Examples of VerificationResult


Examples of org.openid4java.consumer.VerificationResult

    @Test
    public void failedVerificationReturnsFailedAuthenticationStatus() throws Exception {
        ConsumerManager mgr = mock(ConsumerManager.class);
        OpenID4JavaConsumer consumer = new OpenID4JavaConsumer(mgr, new NullAxFetchListFactory());
        VerificationResult vr = mock(VerificationResult.class);
        DiscoveryInformation di = mock(DiscoveryInformation.class);

        when(mgr.verify(anyString(), any(ParameterList.class), any(DiscoveryInformation.class))).thenReturn(vr);

        MockHttpServletRequest request = new MockHttpServletRequest();
View Full Code Here

Examples of org.openid4java.consumer.VerificationResult

    @SuppressWarnings("serial")
    @Test
    public void successfulVerificationReturnsExpectedAuthentication() throws Exception {
        ConsumerManager mgr = mock(ConsumerManager.class);
        OpenID4JavaConsumer consumer = new OpenID4JavaConsumer(mgr, new NullAxFetchListFactory());
        VerificationResult vr = mock(VerificationResult.class);
        DiscoveryInformation di = mock(DiscoveryInformation.class);
        Identifier id = new Identifier() {
            public String getIdentifier() {
                return "id";
            }
        };
        Message msg = mock(Message.class);

        when(mgr.verify(anyString(), any(ParameterList.class), any(DiscoveryInformation.class))).thenReturn(vr);
        when(vr.getVerifiedId()).thenReturn(id);
        when(vr.getAuthResponse()).thenReturn(msg);

        MockHttpServletRequest request = new MockHttpServletRequest();

        request.getSession().setAttribute(DiscoveryInformation.class.getName(), di);
        request.getSession().setAttribute("SPRING_SECURITY_OPEN_ID_ATTRIBUTES_FETCH_LIST", attributes);
View Full Code Here

Examples of org.openid4java.consumer.VerificationResult

        if (StringUtils.hasLength(queryString)) {
            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);
        }

        // 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() + "]",
                    Collections.<OpenIDAttribute>emptyList());
        }

        List<OpenIDAttribute> attributes = fetchAxAttributes(verification.getAuthResponse(), attributesToFetch);

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

