Examples of DiscoveryInformation


Examples of org.openid4java.discovery.DiscoveryInformation

    public AuthRequest authenticate(List discoveries,
                                    String returnToUrl, String realm)
            throws ConsumerException, MessageException
    {
        // try to associate with one OP in the discovered list
        DiscoveryInformation discovered = associate(discoveries);

        return authenticate(discovered, returnToUrl, realm);
    }
View Full Code Here

Examples of org.openid4java.discovery.DiscoveryInformation

                return discovered;
            }
        }

        // stateless, bare response, or the user changed the ID at the OP
        DiscoveryInformation firstServiceMatch = null;

        // perform discovery on the claim identifier in the assertion
        if(DEBUG) _log.debug(
                "Performing discovery on the ClaimedID in the assertion: "
                 + respClaimed);
        List discoveries = _discovery.discover(respClaimed);

        // find the newly discovered service endpoint that matches the assertion
        // - OP endpoint, OP-specific ID and protocol version must match
        // - prefer (first = highest priority) endpoint with an association
        if (DEBUG)
            _log.debug("Looking for a service element to match " +
                       "the ClaimedID and OP endpoint in the assertion...");
        Iterator iter = discoveries.iterator();
        while (iter.hasNext())
        {
            DiscoveryInformation service = (DiscoveryInformation) iter.next();

            if (DiscoveryInformation.OPENID2_OP.equals(service.getVersion()))
                continue;

            String opSpecific = service.hasDelegateIdentifier() ?
                    service.getDelegateIdentifier() :
                    service.getClaimedIdentifier().getIdentifier();

            if ( ! opSpecific.equals(assertId) ||
                    ! service.isVersion2() ||
                    ! service.getIdpEndpoint().toString().equals(respEndpoint) )
                continue;

            // keep the first endpoint that matches
            if (firstServiceMatch == null)
            {
                if (DEBUG) _log.debug("Found matching service: " + service);
                firstServiceMatch = service;
            }

            Association assoc = _associations.load(
                    service.getIdpEndpoint().toString(),
                    authResp.getHandle());

            // don't look further if there is an association with this endpoint
            if (assoc != null)
            {
View Full Code Here

Examples of org.openid4java.discovery.DiscoveryInformation

            // perform discovery on the user-supplied identifier
            List discoveries = manager.discover(userSuppliedString);

            // attempt to associate with the OpenID provider
            // and retrieve one service endpoint for authentication
            DiscoveryInformation discovered = manager.associate(discoveries);

            // store the discovery information in the user's session
            httpReq.getSession().setAttribute("openid-disc", discovered);

            // obtain a AuthRequest message to be sent to the OpenID provider
            AuthRequest authReq = manager.authenticate(discovered, returnToUrl);

            // Attribute Exchange example: fetching the 'email' attribute
            FetchRequest fetch = FetchRequest.createFetchRequest();
            fetch.addAttribute("email", // attribute alias
                "http://schema.openid.net/contact/email", // type URI
                true); // required
            // attach the extension to the authentication request
            authReq.addExtension(fetch);

            // example using Simple Registration to fetching the 'email' attribute
            SRegRequest sregReq = SRegRequest.createFetchRequest();
            sregReq.addAttribute("email", true);
            authReq.addExtension(sregReq);

            if (! discovered.isVersion2() )
            {
                // Option 1: GET HTTP-redirect to the OpenID Provider endpoint
                // The only method supported in OpenID 1.x
                // redirect-URL usually limited ~2048 bytes
                httpResp.sendRedirect(authReq.getDestinationUrl(true));
View Full Code Here

Examples of org.openid4java.discovery.DiscoveryInformation

            // extract the parameters from the authentication response
            // (which comes in as a HTTP request from the OpenID provider)
            ParameterList response = new ParameterList(httpReq.getParameterMap());

            // retrieve the previously stored discovery information
            DiscoveryInformation discovered = (DiscoveryInformation)httpReq.getSession().getAttribute("openid-disc");

            // extract the receiving URL from the HTTP request
            StringBuffer receivingURL = httpReq.getRequestURL();
            String queryString = httpReq.getQueryString();
            if (queryString != null && queryString.length() > 0)
View Full Code Here

Examples of org.openid4java.discovery.DiscoveryInformation

    UserInfo completeAuthentication(HttpServletRequest request)
            throws OpenIDException {
        HttpSession session = request.getSession();
        ParameterList openidResp = Step2.getParameterList(request);
        String receivingUrl = currentUrl(request);
        DiscoveryInformation discovered =
                (DiscoveryInformation) session.getAttribute("discovered");


        AuthResponseHelper authResponse =
                consumerHelper.verify(receivingUrl, openidResp, discovered);
View Full Code Here

Examples of org.openid4java.discovery.DiscoveryInformation

    if (list == null || list.isEmpty()) {
      return null;
    }

    final String contextUrl = urlProvider.get();
    final DiscoveryInformation discovered = manager.associate(list);
    final UrlEncoded retTo = new UrlEncoded(contextUrl + RETURN_URL);
    retTo.put(P_MODE, mode.name());
    if (returnToken != null && returnToken.length() > 0) {
      retTo.put(P_TOKEN, returnToken);
    }
    if (remember) {
      retTo.put(P_REMEMBER, "1");
    }
    if (discovered.hasClaimedIdentifier()) {
      retTo.put(P_CLAIMED, discovered.getClaimedIdentifier().getIdentifier());
    }
    return new State(discovered, retTo, contextUrl);
  }
View Full Code Here

Examples of org.openid4java.discovery.DiscoveryInformation

            URL realmUrl = new URL(realm);
            if (realmUrl.getAuthority().startsWith("*."))
                realm = realm.replaceFirst("\\*\\.", "www.");

            List endpoints = Discovery.rpDiscovery(realm, _yadisResolver);
            DiscoveryInformation endpoint;
            String endpointUrl;
            Iterator iter = endpoints.iterator();
            while (iter.hasNext())
            {
                endpoint = (DiscoveryInformation) iter.next();
                endpointUrl = endpoint.getOPEndpoint().toString();

                if (endpoint.getOPEndpoint().getAuthority().startsWith("*."))
                {
                    _log.warn("Wildcard not allowed in discovered " +
                              "RP endpoints; found: " + endpointUrl);
                    continue;
                }
View Full Code Here

Examples of org.openid4java.discovery.DiscoveryInformation

    {
        ArrayList htmlList = new ArrayList();

        if (htmlResult.getOP2Endpoint() != null)
        {
            DiscoveryInformation extracted = new DiscoveryInformation(
                        htmlResult.getOP2Endpoint(),
                        htmlResult.getClaimedId(),
                        htmlResult.getDelegate2(),
                        DiscoveryInformation.OPENID2);

            if (DEBUG)
                _log.debug("OpenID2-signon HTML discovery endpoint: " + extracted);

            htmlList.add(extracted);
        }

        if (htmlResult.getOP1Endpoint() != null)
        {
            DiscoveryInformation extracted = new DiscoveryInformation(
                        htmlResult.getOP1Endpoint(),
                        htmlResult.getClaimedId(),
                        htmlResult.getDelegate1(),
                        DiscoveryInformation.OPENID11);
View Full Code Here

Examples of org.openid4java.discovery.DiscoveryInformation

     *
     * @see Discovery#discover(org.openid4java.discovery.Identifier)
     */
    public DiscoveryInformation associate(List discoveries)
    {
        DiscoveryInformation discovered;
        Association assoc;

        int attemptsLeft = _maxAssocAttempts;
        Iterator itr = discoveries.iterator();
        while (itr.hasNext() && attemptsLeft > 0)
        {
            discovered = (DiscoveryInformation) itr.next();
            attemptsLeft -= associate(discovered, attemptsLeft);

            // check if an association was established
            assoc = _associations.load(discovered.getOPEndpoint().toString());

            if ( assoc != null &&
                    ! Association.FAILED_ASSOC_HANDLE.equals(assoc.getHandle()))
                return discovered;
        }

        if (discoveries.size() > 0)
        {
            // no association established, return the first service endpoint
            DiscoveryInformation d0 = (DiscoveryInformation) discoveries.get(0);
            _log.warn("Association failed; using first entry: " +
                      d0.getOPEndpoint());

            return d0;
        }
        else
        {
View Full Code Here

Examples of org.openid4java.discovery.DiscoveryInformation

    public AuthRequest authenticate(List discoveries,
                                    String returnToUrl, String realm)
            throws ConsumerException, MessageException
    {
        // try to associate with one OP in the discovered list
        DiscoveryInformation discovered = associate(discoveries);

        return authenticate(discovered, returnToUrl, realm);
    }
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.