Skip to content
Permalink
Browse files
[FIXED JENKINS-16396]
Added form validation to the provider URL
  • Loading branch information
kohsuke committed Jan 17, 2013
1 parent 7d3237c commit 177515e02bb0f9fa6d5dc493f753f6cd9beee0b7
@@ -30,6 +30,7 @@
import hudson.model.Hudson;
import hudson.model.User;
import hudson.security.SecurityRealm;
import hudson.util.FormValidation;
import org.acegisecurity.Authentication;
import org.acegisecurity.AuthenticationException;
import org.acegisecurity.AuthenticationManager;
@@ -42,13 +43,15 @@
import org.kohsuke.stapler.Header;
import org.kohsuke.stapler.HttpRedirect;
import org.kohsuke.stapler.HttpResponse;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;
import org.openid4java.OpenIDException;
import org.openid4java.consumer.ConsumerException;
import org.openid4java.consumer.ConsumerManager;
import org.openid4java.consumer.InMemoryConsumerAssociationStore;
import org.openid4java.consumer.InMemoryNonceVerifier;
import org.openid4java.discovery.Discovery;
import org.openid4java.discovery.DiscoveryException;
import org.openid4java.discovery.DiscoveryInformation;
import org.openid4java.util.HttpClientFactory;
import org.openid4java.util.ProxyProperties;
@@ -190,6 +193,15 @@ public String getDisplayName() {
return "OpenID SSO";
}

public FormValidation doValidate(@QueryParameter String endpoint) {
try {
new Discovery().discover(endpoint);
return FormValidation.ok("OK");
} catch (DiscoveryException e) {
return FormValidation.error(e,"Invalid provider URL: "+endpoint);
}
}

static {
TeamExtensionFactory.install();
}
@@ -3,4 +3,5 @@
<f:entry title="${%Provider URL}" field="endpoint">
<f:textbox/>
</f:entry>
<f:validateButton method="validate" title="${%Validate URL}" with="endpoint"/>
</j:jelly>

0 comments on commit 177515e

Please sign in to comment.