Package org.openid4java.discovery

Examples of org.openid4java.discovery.UrlIdentifier


    assertNull(info.getDelegateIdentifier());
  }

  public void testFindOpEndpointsForUser_throughSiteXrds_secure()
      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);
    VerificationResult verification = new VerificationResult(
        ImmutableList.of(
            CertConstantUtil.SERVER_PUB_CERT,
            CertConstantUtil.INTERMEDIATE_PUB_CERT));

    expect(fetcher.fetch(httpRequest)).andReturn(new FakeResponse(SITE_XRD));
    expect(verifier.verify(aryEq(SITE_XRD.getBytes()), (String) isNull()))
        .andReturn(verification);
    expect(validator.matches(CertConstantUtil.SERVER_PUB_CERT, "balfanz.net"))
        .andReturn(Boolean.TRUE);

    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));
    expect(verifier.verify(aryEq(USER_XRD.getBytes()), (String) isNull()))
        .andReturn(verification);
    expect(validator.matches(CertConstantUtil.SERVER_PUB_CERT,
        "http://balfanz.net/openid?id=12345"))
        .andReturn(Boolean.TRUE);

    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());
    assertTrue(info.isSecure());
    assertEquals(user.getIdentifier(), info.getClaimedIdentifier().toString());
    assertNull(info.getDelegateIdentifier());
  }
View Full Code Here


    assertNull(info.getDelegateIdentifier());
  }

  public void testFindOpEndpointsForUser_throughSiteXrds_withNextAuthority()
      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);
    VerificationResult verification = new VerificationResult(
        ImmutableList.of(
            CertConstantUtil.SERVER_PUB_CERT,
            CertConstantUtil.INTERMEDIATE_PUB_CERT));

    expect(fetcher.fetch(httpRequest))
        .andReturn(new FakeResponse(SITE_XRD_NEXT_AUTHORITY));
    expect(verifier.verify(aryEq(SITE_XRD_NEXT_AUTHORITY.getBytes()),
        (String) isNull()))
        .andReturn(verification);
    expect(validator.matches(CertConstantUtil.SERVER_PUB_CERT, "balfanz.net"))
        .andReturn(Boolean.TRUE);

    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));
    expect(verifier.verify(aryEq(USER_XRD.getBytes()), (String) isNull()))
        .andReturn(verification);
    expect(validator.matches(CertConstantUtil.SERVER_PUB_CERT,
        "www.google.com"))
        .andReturn(Boolean.TRUE);

    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());
    assertTrue(info.isSecure());
    assertEquals(user.getIdentifier(), info.getClaimedIdentifier().toString());
    assertNull(info.getDelegateIdentifier());
  }
View Full Code Here

    assertNull(info.getDelegateIdentifier());
  }

  public void testFindOpEndpointsForUser_throughSiteXrds_SignatureInHeader()
      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);
    VerificationResult verification = new VerificationResult(
        ImmutableList.of(
            CertConstantUtil.SERVER_PUB_CERT,
            CertConstantUtil.INTERMEDIATE_PUB_CERT));
    FakeResponse siteResponse = new FakeResponse(SITE_XRD);
    siteResponse.setSignature("siteSig");

    FakeResponse userResponse = new FakeResponse(USER_XRD);
    userResponse.setSignature("userSig");

    expect(fetcher.fetch(httpRequest)).andReturn(siteResponse);
    expect(verifier.verify(aryEq(SITE_XRD.getBytes()), eq("siteSig")))
        .andReturn(verification);
    expect(validator.matches(CertConstantUtil.SERVER_PUB_CERT, "balfanz.net"))
        .andReturn(Boolean.TRUE);

    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(userResponse);
    expect(verifier.verify(aryEq(USER_XRD.getBytes()), eq("userSig")))
        .andReturn(verification);
    expect(validator.matches(CertConstantUtil.SERVER_PUB_CERT,
        "http://balfanz.net/openid?id=12345"))
        .andReturn(Boolean.TRUE);

    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());
    assertTrue(info.isSecure());
    assertEquals(user.getIdentifier(), info.getClaimedIdentifier().toString());
    assertNull(info.getDelegateIdentifier());
  }
View Full Code Here

                throw new DiscoveryException( "GET failed on " +
                    identifier.toString() +
                    " Received status code: " + resp.getStatusCode(),
                    OpenIDException.DISCOVERY_HTML_GET_ERROR);

            result.setClaimed( new UrlIdentifier(resp.getFinalUri()) );

            if (resp.getBody() == null)
                throw new DiscoveryException(
                        "No HTML data read from " + identifier.toString(),
                OpenIDException.DISCOVERY_HTML_NODATA_ERROR);
View Full Code Here

                    if (!targetTypes.contains(type)) continue;
                    try {
                        result.add(new DiscoveryInformation(
                            new URL(endpoint.getUri()),
                            DiscoveryInformation.OPENID_SIGNON_TYPES.contains(type) ?
                                new UrlIdentifier(_normalizedUrl) : null,
                            DiscoveryInformation.OPENID2.equals(type) ? endpoint.getLocalId() :
                            DiscoveryInformation.OPENID1_SIGNON_TYPES.contains(type) ? endpoint.getDelegate() : null,
                            type,
                            endpoint.getTypes()));
                    } catch (MalformedURLException e) {
View Full Code Here

                throw new DiscoveryException( "GET failed on " +
                    identifier.toString() +
                    " Received status code: " + resp.getStatusCode(),
                    OpenIDException.DISCOVERY_HTML_GET_ERROR);

            result.setClaimed( new UrlIdentifier(resp.getFinalUri()) );

            if (resp.getBody() == null)
                throw new DiscoveryException(
                        "No HTML data read from " + identifier.toString(),
                OpenIDException.DISCOVERY_HTML_NODATA_ERROR);
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

                        boolean secureVerification = ((secureDiscovered != null) && (secureDiscovered.getClaimedIdentifier() != null) && secureDiscovered.isSecure());
                        if (secureVerification)
                        {
                            try
                            {
                                UrlIdentifier verifiedClaimedId = new UrlIdentifier(results.verification.getVerifiedId().getIdentifier(), true);
                                secureVerification = secureDiscovered.getClaimedIdentifier().getIdentifier().equals(verifiedClaimedId.getIdentifier());
                            }
                            catch (OpenIDException oide)
                            {
                                secureVerification = false;
                            }
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.