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());
}