Package org.openid4java.message

Examples of org.openid4java.message.AuthSuccess


      // Examine the verification result and extract the verified identifier
      Optional<Identifier> verified = Optional.fromNullable(verification.getVerifiedId());
      if (verified.isPresent()) {
        // Verified
        AuthSuccess authSuccess = (AuthSuccess) verification.getAuthResponse();

        // We have successfully authenticated so remove the temp user
        // and replace it with a potentially new one
        InMemoryUserCache.INSTANCE.hardDelete(tempUser);

        tempUser = new User(null, UUID.randomUUID());
        tempUser.setOpenIDIdentifier(verified.get().getIdentifier());

        // Provide a basic authority in light of successful authentication
        tempUser.getAuthorities().add(Authority.ROLE_PUBLIC);

        // Extract additional information
        if (authSuccess.hasExtension(AxMessage.OPENID_NS_AX)) {
          tempUser.setEmailAddress(extractEmailAddress(authSuccess));
          tempUser.setFirstName(extractFirstName(authSuccess));
          tempUser.setLastName(extractLastName(authSuccess));
        }
        log.info("Extracted a temporary {}", tempUser);
View Full Code Here


            log.info("Receiving URL = " + receivingURL.toString());
            verification = manager.verify(receivingURL.toString(), openidResp, discovered);
            // examine the verification result and extract the verified identifier
            Identifier verified = verification.getVerifiedId();
            if (verified != null) {
                AuthSuccess authSuccess = (AuthSuccess) verification.getAuthResponse();

                HttpSession session = httpRequest.getSession(true);
                session.setAttribute("openid_identifier", authSuccess.getIdentity());
                String emailId = null;
                if (authSuccess.hasExtension(AxMessage.OPENID_NS_AX)) {
                    FetchResponse fetchResp = (FetchResponse) authSuccess.getExtension(AxMessage.OPENID_NS_AX);
                    emailId = (String) fetchResp.getAttributeValues("email").get(0);

                    session.setAttribute("emailFromFetch", fetchResp.getAttributeValues("email").get(0));
                }
                if (authSuccess.hasExtension(SRegMessage.OPENID_NS_SREG)) {
                    SRegResponse sregResp = (SRegResponse) authSuccess.getExtension(SRegMessage.OPENID_NS_SREG);
                    emailId = sregResp.getAttributeValue("email");
                }
                if (emailId != null) {
                    httpSession.setAttribute(OpenIdConstants.HTTPSESSION_OPENID_ID, emailId);
                } else {
View Full Code Here

            // examine the verification result and extract the verified
            // identifier
            Identifier verified = verification.getVerifiedId();
            if (verified != null) {
                AuthSuccess authSuccess = (AuthSuccess) verification
                        .getAuthResponse();
                if (!openId.equals(authSuccess.getIdentity()))
                {
                    throw new ServletException("Invalid Openid");
                }
            }
            
View Full Code Here

        
         // examine the verification result and extract the verified identifier
         Identifier verified = verification.getVerifiedId();
         if (verified != null)
         {
             AuthSuccess authSuccess =
                     (AuthSuccess) verification.getAuthResponse();
            
             //Create an lifecycle event array
             OpenIDLifecycleEvent[] eventArr = new OpenIDLifecycleEvent[]
             {
                  /**Store the id**/
                  new OpenIDLifecycleEvent(TYPE.SESSION,
                       OP.ADD, CONST.OPENID.get(), authSuccess.getIdentity()),
                      
                  /** Store the claimed **/    
                  new OpenIDLifecycleEvent(TYPE.SESSION,
                       OP.ADD, CONST.OPENID_CLAIMED.get(), authSuccess.getClaimed()),
                      
                  /** Indicate success **/    
                  new OpenIDLifecycleEvent(TYPE.SUCCESS,
                       null, null, null)
             };
View Full Code Here

    // examine the verification result and extract the verified identifier
    FetchResponse fetchResponse = null;
    List<MessageExtension> messageExtensions = new ArrayList<MessageExtension>();
    Identifier identifier = verification.getVerifiedId();
    if (identifier != null) {
      AuthSuccess authSuccess = AuthSuccess.createAuthSuccess(responseParameters);
      EROpenIDManager.log.debug("AuthSucess:" + authSuccess);

      if (authSuccess.hasExtension(AxMessage.OPENID_NS_AX)) {
        MessageExtension ext = authSuccess.getExtension(AxMessage.OPENID_NS_AX);
        messageExtensions.add(ext);
        EROpenIDManager.log.debug("MessageExtension (AX):" + ext);
        // handle backwards, deprecated compatibility
        if (ext instanceof FetchResponse && fetchResponse == null)
          fetchResponse = (FetchResponse)ext;
      }

      if (authSuccess.hasExtension(SRegMessage.OPENID_NS_SREG)) {
        MessageExtension ext = authSuccess.getExtension(SRegMessage.OPENID_NS_SREG);
        messageExtensions.add(ext);
        EROpenIDManager.log.debug("MessageExtension (SREG):" + ext);
      }

      if (authSuccess.hasExtension(SRegMessage.OPENID_NS_SREG11)) {
        MessageExtension ext = authSuccess.getExtension(SRegMessage.OPENID_NS_SREG11);
        messageExtensions.add(ext);
        EROpenIDManager.log.debug("MessageExtension (SREG11):" + ext);
      }
    }
View Full Code Here

    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);

          if (ext instanceof FetchResponse) {
            FetchResponse fetchResp = (FetchResponse) ext;

            details.setMail(fetchResp.getAttributeValue("email"));

            String fullname = fetchResp.getAttributeValue("fullname");
            if (fullname == null) {
              String firstname = fetchResp.getAttributeValue("firstname");
              String lastname = fetchResp.getAttributeValue("lastname");

              if (firstname == null) {
                fullname = lastname == null ? null : lastname;
              } else if (lastname != null) {
                fullname = firstname + " " + lastname;
              } else {
                fullname = firstname;
              }
            }
            details.setName(fullname);
          }
        } else if (authSuccess.hasExtension(SRegMessage.OPENID_NS_SREG)) {
          MessageExtension extension = authSuccess.getExtension(SRegMessage.OPENID_NS_SREG);
          if (extension instanceof SRegResponse) {
            SRegResponse sRegResponse = (SRegResponse) extension;
            details.setMail(sRegResponse.getAttributeValue("email"));
            details.setName(sRegResponse.getAttributeValue("fullname"));
          }
View Full Code Here

    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);

          if (ext instanceof FetchResponse) {
            FetchResponse fetchResp = (FetchResponse) ext;

            details.setMail(fetchResp.getAttributeValue("email"));

            String fullname = fetchResp.getAttributeValue("fullname");
            if (fullname == null) {
              String firstname = fetchResp.getAttributeValue("firstname");
              String lastname = fetchResp.getAttributeValue("lastname");

              if (firstname == null) {
                fullname = lastname == null ? null : lastname;
              } else if (lastname != null) {
                fullname = firstname + " " + lastname;
              } else {
                fullname = firstname;
              }
            }
            details.setName(fullname);
          }
        } else if (authSuccess.hasExtension(SRegMessage.OPENID_NS_SREG)) {
          MessageExtension extension = authSuccess.getExtension(SRegMessage.OPENID_NS_SREG);
          if (extension instanceof SRegResponse) {
            SRegResponse sRegResponse = (SRegResponse) extension;
            details.setMail(sRegResponse.getAttributeValue("email"));
            details.setName(sRegResponse.getAttributeValue("fullname"));
          }
View Full Code Here

        
         // examine the verification result and extract the verified identifier
         Identifier verified = verification.getVerifiedId();
         if (verified != null)
         {
             AuthSuccess authSuccess =
                     (AuthSuccess) verification.getAuthResponse();
            
             //Create an lifecycle event array
             OpenIDLifecycleEvent[] eventArr = new OpenIDLifecycleEvent[]
             {
                  /**Store the id**/
                  new OpenIDLifecycleEvent(TYPE.SESSION,
                       OP.ADD, CONST.OPENID.get(), authSuccess.getIdentity()),
                      
                  /** Store the claimed **/    
                  new OpenIDLifecycleEvent(TYPE.SESSION,
                       OP.ADD, CONST.OPENID_CLAIMED.get(), authSuccess.getClaimed()),
                      
                  /** Indicate success **/    
                  new OpenIDLifecycleEvent(TYPE.SUCCESS,
                       null, null, null)
             };
View Full Code Here

    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);

          if (ext instanceof FetchResponse) {
            FetchResponse fetchResp = (FetchResponse) ext;

            details.setMail(fetchResp.getAttributeValue("email"));

            String fullname = fetchResp.getAttributeValue("fullname");
            if (fullname == null) {
              String firstname = fetchResp.getAttributeValue("firstname");
              String lastname = fetchResp.getAttributeValue("lastname");

              if (firstname == null) {
                fullname = lastname == null ? null : lastname;
              } else if (lastname != null) {
                fullname = firstname + " " + lastname;
              } else {
                fullname = firstname;
              }
            }
            details.setName(fullname);
          }
        } else if (authSuccess.hasExtension(SRegMessage.OPENID_NS_SREG)) {
          MessageExtension extension = authSuccess.getExtension(SRegMessage.OPENID_NS_SREG);
          if (extension instanceof SRegResponse) {
            SRegResponse sRegResponse = (SRegResponse) extension;
            details.setMail(sRegResponse.getAttributeValue("email"));
            details.setName(sRegResponse.getAttributeValue("fullname"));
          }
View Full Code Here

      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
              .getExtension(AxMessage.OPENID_NS_AX);

          p.setEmail(fetchResp.getAttributeValue("email"));
          p.setFirstName(fetchResp.getAttributeValue("firstname"));
          p.setLastName(fetchResp.getAttributeValue("lastname"));
View Full Code Here

TOP

Related Classes of org.openid4java.message.AuthSuccess

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.