Package org.openid4java.discovery

Examples of org.openid4java.discovery.DiscoveryInformation


      // Perform discovery on the user-supplied identifier
      List discoveries = consumerManager.discover(identifier);

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

      // Create a memento to rebuild the discovered information in a subsequent request
      DiscoveryInformationMemento memento = new DiscoveryInformationMemento();
      if (discovered.getClaimedIdentifier() != null) {
        memento.setClaimedIdentifier(discovered.getClaimedIdentifier().getIdentifier());
      }
      memento.setDelegate(discovered.getDelegateIdentifier());
      if (discovered.getOPEndpoint() != null) {
        memento.setOpEndpoint(discovered.getOPEndpoint().toString());
      }

      memento.setTypes(discovered.getTypes());
      memento.setVersion(discovered.getVersion());

      // Create a temporary User to preserve state between requests without
      // using a session (we could be in a cluster)
      User tempUser = new User(null, sessionToken);
      tempUser.setOpenIDDiscoveryInformationMemento(memento);
View Full Code Here


      public String getIdentifier() {
        return memento.getClaimedIdentifier();
      }
    };

    DiscoveryInformation discovered;
    try {
      discovered = new DiscoveryInformation(
        URI.create(memento.getOpEndpoint()).toURL(),
        identifier,
        memento.getDelegate(),
        memento.getVersion(),
        memento.getTypes()
View Full Code Here

                    }
                }
            }

            String openIdIdentity = httpRequest.getParameter("openid.identity");
            DiscoveryInformation discovered = (DiscoveryInformation) httpSession.getAttribute("discovered");

            StringBuffer receivingURL = httpRequest.getRequestURL();
            String queryString = httpRequest.getQueryString();
            if (queryString != null && queryString.length() > 0) {
                receivingURL.append("?").append(httpRequest.getQueryString());
View Full Code Here

     *
     * @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

    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

        }

        // stateless, bare response, or the user changed the ID at the OP
        _log.info("Proceeding with stateless mode / bare response verification...");

        DiscoveryInformation firstServiceMatch = null;

        // assuming openid.identity is the claimedId
        // (delegation can't work with stateless/bare resp v1 operation)
        if (DEBUG) _log.debug(
            "Performing discovery on the ClaimedID in the assertion: " + assertId);
        List discoveries = _discovery.discover(assertId);

        Iterator iter = discoveries.iterator();
        while (iter.hasNext())
        {
            DiscoveryInformation service = (DiscoveryInformation) iter.next();

            if (service.isVersion2() || // only interested in v1
                ! service.hasClaimedIdentifier() || // need a claimedId
                service.hasDelegateIdentifier() || // not allowing delegates
                ! assertId.equals(service.getClaimedIdentifier().getIdentifier()))
                continue;

            if (DEBUG) _log.debug("Found matching service: " + service);

            // keep the first endpoint that matches
            if (firstServiceMatch == null)
                firstServiceMatch = service;

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

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

                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.getOPEndpoint().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.getOPEndpoint().toString(),
                    authResp.getHandle());

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

            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

    {
        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

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

        // 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
        request.getSession().setAttribute(DISCOVERY_SESSION_KEY, discovered);

        // obtain a AuthRequest message to be sent to the OpenID provider
View Full Code Here

TOP

Related Classes of org.openid4java.discovery.DiscoveryInformation

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.