Examples of org.openid4java.consumer.VerificationResult

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

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

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

         if (identifier != null)
         {
            AuthSuccess authSuccess = (AuthSuccess) verification.getAuthResponse();

            Map<String, List<String>> attributeValues = null;
            if (authSuccess.hasExtension(AxMessage.OPENID_NS_AX))
            {
               FetchResponse fetchResp = (FetchResponse) authSuccess.getExtension(AxMessage.OPENID_NS_AX);
               @SuppressWarnings("unchecked")
               Map<String, List<String>> attrValues = fetchResp.getAttributes();
               attributeValues = attrValues;
            }

            OpenIdPrincipal principal = createPrincipal(identifier.getIdentifier(),
                  discovered.getOPEndpoint(), attributeValues);

            openIdRelyingPartySpi.get().loginSucceeded(principal,
                  responseHandler.createResponseHolder(httpResponse));
         }
         else
         {
            openIdRelyingPartySpi.get().loginFailed(verification.getStatusMsg(),
                  responseHandler.createResponseHolder(httpResponse));
         }
      }
      catch (OpenIDException e)
      {
View Full Code Here

Examples of org.openid4java.consumer.VerificationResult

            StringBuffer receivingURL = request.getRequestURL();
            String queryString = request.getQueryString();
            if( queryString != null && queryString.length() > 0 )
                receivingURL.append("?").append(queryString);
            VerificationResult verification = manager.verify(receivingURL.toString(), openidResp, discovered);

            Identifier verified = verification.getVerifiedId();
            String openid = null;
           
            if( verified != null ){
                AuthSuccess authSuccess = (AuthSuccess)verification.getAuthResponse();
                /*
                 * This piece of code does not work with blogspot.com while it works well
                 * with myopenid.com.
                request.setAttribute("opendpoint", authSuccess.getOpEndpoint());
                request.setAttribute("claimed", authSuccess.getClaimed());
View Full Code Here

Examples of org.openid4java.consumer.VerificationResult

            }

            // verify the response; ConsumerManager needs to be the same
            // (static) instance used to place the authentication request

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

            // examine the verification result and extract the verified
            // identifier

            final Identifier verified = verification.getVerifiedId();
            if (verified != null) {
                final AuthSuccess authSuccess = (AuthSuccess) verification.getAuthResponse();
                if (authSuccess.hasExtension(AxMessage.OPENID_NS_AX)) {
                    final FetchResponse fetchResp = (FetchResponse) authSuccess.getExtension(AxMessage.OPENID_NS_AX);
                    final String email = fetchResp.getAttributeValue("email");
                    final String lastname = fetchResp.getAttributeValue("LastName");
                    final String firstname = fetchResp.getAttributeValue("FirstName");
View Full Code Here

Examples of org.openid4java.consumer.VerificationResult

            throws OpenIDException, IdentityException {

        DiscoveryInformation discovered = null;
        String receivingURL = null;
        String queryString = null;
        VerificationResult verification = null;
        Identifier verified = null;
        HttpSession session = null;

        session = request.getSession();
View Full Code Here

Examples of org.openid4java.consumer.VerificationResult

    // from repeating discovery later, and will allow us to modify the
    // VerificationResult depending on whether the discovery was secure.
    SecureDiscoveryInformation d2 = getDiscoveryInfoForClaimedId(authResponse,
        discovered);

    VerificationResult verification =
      consumerManager.verify(receivingUrl, authResponse, d2);

    // the only indication that something went wrong during nonce and
    // signature checking is if the returned identity is null. In that case,
    // we don't even want to return anything.
    if ((verification.getAuthResponse() instanceof AuthSuccess)
        && (verification.getVerifiedId() == null)) {
      throw new VerificationException("something went wrong during " +
          "response verification, such as nonce or signature checking. " +
          "Check your debug logs.");
    }
View Full Code Here

Examples of org.openid4java.consumer.VerificationResult

            log.info("OpenID disc : " + discovered.getOPEndpoint());
            log.info("OpenID orig ref : " + getOriginalRef());
            ConsumerManager manager = getManager(discovered.getOPEndpoint()
                    .toString());

            VerificationResult verification = manager.verify(getOriginalRef()
                    .toString(), response, discovered);
            log.info("verification = " + verification);

            // examine the verification result and extract the verified
            // identifier
            Identifier verified = verification.getVerifiedId();
            log.info("verified = " + verified);
            if (verified != null) {
                AuthSuccess authSuccess = (AuthSuccess) verification
                        .getAuthResponse();

                if (authSuccess.hasExtension(AxMessage.OPENID_NS_AX)) {
                    FetchRequest fetchResp = (FetchRequest) authSuccess
                            .getExtension(AxMessage.OPENID_NS_AX);
View Full Code Here

Examples of org.openid4java.consumer.VerificationResult

            ConsumerManager manager = getManager(discovered.getOPEndpoint()
                    .toString());
            String redir = request.getResourceRef().getHostIdentifier()
                    + request.getResourceRef().getPath() + "?return=true";

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

            // examine the verification result and extract the verified
            // identifier
            Identifier verified = verification.getVerifiedId();
            l.info("verified = " + verified);
            if (verified != null) {
                AuthSuccess authSuccess = (AuthSuccess) verification
                        .getAuthResponse();

                if (authSuccess.hasExtension(AxMessage.OPENID_NS_AX)) {
                    FetchResponse fetchResp = (FetchResponse) authSuccess
                            .getExtension(AxMessage.OPENID_NS_AX);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.