Package org.openid4java.discovery

Examples of org.openid4java.discovery.Identifier


    }
    User tempUser = tempUserOptional.get();

    // Retrieve the discovery information
    final DiscoveryInformationMemento memento = tempUser.getOpenIDDiscoveryInformationMemento();
    Identifier identifier = new Identifier() {
      @Override
      public String getIdentifier() {
        return memento.getClaimedIdentifier();
      }
    };
View Full Code Here


            // 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)) {
                    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 {
                    httpSession.setAttribute(OpenIdConstants.HTTPSESSION_OPENID_ID, openIdIdentity);
                }
                httpSession.setAttribute(OpenIdConstants.HTTPSESSION_OPENID_URL, verified.getIdentifier());

            } else {
                httpSession.setAttribute(OpenIdConstants.HTTPSESSION_OPENID_ID, null);
                httpSession.setAttribute(OpenIdConstants.HTTPSESSION_OPENID_PROVIDER, null);
                httpSession.setAttribute(OpenIdConstants.HTTPSESSION_OPENID_URL, null);
View Full Code Here

                        "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
                                                                        // email
                                                                        // address
            }

            // invoke the callbacks
            if (callback != null) {
                callback.afterOpenIdAuth(authResult);
                if (callback.getRedirectToUrl() != null) {
                    userRedirect.setLocalUrl(callback.getRedirectToUrl());
                }
            }

            if (verified != null) {
                return verified.getIdentifier();
            }
        } catch (OpenIDException e) {
            LOGGER.warn("exception", e);
        }
View Full Code Here

        // asserted identifier in the AuthResponse
        String assertId = authResp.getIdentity();

        // claimed identifier in the AuthResponse
        Identifier respClaimed =
            _discovery.parseIdentifier(authResp.getClaimed(), true);

        // the OP endpoint sent in the response
        String respEndpoint = authResp.getOpEndpoint();

        if (DEBUG)
            _log.debug("Verifying discovered information for OpenID2 assertion " +
                       "about ClaimedID: " + respClaimed.getIdentifier());


        // was the claimed identifier in the assertion previously discovered?
        if (discovered != null && discovered.hasClaimedIdentifier() &&
                discovered.getClaimedIdentifier().equals(respClaimed) )
View Full Code Here

                       "null assertion or discovered information.");

            return result;
        }

        Identifier claimedId = discovered.isVersion2() ?
            _discovery.parseIdentifier(authResp.getClaimed()) : //may have frag
            discovered.getClaimedIdentifier(); //assert id may be delegate in v1

        String handle = authResp.getHandle();
        URL op = discovered.getOPEndpoint();
        Association assoc = _associations.load(op.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(claimedId);
                if (DEBUG) _log.debug("Local signature verification succeeded.");
            }
            else
            {
                result.setStatusMsg("Local signature verification failed");
                if (DEBUG)
                    _log.debug("Local signature verification failed.");
            }

        }
        else // no association, verify with the OP
        {
            _log.info("No association found, " +
                      "contacting the OP for direct verification...");

            VerifyRequest vrfy = VerifyRequest.createVerifyRequest(authResp);

            ParameterList responseParams = new ParameterList();

            int respCode = call(op.toString(), vrfy, responseParams);
            if (HttpStatus.SC_OK == respCode)
            {
                VerifyResponse vrfyResp =
                        VerifyResponse.createVerifyResponse(responseParams);

                vrfyResp.validate();

                if (vrfyResp.isSignatureVerified())
                {
                    // process the optional invalidate_handle first
                    String invalidateHandle = vrfyResp.getInvalidateHandle();
                    if (invalidateHandle != null)
                        _associations.remove(op.toString(), invalidateHandle);

                    result.setVerifiedId(claimedId);
                    if (DEBUG)
                        _log.debug("Direct signature verification succeeded " +
                                   "with OP: " + op);
                }
                else
                {
                    if (DEBUG)
                        _log.debug("Direct signature verification failed " +
                                "with OP: " + op);
                    result.setStatusMsg("Direct signature verification failed.");
                }
            }
            else
            {
                DirectError err = DirectError.createDirectError(responseParams);

                if (DEBUG) _log.debug("Error verifying signature with the OP: "
                       + op + " error message: " + err.keyValueFormEncoding());

                result.setStatusMsg("Error verifying signature with the OP: "
                                    + err.getErrorMsg());
            }
        }

        Identifier verifiedID = result.getVerifiedId();
        if (verifiedID != null)
            _log.info("Verification succeeded for: " + verifiedID);

        else
            _log.error("Verification failed for: " + authResp.getClaimed()
View Full Code Here

        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

            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()))
                {
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, responseParameters, discovered);

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

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.