Skip to content

Commit

Permalink
Using an improved version in SSO mode as well.
Browse files Browse the repository at this point in the history
This would help diagnose issues like JENKINS-14760.
  • Loading branch information
kohsuke committed Nov 27, 2013
1 parent 6248511 commit ca6531e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
14 changes: 1 addition & 13 deletions src/main/java/hudson/plugins/openid/OpenIdLoginService.java
Expand Up @@ -61,19 +61,7 @@ public OpenIdLoginService() throws ConsumerException {
manager = new ConsumerManager();
manager.setAssociations(new InMemoryConsumerAssociationStore());
manager.setNonceVerifier(new InMemoryNonceVerifier(5000));
manager.getDiscovery().setYadisResolver(new YadisResolver() {
/**
* Improve the error diagnosis by reporting which URL had failed. openid4java as of 0.9.4 does not do that.
*/
@Override
public YadisResult discover(String url, int maxRedirects, HttpCache cache, Set serviceTypes) throws DiscoveryException {
try {
return super.discover(url,maxRedirects,cache,serviceTypes);
} catch (DiscoveryException e) {
throw new DiscoveryException("Failed to discover XRDS document from "+url, e.getErrorCode(), e);
}
}
});
manager.getDiscovery().setYadisResolver(new YadisResolver2());
}

@Override
Expand Down
Expand Up @@ -117,7 +117,9 @@ private DiscoveryInformation getDiscoveredEndpoint() throws IOException, OpenIDE
if (discoveredEndpoint==null) {
// pretend that the endpoint URL is by itself an OpenID and find out an endpoint
// if that fails, assume that the endpoint URL is the real endpoint URL.
List r = new Discovery().discover(endpoint);
Discovery d = new Discovery();
d.setYadisResolver(new YadisResolver2());
List r = d.discover(endpoint);
if (r == null || r.isEmpty()) {
discoveredEndpoint = new DiscoveryInformation(new URL(endpoint));
} else {
Expand Down
26 changes: 26 additions & 0 deletions src/main/java/hudson/plugins/openid/YadisResolver2.java
@@ -0,0 +1,26 @@
package hudson.plugins.openid;

import org.openid4java.discovery.DiscoveryException;
import org.openid4java.discovery.yadis.YadisResolver;
import org.openid4java.discovery.yadis.YadisResult;
import org.openid4java.util.HttpCache;

import java.util.Set;

/**
* {@link YadisResolver} with better error diagnosis.
* @author Kohsuke Kawaguchi
*/
class YadisResolver2 extends YadisResolver {
/**
* Improve the error diagnosis by reporting which URL had failed. openid4java as of 0.9.4 does not do that.
*/
@Override
public YadisResult discover(String url, int maxRedirects, HttpCache cache, Set serviceTypes) throws DiscoveryException {
try {
return super.discover(url,maxRedirects,cache,serviceTypes);
} catch (DiscoveryException e) {
throw new DiscoveryException("Failed to discover XRDS document from "+url, e.getErrorCode(), e);
}
}
}

0 comments on commit ca6531e

Please sign in to comment.