Examples of DiscoveryInformation


Examples of org.openid4java.discovery.DiscoveryInformation

     * @throws RelyingPartyException
     */
    public Message verifyOpenID(HttpServletRequest request, ParameterList openidResp)
            throws OpenIDException, IdentityException {

        DiscoveryInformation discovered = null;
        String receivingURL = null;
        String queryString = null;
        VerificationResult verification = null;
        Identifier verified = null;
        HttpSession session = null;
View Full Code Here

Examples of org.openid4java.discovery.DiscoveryInformation

   * Generates a new auth request, which can be queried for a redirect-URL
   * to send the user agent to (and which will point to he OP).
   */
  public AuthRequest generateRequest() throws DiscoveryException,
      MessageException, ConsumerException {
    DiscoveryInformation discovered = getDiscoveryInformation();

    // this a standard OpenID request
    AuthRequest authReq =
      consumerManager.authenticate(discovered, returnToUrl, null);
    if (axFetchRequest != null) {
View Full Code Here

Examples of org.openid4java.discovery.DiscoveryInformation

  public void testCreation() throws Exception {
    URL url = new URL("http://whatever.com");
    UrlIdentifier identifier = new UrlIdentifier("http://identifier.com");
    Set types = Collections.singleton("Type");
    DiscoveryInformation information = new DiscoveryInformation(
        url, identifier, "delegate", "version", types);

    SecureDiscoveryInformation secureInformation =
        new SecureDiscoveryInformation(information);
View Full Code Here

Examples of org.openid4java.discovery.DiscoveryInformation

  public void testFallbackDiscovery_oldStyle() throws Exception {
    IdpIdentifier host = new IdpIdentifier("host");
    UrlIdentifier legacy = new UrlIdentifier("http://legacy.com");

    List<DiscoveryInformation> infos = new ArrayList<DiscoveryInformation>();
    infos.add(new DiscoveryInformation(new URL("http://foo.com")));

    FallbackDiscovery<Identifier> mockFallback =
        control.createMock(ForwardingFallbackDiscoverer.class);

    ForwardingFallbackDiscoverer fallback =
View Full Code Here

Examples of org.openid4java.discovery.DiscoveryInformation

      throws ServletException, IOException {

    HttpSession session = req.getSession();
    ParameterList openidResp = Step2.getParameterList(req);
    String receivingUrl = Step2.getUrlWithQueryString(req);
    DiscoveryInformation discovered =
      (DiscoveryInformation) session.getAttribute("discovered");

    String requestToken = NO_TOKEN;

    // Try to get the OpenId, AX, and OAuth values from the auth response
View Full Code Here

Examples of org.openid4java.discovery.DiscoveryInformation

            List<?> discoveries = null;
            discoveries = discovery.discover(target);
            for (Object o : discoveries) {
                if (o instanceof DiscoveryInformation) {
                    DiscoveryInformation di = (DiscoveryInformation) o;
                    log.info("Found - " + di.getOPEndpoint());
                    target = di.getOPEndpoint().toString();
                }
            }

            ConsumerManager manager = getManager(target);
            // try {
            // discoveries = manager.discover(target);
            // } catch (YadisException e) {
            // log.info("Could not connect in time!!!!!!!!!!!!!!!!!!!!!!");
            // return new
            // StringRepresentation("Could not connect to Identity Server in time.",MediaType.TEXT_HTML);
            // }

            // 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
            // getContext().getAttributes().put("openid-disc", discovered);
            String sessionId = String.valueOf(System
                    .identityHashCode(discovered));
            session.put(sessionId, discovered);

            getResponse().getCookieSettings().add(
                    new CookieSetting(DESCRIPTOR_COOKIE, sessionId));
            log.info("Setting DESCRIPTOR COOKIE");

            // obtain a AuthRequest message to be sent to the OpenID provider
            AuthRequest authReq = manager.authenticate(discovered,
                    returnToUrl.toString()); // TODO maybe add TIMESTAMP?
            // Domain wide realm add meta to main page
            // http://localhost:8080/oauth/xrds?returnTo=http://localhost:8080/oauth/openid_login\r\n
            // log.info("OpenID - REALM = " +
            // getReference().getHostIdentifier());
            // authReq.setRealm(getReference().getHostIdentifier().toString());
            log.info("OpenID - REALM = " + getReference().getBaseRef());
            authReq.setRealm(getReference().getBaseRef().toString());

            // Attribute Exchange - getting optional and required
            FetchRequest fetch = null;
            String[] optional = params.getValuesArray("ax_optional", true);
            for (String o : optional) {
                if (!ax.containsKey(o)) {
                    log.warning("Not supported AX extension : " + o);
                    continue;
                }
                if (fetch == null)
                    fetch = FetchRequest.createFetchRequest();
                fetch.addAttribute(o, ax.get(o), false);
            }

            String[] required = params.getValuesArray("ax_required", true);
            for (String r : required) {
                if (!ax.containsKey(r)) {
                    log.warning("Not supported AX extension : " + r);
                    continue;
                }
                if (fetch == null)
                    fetch = FetchRequest.createFetchRequest();
                fetch.addAttribute(r, ax.get(r), true);
            }

            if (fetch != null) {
                authReq.addExtension(fetch);
            }

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

Examples of org.openid4java.discovery.DiscoveryInformation

                    log.info("Cookie: " + setting.getName()
                            + setting.getFirst());
                }
            }

            DiscoveryInformation discovered = (DiscoveryInformation) session
                    .get(openidDisc); // TODO cleanup

            log.info("discovered = " + discovered);

            // extract the receiving URL from the HTTP request

            log.info("getOriginalRef = " + getOriginalRef());

            // verify the response; ConsumerManager needs to be the same
            // (static) instance used to place the authentication request
            // StringBuilder receivingURL = new StringBuilder();
            // receivingURL.append(getOriginalRef().getScheme(true));
            // receivingURL.append(':');
            // receivingURL.append(getOriginalRef().getSchemeSpecificPart(true));
            // log.info("receivingURL = "+receivingURL);

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

Examples of org.openid4java.discovery.DiscoveryInformation

        List<?> discoveries = null;
        discoveries = discovery.discover(target);
        for (Object o : discoveries) {
            if (o instanceof DiscoveryInformation) {
                DiscoveryInformation di = (DiscoveryInformation) o;
                l.info("Found - " + di.getOPEndpoint());
                target = di.getOPEndpoint().toString();
            }
        }

        ConsumerManager manager = getManager(target);
        DiscoveryInformation discovered = manager.associate(discoveries);

        // store the discovery information in the user's session
        // getContext().getAttributes().put("openid-disc", discovered);
        String sessionId = String.valueOf(System.identityHashCode(discovered));
        session.put(sessionId, discovered);

        response.getCookieSettings().add(
                new CookieSetting(OpenIdConsumer.DESCRIPTOR_COOKIE, sessionId));
        l.info("Setting DESCRIPTOR COOKIE");

        // obtain a AuthRequest message to be sent to the OpenID provider
        AuthRequest authReq = manager.authenticate(discovered, redir); // TODO
                                                                       // maybe
                                                                       // add
                                                                       // TIMESTAMP?;
        String ref = request.getResourceRef().getBaseRef().toString();
        l.info("OpenID - REALM = " + ref);
        authReq.setRealm(ref);

        // Attribute Exchange - getting optional and required
        FetchRequest fetch = null;
        // String[] optional = params.getValuesArray("ax_optional", true);
        for (AX o : this.optionalAttributes) {
            if (fetch == null)
                fetch = FetchRequest.createFetchRequest();
            fetch.addAttribute(o.toString(), ax.get(o), false);
        }

        // String[] required = params.getValuesArray("ax_required", true);
        for (AX r : this.requiredAttributes) {
            if (fetch == null)
                fetch = FetchRequest.createFetchRequest();
            fetch.addAttribute(r.toString(), ax.get(r), true);
        }

        if (fetch != null) {
            authReq.addExtension(fetch);
        }

        if (!discovered.isVersion2()) {
            l.info("OpenId - Http Redirect");
            response.redirectTemporary(authReq.getDestinationUrl(true));

        } else {
            l.info("OpenId - HTML Form Redirect");
View Full Code Here

Examples of org.openid4java.discovery.DiscoveryInformation

                for (Cookie setting : request.getCookies()) {
                    l.info("Cookie: " + setting.getName() + setting.getFirst());
                }
            }

            DiscoveryInformation discovered = (DiscoveryInformation) session
                    .get(openidDisc); // TODO cleanup

            l.info("discovered = " + discovered);

            // extract the receiving URL from the HTTP request

            l.info("getOriginalRef = " + request.getOriginalRef());

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

            VerificationResult verification = manager.verify(redir, response,
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.getIdpEndpoint().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.getIdpEndpoint());

            return d0;
        }
        else
        {
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.