Package org.openid4java.discovery

Examples of org.openid4java.discovery.UrlIdentifier


    if (d2 == null) {
      return false;
    }

    UrlIdentifier claimedIdWithoutFragment;
    try {
      claimedIdWithoutFragment = new UrlIdentifier(
          verification.getVerifiedId().getIdentifier(), true);
    } catch (DiscoveryException e) {
      return false;
    }

    if (d2.getClaimedIdentifier() == null) {
      return false;
    }

    if (!d2.getClaimedIdentifier().getIdentifier().equals(
        claimedIdWithoutFragment.getIdentifier())) {
      return false;
    }

    return d2.isSecure();
  }
View Full Code Here


      IdpIdentifier site = (IdpIdentifier) identifier;
      return siteFallbackDiscoverer.get(site);

    } else if (identifier instanceof UrlIdentifier) {

      UrlIdentifier url = (UrlIdentifier)identifier;
      return userFallbackDiscoverer.get(url);

    } else {

      // for all other types of identifiers, use old-style discovery
View Full Code Here

  }

  public void testFindXrdUriForOp_forUser() throws Exception {

    String mimeType = "application/xrds+xml";
    UrlIdentifier user = new UrlIdentifier("http://host.com/bob");

    // first, what if it's not in there at all
    HostMeta hostMeta = getHostMeta(
        "Link-Pattern: <http://foo.com/bar>; rel=\"describedby\""// missing mime-type
        "Link-Pattern: <http://foo.com/bar2>; rel=http://specs.openid.net/auth/2.0/server");
View Full Code Here

    super.setUp();
  }

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

    assertSame(infos, result);
  }

  public void testTryHostMetaBasedClaimedIdDiscovery() throws Exception {

    UrlIdentifier user = new UrlIdentifier("http://bob.com/myid");
    List<SecureDiscoveryInformation> infos = Lists.newArrayList();

    HostMeta hostMeta = getHostMeta(
        "Link: <http://foo.com/bar1>; rel=foobar; type=application/xrds+xml",
        "Link-Pattern: <http://foo.com/bar2?uri={%uri}>; " +
            "rel=\"http://specs.foo.net/auth/2.5/xrd-op describedby\"; " +
            "type=application/xrds+xml");

    expect(xrdResolver.getDiscoveryDocumentType())
        .andStubReturn("application/xrds+xml");
    expect(hostMetafetcher.getHostMeta("bob.com"))
        .andReturn(hostMeta);
    expect(xrdResolver.findOpEndpointsForUser(user,
        URI.create("http://foo.com/bar2?uri=" + URLEncoder.encode(user.getIdentifier(), "UTF-8"))))
        .andReturn(infos);

    control.replay();

    List<SecureDiscoveryInformation> result = discovery.tryHostMetaBasedDiscoveryForUser(user);
View Full Code Here

    assertSame(infos, result);
  }

  public void testTryHostMetaBasedClaimedIdDiscovery_siteXrd() throws Exception {

    UrlIdentifier user = new UrlIdentifier("http://bob.com/myid");
    List<SecureDiscoveryInformation> infos = Lists.newArrayList();

    HostMeta hostMeta = getHostMeta(
        "Link: <http://foo.com/bar1>; rel=foobar; type=application/xrds+xml",
        "Link: <http://foo.com/bar2>; rel=\"http://specs.foo.net/auth/2.5/xrd-op describedby\"; type=application/xrds+xml");
View Full Code Here

    assertSame(infos, result);
  }

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

        info.getOPEndpoint().toString());
    assertFalse(info.isSecure());
  }

  public void testFindOpEndpointsForUser_direct() throws Exception {
    UrlIdentifier user = new UrlIdentifier("http://balfanz.net/openid?id=12345");
    URI siteXrdsUri = URI.create("http://example.com/xrds");

    FetchRequest httpRequest = FetchRequest.createGetRequest(siteXrdsUri);

    expect(verifier.verify(isA(byte[].class), (String) isNull()))
        .andStubThrow(new XmlSimpleSignException("no signature"));
    expect(fetcher.fetch(httpRequest)).andReturn(new FakeResponse(USER_XRD));

    control.replay();
    List<SecureDiscoveryInformation> result =
        xrdResolver.findOpEndpointsForUser(user, siteXrdsUri);
    control.verify();

    assertEquals(1, result.size());
    SecureDiscoveryInformation info = result.get(0);
    assertEquals("https://www.google.com/a/balfanz.net/o8/ud?be=o8",
        info.getOPEndpoint().toString());
    assertFalse(info.isSecure());
    assertEquals(user.getIdentifier(), info.getClaimedIdentifier().toString());
    assertNull(info.getDelegateIdentifier());
  }
