Package org.openid4java.discovery

Examples of org.openid4java.discovery.DiscoveryException


        try
        {
            HttpResponse resp = _httpFetcher.get(hxri);
            if (resp == null || HttpStatus.SC_OK != resp.getStatusCode())
                throw new DiscoveryException("Error retrieving HXRI: " + hxri);

            Set targetTypes = DiscoveryInformation.OPENID_OP_TYPES;

            List endpoints = XRDS_PARSER.parseXrds(resp.getBody(), targetTypes);

            List results = new ArrayList();

            Iterator endpointIter = endpoints.iterator();
            while (endpointIter.hasNext())
            {
                XrdsServiceEndpoint endpoint = (XrdsServiceEndpoint) endpointIter.next();
                Iterator typesIter = endpoint.getTypes().iterator();
                while (typesIter.hasNext()) {
                    String type = (String) typesIter.next();
                    if (!targetTypes.contains(type)) continue;
                    try {
                        results.add(new DiscoveryInformation(
                            new URL(endpoint.getUri()),
                            parseIdentifier(endpoint.getCanonicalId()),
                            DiscoveryInformation.OPENID2.equals(type) ? endpoint.getLocalId() :
                            DiscoveryInformation.OPENID1_SIGNON_TYPES.contains(type) ? endpoint.getDelegate() : null,
                            type));
                    } catch (MalformedURLException e) {
                        throw new DiscoveryException("Invalid endpoint URL discovered: " + endpoint.getUri());
                    }
                }
            }
            return results;
        }
        catch (IOException e)
        {
            throw new DiscoveryException("Error performing discovery on HXRI: " + hxri);
        }
    }
View Full Code Here


                rtn = UrlIdentifier.normalize("http://" + username)
                        .toExternalForm();
            }
            System.out.println("rtn |" + rtn + "|");
            if (rtn.equals("http://")) {
                throw new DiscoveryException("Invalid openID: "
                        + username);
            } else {
                return rtn;
            }
        } catch (DiscoveryException e) {
View Full Code Here

    @Test(expected = OpenIDConsumerException.class)
    public void discoveryExceptionRaisesOpenIDException() throws Exception {
        ConsumerManager mgr = mock(ConsumerManager.class);
        OpenID4JavaConsumer consumer = new OpenID4JavaConsumer(mgr, new NullAxFetchListFactory());
        when(mgr.discover(anyString())).thenThrow(new DiscoveryException("msg"));
        consumer.beginConsumption(new MockHttpServletRequest(), "", "", "");
    }
View Full Code Here

        OpenID4JavaConsumer consumer = new OpenID4JavaConsumer(mgr, new NullAxFetchListFactory());

        when(mgr.verify(anyString(), any(ParameterList.class), any(DiscoveryInformation.class)))
                .thenThrow(new MessageException(""))
                .thenThrow(new AssociationException(""))
                .thenThrow(new DiscoveryException(""));

        MockHttpServletRequest request = new MockHttpServletRequest();
        request.setQueryString("x=5");

        try {
View Full Code Here

      Discovery discovery = consumerManager.getDiscovery();
      @SuppressWarnings("unchecked")
      List<DiscoveryInformation> discoveries = discovery.discover(openId);

      if (discoveries == null || discoveries.size() == 0) {
        throw new DiscoveryException("discovery on " + openId.getIdentifier() +
            " failed.");
      }

      discovered = consumerManager.associate(discoveries);
    }
View Full Code Here

    // get host-meta for that host
    HostMeta hostMeta;
    try {
      hostMeta = hostMetaFetcher.getHostMeta(host);
    } catch (HostMetaException e) {
      throw new DiscoveryException("could not get host-meta for " + host, e);
    }

    // Find XRD that host-meta is pointing to. In the case of site-discovery,
    // this will point to the site's XRD.
    URI xrdUri = xrdLocationSelector.findSiteXrdUriForOp(hostMeta,
View Full Code Here

    // get host-meta for that host
    HostMeta hostMeta;
    try {
      hostMeta = hostMetaFetcher.getHostMeta(host);
    } catch (HostMetaException e) {
      throw new DiscoveryException("could not get host-meta for " + host, e);
    }

    // First, let's check whether there are link-patterns in the host-meta that
    // point directly to the user's XRD(S).
    URI xrdUri = xrdLocationSelector.findUserXrdUriForOp(hostMeta,
View Full Code Here

   * Link-element based discovery.
   */
  private List<SecureDiscoveryInformation> tryLinkElementBasedDiscoveryForUser(
      UrlIdentifier claimedId) throws DiscoveryException {
    // TODO: implement this
    throw new DiscoveryException("link-element-based discovery is not " +
        "implemented yet");
  }
View Full Code Here

   * Link-header based discovery.
   */
  private List<SecureDiscoveryInformation> tryLinkHeaderBasedDiscoveryForUser(
      UrlIdentifier claimedId) throws DiscoveryException {
    // TODO: implement this
    throw new DiscoveryException("link-header-based discovery is not " +
        "implemented yet");
  }
View Full Code Here

    IdpIdentifier host = new IdpIdentifier(claimedId.getUrl().getHost());

    // find the <Service> element with type '.../describedby'
    Service service = getServiceForType(siteXrd.getXrd(), URI_TEMPLATE_TYPE);
    if (service == null) {
      throw new DiscoveryException("could not find service of type " +
          URI_TEMPLATE_TYPE + " in XRDS at location " +
          claimedId.getIdentifier());
    }

    // is there a NextAuthority? We only trust the next authority element
    // if the document is properly signed.
    String nextAuthority = checkSecurity(siteXrd, host, null)
        ? getTagValue(service, NEXT_AUTHORITY_TAG// might still be null
        : null;                                     // must be null if unsigned

    // find the <URITemplate> tag inside the <Service> element
    String uriTemplate = getTagValue(service, URI_TEMPLATE_TAG);
    if (uriTemplate == null) {
      throw new DiscoveryException("missing " + URI_TEMPLATE_TAG + " in " +
          "service specification in XRDS at location " +
          claimedId.getIdentifier());
    }

    // now, apply the mapping:
View Full Code Here

TOP

Related Classes of org.openid4java.discovery.DiscoveryException

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.