Package org.openid4java.consumer

Examples of org.openid4java.consumer.VerificationResult


        logger.debug("discoveryInformation : {}", discoveryInformation);

        try {
            final String contextualCallbackUrl = getContextualCallbackUrl(context);
            // verify the response
            final VerificationResult verification = this.consumerManager.verify(contextualCallbackUrl, parameterList,
                    discoveryInformation);

            // examine the verification result and extract the verified identifier
            final Identifier verified = verification.getVerifiedId();
            if (verified != null) {
                final AuthSuccess authSuccess = (AuthSuccess) verification.getAuthResponse();
                logger.debug("authSuccess : {}", authSuccess);

                final U profile = createProfile(authSuccess);
                profile.setId(verified.getIdentifier());
                logger.debug("profile : {}", profile);
View Full Code Here


        receivingURL.append("?").append(request.getQueryString());
     
      // verify the response; ConsumerManager needs to be the same
      // (static) instance used to place the authentication request
      System.out.println("actual verify");
      VerificationResult verification = manager.verify(receivingURL.toString(), responseParams, null);
      // examine the verification result and extract the verified
      // identifier
      System.out.println("getting verified id");
      Identifier id = verification.getVerifiedId();
     
      if (id != null) {
        System.out.println("id found");
        UserDetails userDetails = new UserDetails();
        userDetails.setUniqueId(HttpCookies.getCookieValue(request, uniqueIdCookieName));
        userDetails.setOpenId(id.getIdentifier());
        AuthSuccess authSuccess = (AuthSuccess) verification.getAuthResponse();
        System.out.println("retrieved auth response");
        if (authSuccess.hasExtension(AxMessage.OPENID_NS_AX)) {
          System.out.println("doing stuff for auth extension");
          MessageExtension ext = authSuccess.getExtension(AxMessage.OPENID_NS_AX);
View Full Code Here

        if ((queryString != null) && (queryString.length() > 0)) {
            receivingURL.append("?").append(request.getQueryString());
        }

        // verify the response
        VerificationResult verification;

        try {
            verification = consumerManager.verify(receivingURL.toString(), openidResp, discovered);
        } catch (MessageException e) {
            throw new OpenIDConsumerException("Error verifying openid response", e);
        } catch (DiscoveryException e) {
            throw new OpenIDConsumerException("Error verifying openid response", e);
        } catch (AssociationException e) {
            throw new OpenIDConsumerException("Error verifying openid response", e);
        }

        // fetch the attributesToFetch of the response
        Message authSuccess = verification.getAuthResponse();
        List<OpenIDAttribute> attributes = new ArrayList<OpenIDAttribute>(this.attributesToFetch.size());

        if (authSuccess.hasExtension(AxMessage.OPENID_NS_AX)) {
            if (debug) {
                logger.debug("Extracting attributes retrieved by attribute exchange");
            }
            try {
                MessageExtension ext = authSuccess.getExtension(AxMessage.OPENID_NS_AX);
                if (ext instanceof FetchResponse) {
                    FetchResponse fetchResp = (FetchResponse) ext;
                    for (OpenIDAttribute attr : attributesToFetch) {
                        List<String> values = fetchResp.getAttributeValues(attr.getName());
                        if (!values.isEmpty()) {
                            OpenIDAttribute fetched = new OpenIDAttribute(attr.getName(), attr.getType(), values);
                            fetched.setRequired(attr.isRequired());
                            attributes.add(fetched);
                        }
                    }
                }
            } catch (MessageException e) {
                attributes.clear();
                throw new OpenIDConsumerException("Attribute retrieval failed", e);
            }
            if (debug) {
                logger.debug("Retrieved attributes" + attributes);
            }
        }

        // examine the verification result and extract the verified identifier
        Identifier verified = verification.getVerifiedId();

        if (verified == null) {
            Identifier id = discovered.getClaimedIdentifier();
            return new OpenIDAuthenticationToken(OpenIDAuthenticationStatus.FAILURE,
                    id == null ? "Unknown" : id.getIdentifier(),
                    "Verification status message: [" + verification.getStatusMsg() + "]", attributes);
        }

        return new OpenIDAuthenticationToken(OpenIDAuthenticationStatus.SUCCESS, verified.getIdentifier(),
                        "some message", attributes);
    }
View Full Code Here

            if (queryString != null && queryString.length() > 0)
                receivingURL.append("?").append(httpReq.getQueryString());

            // verify the response; ConsumerManager needs to be the same
            // (static) instance used to place the authentication request
            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();

                HttpSession session = httpReq.getSession(true);
                session.setAttribute("openid_identifier", authSuccess.getIdentity());

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

      // Verify the response
      // ConsumerManager needs to be the same (static) instance used
      // to place the authentication request
      // This could be tricky if this service is load-balanced
      VerificationResult verification = consumerManager.verify(
        receivingURL.toString(),
        parameterList,
        discovered);

      // 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);
View Full Code Here

            String queryString = httpRequest.getQueryString();
            if (queryString != null && queryString.length() > 0) {
                receivingURL.append("?").append(httpRequest.getQueryString());
            }
            // verify the response
            VerificationResult verification = null;
            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)) {
View Full Code Here

                receivingURL.append("?").append(httpReq.getQueryString());
            }

            // verify the response; ConsumerManager needs to be the same
            // (static) instance used to place the authentication request
            VerificationResult verification =
                    manager.verify(receivingURL.toString(), response,
                            discovered);

            // The OpenId provider cancelled the authentication
            if ("cancel".equals(response.getParameterValue("openid.mode"))) {
                // TODO This should be done at a higher level. i.e. instead of
                // returning a string, return an
                // object that holds more information for the UI to render
                FacesMessages.instance().add(StatusMessage.Severity.INFO,
                        "Authentication Request Cancelled");
            }

            // examine the verification result and extract the verified
            // identifier
            Identifier verified = verification.getVerifiedId();
            if (verified != null) {
                authResult = new OpenIdAuthenticationResult();
                authResult.setAuthenticatedId(verified.getIdentifier());
                authResult.setEmail(openIdProvider.getEmail(response)); // Get
                                                                        // the
View Full Code Here

        if (queryString != null && queryString.length() > 0) {
            receivingURL.append("?").append(request.getQueryString());
        }

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

        // examine the verification result and extract the verified identifier
        Identifier identifier = verification.getVerifiedId();
        ModelAndView modelAndView = new ModelAndView("answer");
        modelAndView.addObject("identifier", identifier);
        return modelAndView;
    }
View Full Code Here

               resp.releaseConnection();
            }

            // verify the response; ConsumerManager needs to be the same
            // (static) instance used to place the authentication request
            VerificationResult verification =
                manager.verify(returnToUrl.toString(), response, discovered);

            // 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

     
      // verify the response; ConsumerManager needs to be the same
      // (static) instance used to place the authentication request
      try
      {
         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();
            
             //Create an lifecycle event array
             OpenIDLifecycleEvent[] eventArr = new OpenIDLifecycleEvent[]
             {
                  /**Store the id**/
View Full Code Here

TOP

Related Classes of org.openid4java.consumer.VerificationResult

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.