View Full Code Here

    assertEquals(user.getIdentifier(), info.getClaimedIdentifier().toString());
    assertNull(info.getDelegateIdentifier());
  }

  public void testFindOpEndpointsForUser_directWithLocalId() throws Exception {
    UrlIdentifier user = new UrlIdentifier("http://balfanz.net/openid?id=12345");
    URI siteXrdsUri = URI.create("http://example.com/xrds");

    FetchRequest httpRequest = FetchRequest.createGetRequest(siteXrdsUri);

    expect(verifier.verify(isA(byte[].class), (String) isNull()))
        .andStubThrow(new XmlSimpleSignException("no signature"));
    expect(fetcher.fetch(httpRequest)).andReturn(new FakeResponse(USER_XRD_WITH_LOCAL_ID));

    control.replay();
    List<SecureDiscoveryInformation> result =
        xrdResolver.findOpEndpointsForUser(user, siteXrdsUri);
    control.verify();

    assertEquals(1, result.size());
    SecureDiscoveryInformation info = result.get(0);
    assertEquals("https://www.google.com/a/balfanz.net/o8/ud?be=o8",
        info.getOPEndpoint().toString());
    assertFalse(info.isSecure());
    assertEquals(user.getIdentifier(), info.getClaimedIdentifier().toString());
    assertEquals("12345", info.getDelegateIdentifier());
  }
View Full Code Here

    assertEquals(user.getIdentifier(), info.getClaimedIdentifier().toString());
    assertEquals("12345", info.getDelegateIdentifier());
  }

  public void testFindOpEndpointsForUser_throughSiteXrds() throws Exception {
    UrlIdentifier user = new UrlIdentifier("http://balfanz.net/openid?id=12345");
    URI siteXrdsUri = URI.create("http://example.com/xrds");

    FetchRequest httpRequest = FetchRequest.createGetRequest(siteXrdsUri);

    expect(verifier.verify(isA(byte[].class), (String) isNull()))
        .andStubThrow(new XmlSimpleSignException("no signature"));
    expect(fetcher.fetch(httpRequest)).andReturn(new FakeResponse(SITE_XRD));

    String userXrdsUri = "https://www.google.com/accounts/o8/user-xrds?uri="
        + URLEncoder.encode(user.getIdentifier(), "UTF-8");

    FetchRequest nextRequest = FetchRequest.createGetRequest(URI.create(userXrdsUri));

    expect(fetcher.fetch(nextRequest)).andReturn(new FakeResponse(USER_XRD));

    control.replay();
    List<SecureDiscoveryInformation> result =
        xrdResolver.findOpEndpointsForUserThroughSiteXrd(user, siteXrdsUri);
    control.verify();

    assertEquals(1, result.size());
    SecureDiscoveryInformation info = result.get(0);
    assertEquals("https://www.google.com/a/balfanz.net/o8/ud?be=o8",
        info.getOPEndpoint().toString());
    assertFalse(info.isSecure());
    assertEquals(user.getIdentifier(), info.getClaimedIdentifier().toString());
    assertNull(info.getDelegateIdentifier());
  }
View Full Code Here

TOP

Related Classes of org.openid4java.discovery.UrlIdentifier

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.