Package org.openid4java.discovery

Examples of org.openid4java.discovery.Identifier


  public void processReturn(PageParameters params) {
    ParameterList response = new ParameterList(params);
    try {
      VerificationResult verificationResult = getConsumerManager().verify(getOpenIdReturnUrl(), response,
          discoveryInformation);
      Identifier verifiedIdentifier = verificationResult.getVerifiedId();
      if (verifiedIdentifier != null) {
        AuthSuccess authSuccess = (AuthSuccess) verificationResult.getAuthResponse();

        OpenIdDetails details = new OpenIdDetails();
        details.setOpenId(verifiedIdentifier.getIdentifier());

        // try to get additional details
        if (authSuccess.hasExtension(AxMessage.OPENID_NS_AX)) {
          MessageExtension ext = authSuccess.getExtension(AxMessage.OPENID_NS_AX);
View Full Code Here


         VerificationResult verification = this.consumerManager.verify(
                 receivedURL,
                 responselist, discovered);
        
         // examine the verification result and extract the verified identifier
         Identifier verified = verification.getVerifiedId();
         if (verified != null)
         {
             AuthSuccess authSuccess =
                     (AuthSuccess) verification.getAuthResponse();
            
View Full Code Here

            VerificationResult verification = manager.verify(
                    receivingURL.toString(),
                    response, discovered);

            // examine the verification result and extract the verified identifier
            Identifier verified = verification.getVerifiedId();
            if (verified != null)
            {
                AuthSuccess authSuccess =
                        (AuthSuccess) verification.getAuthResponse();
View Full Code Here

    /*
     * The OpenID provider returns to this action
     */
    public void verify() {
        Identifier verified = (Identifier) getAuthenticator().verify(getCtx());
        if (verified != null) {
            storeLoggedInUser(verified.getIdentifier());
            printStatus();
        } else {
            print("Unable to verify.");
        }
    }
View Full Code Here

  public void processReturn(PageParameters params) {
    ParameterList response = new ParameterList(WicketUtils.toMap(params));
    try {
      VerificationResult verificationResult = getConsumerManager().verify(getOpenIdReturnUrl(), response,
          discoveryInformation);
      Identifier verifiedIdentifier = verificationResult.getVerifiedId();
      if (verifiedIdentifier != null) {
        AuthSuccess authSuccess = (AuthSuccess) verificationResult.getAuthResponse();

        OpenIdDetails details = new OpenIdDetails();
        details.setOpenId(verifiedIdentifier.getIdentifier());

        // try to get additional details
        if (authSuccess.hasExtension(AxMessage.OPENID_NS_AX)) {
          MessageExtension ext = authSuccess.getExtension(AxMessage.OPENID_NS_AX);
View Full Code Here

      VerificationResult verification = manager.verify(
          receivingURL.toString(), response, discovered);

      // examine the verification result and extract the verified
      // identifier
      Identifier verified = verification.getVerifiedId();
      if (verified != null) {
        LOG.debug("Verified Id : " + verified.getIdentifier());
        Profile p = new Profile();
        p.setValidatedId(verified.getIdentifier());
        AuthSuccess authSuccess = (AuthSuccess) verification
            .getAuthResponse();

        if (authSuccess.hasExtension(AxMessage.OPENID_NS_AX)) {
          FetchResponse fetchResp = (FetchResponse) authSuccess
View Full Code Here

  public void processReturn(PageParameters params) {
    ParameterList response = new ParameterList(params);
    try {
      VerificationResult verificationResult = getConsumerManager().verify(getOpenIdReturnUrl(), response,
          discoveryInformation);
      Identifier verifiedIdentifier = verificationResult.getVerifiedId();
      if (verifiedIdentifier != null) {
        AuthSuccess authSuccess = (AuthSuccess) verificationResult.getAuthResponse();

        OpenIdDetails details = new OpenIdDetails();
        details.setOpenId(verifiedIdentifier.getIdentifier());

        // try to get additional details
        if (authSuccess.hasExtension(AxMessage.OPENID_NS_AX)) {
          MessageExtension ext = authSuccess.getExtension(AxMessage.OPENID_NS_AX);
View Full Code Here

                    {
                        // standard OpenId verification
                        verificationResults = openIDVerification(authRequestURL, authParams, discovered);
                    }
                    VerificationResult verification = verificationResults.verification;
                    Identifier verifiedIdentifier = verificationResults.verifiedIdentifier;

                    // extract identifier from verified authenticated request
                    if (verifiedIdentifier == null)
                    {
                        throw new RuntimeException("Verified identifier unavailable for authenticated OpenID login");                   
                    }
                    authenticatedByProvider = true;
                   
                    String email = null;
                    String firstName = null;
                    String lastName = null;
                    String nickname = null;               
                    String fullName = null;
                    // extract requested attribute exchange data
                    AuthSuccess authResponse = (AuthSuccess)verification.getAuthResponse();
                    if (authResponse.hasExtension(AxMessage.OPENID_NS_AX))
                    {
                        try
                        {
                            FetchResponse axResponse = (FetchResponse)authResponse.getExtension(AxMessage.OPENID_NS_AX);
                            email = axResponse.getAttributeValue("email");
                            fullName = axResponse.getAttributeValue("fullname");
                            firstName = axResponse.getAttributeValue("firstname");
                            lastName = axResponse.getAttributeValue("lastname");
                            nickname = axResponse.getAttributeValue("nickname");
                        }
                        catch (OpenIDException oide)
                        {
                            throw new RuntimeException("Unexpected OpenID authenticated attribute exchange fetch exception: "+oide, oide);
                        }
                    }
                    // extract requested simple registration data
                    if (authResponse.hasExtension(SRegMessage.OPENID_NS_SREG))
                    {
                        try
                        {
                            SRegResponse sregResponse = (SRegResponse)authResponse.getExtension(SRegMessage.OPENID_NS_SREG);
                            email = sregResponse.getAttributeValue("email");
                            fullName = sregResponse.getAttributeValue("fullname");
                            nickname = sregResponse.getAttributeValue("nickname");
                        }
                        catch (OpenIDException oide)
                        {
                            throw new RuntimeException("Unexpected OpenID authenticated simple registration fetch exception: "+oide, oide);
                        }
                    }

                    // log authenticated request
                    if (log.isDebugEnabled())
                    {
                        log.debug("Authenticated OpenID verified identifier: "+verifiedIdentifier.getIdentifier()+", email="+email+", fullname="+fullName+", firstname="+firstName+", lastname="+lastName+", nickname="+nickname);
                    }

                    // validate and default attributes
                    if (email == null)
                    {
View Full Code Here

                AuthSuccess authResponse = AuthSuccess.createAuthSuccess(authParams);
                if ((authResponse != null) && authResponse.isVersion2() && (authResponse.getIdentity() != null) && (authResponse.getClaimed() != null))
                {
                    // get OpenId identifier
                    String providerId = authResponse.getIdentity();
                    Identifier responseClaimedId = openIDStep2ConsumerManager.getDiscovery().parseIdentifier(authResponse.getClaimed(), true);
                    String responseEndpoint = authResponse.getOpEndpoint();
                   
                    if (log.isDebugEnabled())
                    {
                        log.debug("Step2 discovery for identity: "+responseClaimedId);
                    }

                    // get Step2 secure discovery information
                    SecureDiscoveryInformation secureDiscovered = null;
                   
                    // validate previously discovered secure discovery information
                    if (discovered instanceof SecureDiscoveryInformation)
                    {
                        // check for matching version, identifiers, and endpoints
                        if (discovered.isVersion2() && discovered.hasClaimedIdentifier() && discovered.getClaimedIdentifier().equals(responseClaimedId) && discovered.getOPEndpoint().equals(responseEndpoint))
                        {
                            String discoveredProviderId = (discovered.hasDelegateIdentifier() ? discovered.getDelegateIdentifier() : discovered.getClaimedIdentifier().getIdentifier());
                            if (discoveredProviderId.equals(providerId))
                            {
                                secureDiscovered = (SecureDiscoveryInformation)discovered;

                                if (log.isDebugEnabled())
                                {
                                    log.debug("Matched previously discovered Step2 secure discovery information for "+responseClaimedId+" identity: "+secureDiscovered.getOPEndpoint());
                                }
                            }
                        }
                    }

                    // discover secure discovery information if necessary
                    if (secureDiscovered == null)
                    {
                        // perform discovery on claimed identifier
                        List<SecureDiscoveryInformation> discoveredInfos = openIDStep2ConsumerManager.getDiscovery().discover(responseClaimedId);
                        // match secure discovered information: prefer previously associated matches
                        for (SecureDiscoveryInformation discoveredInfo : discoveredInfos)
                        {
                            // match secure discovered information
                            String version = discoveredInfo.getVersion();
                            if ((version != null) && version.equals(DiscoveryInformation.OPENID2_OP) && discoveredInfo.isVersion2() && discoveredInfo.getOPEndpoint().equals(responseEndpoint))
                            {
                                String discoveredProviderId = (discoveredInfo.hasDelegateIdentifier() ? discoveredInfo.getDelegateIdentifier() : discoveredInfo.getClaimedIdentifier().getIdentifier());
                                if (discoveredProviderId.equals(providerId))
                                {
                                    // match previously associated or first discovered
                                    if (openIDStep2ConsumerManager.getPrivateAssociationStore().load(discoveredInfo.getOPEndpoint().toString(), authResponse.getHandle()) != null)
                                    {
                                        secureDiscovered = discoveredInfo;
                                        break;
                                    }
                                    else if (secureDiscovered == null)
                                    {
                                        secureDiscovered = discoveredInfo;                                   
                                    }
                                }                           
                            }
                        }

                        if (log.isDebugEnabled() && (secureDiscovered != null))
                        {
                            log.debug("Discovered Step2 secure discovery information for "+responseClaimedId+" identity: "+secureDiscovered.getOPEndpoint());
                        }
                    }

                    if (log.isDebugEnabled() && (secureDiscovered != null))
                    {
                        log.debug("Verify Step2 OpenID authentication request using: "+secureDiscovered.getOPEndpoint());
                    }

                    // verify using secure discovery information
                    results.verification = openIDStep2ConsumerManager.verify(authRequestURL, authParams, secureDiscovered);

                    if (log.isDebugEnabled() && (results.verification != null))
                    {
                        log.debug("Verified Step2 OpenID authentication request: "+authRequestURL);
                    }
                   
                    // verify secure verified identifier
                    if ((results.verification.getAuthResponse() instanceof AuthSuccess) && (results.verification.getVerifiedId() != null))
                    {
                        // verify secure verification
                        boolean secureVerification = ((secureDiscovered != null) && (secureDiscovered.getClaimedIdentifier() != null) && secureDiscovered.isSecure());
                        if (secureVerification)
                        {
                            try
                            {
                                UrlIdentifier verifiedClaimedId = new UrlIdentifier(results.verification.getVerifiedId().getIdentifier(), true);
                                secureVerification = secureDiscovered.getClaimedIdentifier().getIdentifier().equals(verifiedClaimedId.getIdentifier());
                            }
                            catch (OpenIDException oide)
                            {
                                secureVerification = false;
                            }
                        }
                       
                        // return verified identifier
                        Identifier verifiedId = results.verification.getVerifiedId();
                        results.verifiedIdentifier = (secureVerification ? new SecureUrlIdentifier(verifiedId) : verifiedId);

                        if (log.isDebugEnabled())
                        {
                            log.debug("Verified Step2 OpenID authentication request identity: "+results.verifiedIdentifier);
View Full Code Here

              "Path must be one of \"openidcallback\", \"authrequest\", or \"providers\"");
    }

    if ("openidcallback".equals(paths[0])) {
      // Service the callback     
      Identifier identifier = this.consumer.verifyResponse(req);
      returnIdentifier(identifier, resp);
      return;
    }

    if ("authrequest".equals(paths[0])) {
View Full Code Here

TOP

Related Classes of org.openid4java.discovery.Identifier

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.