Package org.openid4java.association

Examples of org.openid4java.association.Association


                "Cannot process OpenID-token RST",
                "No claimed identifier found.");
            return;
        }

        Association assoc;
        try
        {
            assoc = _privateAssociations.generate(
                org.openid4java.association.Association.TYPE_HMAC_SHA1, _expireIn.intValue());
        }
        catch (AssociationException e)
        {
            setWstFault(constants, response,
                "Cannot instantiate private association store",
                e.getMessage());
            return;
        }

        if (! compat && _opEndpoint == null)
        {
            setWstFault(constants, response,
                "Cannot process OpenID-token RST",
                "OP-Endpoint not configured; required for OpenID 2 messages.");
            return;
        }

        // nonces not used: OP invalidates private assoc handle on first use
        String nonce = _nonceGenerator.next();

        AuthSuccess openidResp;
        try
        {
            openidResp = AuthSuccess.createAuthSuccess(
            _opEndpoint, claimedID, claimedID,
            compat, uriAppliesTo.toString(), nonce,
            null, assoc, false);

            if (! compat)
            {
                FetchResponse fetchResp = FetchResponse.createFetchResponse();
                fetchResp.addAttributes(attrs);
                openidResp.addExtension(fetchResp);
            }

            // sign the message
            openidResp.setSignature(assoc.sign(openidResp.getSignedText()));
        }
        catch (OpenIDException e)
        {
            setWstFault(constants, response,
                "Cannot generate OpenID assertion",
View Full Code Here


        throw new AssociationException (
                          "Invalid association data retrived from database; cannot create Association "
                              + "object for handle: "
                              + handle ) ;

      Association assoc ;

      if ( Association.TYPE_HMAC_SHA1.equals ( type ) )
        assoc = Association.createHmacSha1 handle,
                            Base64.decodeBase64 ( macKey.getBytes ( ) ),
                            expDate ) ;
View Full Code Here

      String handle = (String) res.get ( "handle" ) ;
      String type = (String) res.get ( "type" ) ;
      String macKey = (String) res.get ( "mackey" ) ;
      Date expDate = (Date) res.get ( "expdate" ) ;

      Association assoc ;

            if ( expDate == null || ( type == null || macKey == null ) &&
                 ! Association.FAILED_ASSOC_HANDLE.equals(handle) ) {
        throw new AssociationException (
                          "Invalid expiry date retrived from database; cannot create Association "
View Full Code Here

    public synchronized Association load(String opUrl)
    {
        removeExpired();

        Association latest = null;

        if (_opMap.containsKey(opUrl))
        {
            Map handleMap = (Map) _opMap.get(opUrl);

            Iterator handles = handleMap.keySet().iterator();
            while (handles.hasNext())
            {
                String handle = (String) handles.next();

                Association association = (Association) handleMap.get(handle);

                if (latest == null ||
                        latest.getExpiry().before(association.getExpiry()))
                    latest = association;
            }
        }

        return latest;
View Full Code Here

            Iterator handles = handleMap.keySet().iterator();
            while (handles.hasNext())
            {
                String handle = (String) handles.next();

                Association association = (Association) handleMap.get(handle);

                if (association.hasExpired())
                {
                    handleToRemove.add(handle);
                }
            }
View Full Code Here

        {
            try
            {
                String handle = Long.toHexString(_random.nextLong());

                Association association =
                        Association.generate(type, handle, expiryIn);

                int cnt = jdbcTemplate.update(sql,
                        new Object[] {
                                association.getHandle(),
                                association.getType(),
                                new String(Base64.encodeBase64(
                                        association.getMacKey().getEncoded())),
                                association.getExpiry()
                        });

                if (cnt == 1)
                {
                    if (DEBUG)
View Full Code Here

            if (DEBUG) _log.debug("Unencrypted MAC key (base64): "
                                  + getParameterValue("mac_key"));
        }

        Association assoc;

        if (Association.TYPE_HMAC_SHA1.equals(type.getAssociationType()))
            assoc = Association.createHmacSha1(handle, macKey, expiresIn);

        else if (Association.TYPE_HMAC_SHA256.equals(type.getAssociationType()))
View Full Code Here

            throw new ConsumerException("Authentication cannot continue: " +
                    "no discovery information provided.");

        associate(discovered, _maxAssocAttempts);

        Association assoc =
                _associations.load(discovered.getIdpEndpoint().toString());
        String handle = assoc != null ?
                assoc.getHandle() : Association.FAILED_ASSOC_HANDLE;

        // get the Claimed ID
        String claimedId;
        if (discovered.hasClaimedIdentifier())
            claimedId = discovered.getClaimedIdentifier().getIdentifier();
View Full Code Here

            {
                if (DEBUG) _log.debug("Found matching service: " + service);
                firstServiceMatch = service;
            }

            Association assoc = _associations.load(
                    service.getIdpEndpoint().toString(),
                    authResp.getHandle());

            // don't look further if there is an association with this endpoint
            if (assoc != null)
View Full Code Here

            return result;
        }

        String handle = authResp.getHandle();
        URL idp = discovered.getIdpEndpoint();
        Association assoc = _associations.load(idp.toString(), handle);

        if (assoc != null) // association available, local verification
        {
            _log.info("Found association: " + assoc.getHandle() +
                      " verifying signature locally...");
            String text = authResp.getSignedText();
            String signature = authResp.getSignature();

            if (assoc.verifySignature(text, signature))
            {
                result.setVerifiedId(discovered.getClaimedIdentifier());
                if (DEBUG) _log.debug("Local signature verification succeeded.");
            }
            else if (DEBUG) _log.debug("Local signature verification failed.");
View Full Code Here

TOP

Related Classes of org.openid4java.association.Association

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.