boolean isSecure = checkSecurity(xrd, id, authority);
List<Service> services = getServicesForType(xrd.getXrd(), version);
if (services == null) {
throw new DiscoveryException("could not find <Service> of type " +
version + " in XRDS for " + xrd.getSource());
}
List<SecureDiscoveryInformation> result =
Lists.newArrayListWithCapacity(services.size());
for (Service service : services) {
try {
if (version.equals(DiscoveryInformation.OPENID2)) {
// look for LocalID and use claimedID, if given.
result.add(createDiscoveryInfoForSignon(service, id, isSecure));
} else if (version.equals(DiscoveryInformation.OPENID2_OP)) {
// for site discovery, just return the URI
result.add(createDiscoveryInfoForServer(service, isSecure));
} else {
throw new DiscoveryException("unkown OpenID version : " + version);
}
} catch (MalformedURLException e) {
logger.log(Level.WARNING, "found malformed URL in discovery document " +
"at " + xrd.getSource(), e);
continue;