Package org.openid4java.discovery

Examples of org.openid4java.discovery.Identifier


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


            Response response) {
        JSONObject obj = null;
        Logger l = Context.getCurrentLogger();
        // Map<String, String> axRequired = new HashMap<String, String>();
        Map<AX, String> axResp = new HashMap<AX, String>();
        Identifier i = verifyResponse(queryParams, axResp, request, response);
        if (i == null) {
            l.info("Authentication Failed");
            return obj;
        }
        l.info("Identifier = " + i.getIdentifier());
        String id = i.getIdentifier();

        if (id != null) {
            // New Code, always return JSON and let filter handle any
            // callback.
            // TODO maybe move it to use Principal.
            obj = new JSONObject();
            try {
                obj.put("id", i.getIdentifier());
                for (AX s : axResp.keySet()) {
                    obj.put(s.toString(), axResp.get(s));
                }
            } catch (JSONException e) {
                l.log(Level.WARNING, "Failed to get the ID!", e);
View Full Code Here

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

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

        // claimed identifier
        Identifier claimedId = discovered.getClaimedIdentifier();

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

        // OP-specific ID
        String opSpecific = discovered.hasDelegateIdentifier() ?
                discovered.getDelegateIdentifier() : claimedId.getIdentifier();

        // does the asserted ID match the OP-specific ID from the discovery?
        if ( opSpecific.equals(assertId) )
            return discovered;  // success
View Full Code Here

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

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

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

                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: " + verifiedID
View Full Code Here

            // 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);
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 if (DEBUG)
            {
                _log.debug("Local signature verification failed.");
                result.setStatusMsg("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

                null, // sepMediaType
                flags,
                state
            );

            Identifier claimedIdentifier = null;
            URL opEndpointUrl;
            CanonicalID canonID;

            if (! baseXRD.getStatus().getCID().equals(Status.CID_VERIFIED)) {
              _log.error("Unverified CanonicalID: " + baseXRD.getCanonicalID() + " of:" + identifier.getIdentifier());
              return false;
            }
           
            if (wantCID)
            {
                canonID = baseXRD.getCanonicalID();

                if (canonID == null) {
                    _log.error("No CanonicalID found for " + srvType +
                            " after XRI resolution of: "
                            + identifier.getIdentifier());
                    return false;
                }

                claimedIdentifier = parseIdentifier(canonID.getValue());
                _log.info("Using canonicalID as claimedID: " +
                          claimedIdentifier.getIdentifier() +
                          " for " + srvType);
            }

            Iterator it = services.iterator();
            while (it.hasNext())
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.