Java源码示例:org.jasig.cas.client.validation.TicketValidator
示例1
/**
* Constructs a Cas20ServiceTicketValidator or a Cas20ProxyTicketValidator based
* on supplied parameters.
*
* @param casProperties the ShiroCasProperties object.
* @return a fully constructed TicketValidator.
*/
public static final TicketValidator createTicketValidator(final ShiroCasProperties casProperties) {
if (Protocol.CAS1 == casProperties.getProtocol()) {
return buildCas10TicketValidator(casProperties);
} else if (Protocol.CAS2 == casProperties.getProtocol()) {
return buildCas20TicketValidator(casProperties);
} else if (Protocol.CAS3 == casProperties.getProtocol()) {
return buildCas30TicketValidator(casProperties);
} else if (Protocol.SAML11 == casProperties.getProtocol()) {
return buildSAMLTicketValidator(casProperties);
} else {
throw new CasAuthenticationException("Unable to initialize the TicketValidator for protocol: " + casProperties.getProtocol().name());
}
}
示例2
protected static TicketValidator buildCas30TicketValidator(final ShiroCasProperties casProperties) {
final boolean allowAnyProxy = casProperties.isAcceptAnyProxy();
final String allowedProxyChains = casProperties.getAllowedProxyChains();
final String casServerUrlPrefix = casProperties.getCasServerUrlPrefix();
final Class<? extends Cas20ServiceTicketValidator> ticketValidatorClass = StringUtils.hasText(casProperties.getTicketValidatorClass()) ? ReflectUtils.loadClass(casProperties.getTicketValidatorClass()) : null;
final Cas20ServiceTicketValidator validator;
if (allowAnyProxy || CommonUtils.isNotBlank(allowedProxyChains)) {
final Cas20ProxyTicketValidator v = createNewTicketValidator(ticketValidatorClass, casServerUrlPrefix, Cas30ProxyTicketValidator.class);
v.setAcceptAnyProxy(allowAnyProxy);
v.setAllowedProxyChains(CommonUtils.createProxyList(allowedProxyChains));
validator = v;
} else {
validator = createNewTicketValidator(ticketValidatorClass, casServerUrlPrefix, Cas30ServiceTicketValidator.class);
}
validator.setProxyCallbackUrl(casProperties.getProxyCallbackUrl());
validator.setProxyGrantingTicketStorage(proxyGrantingTicketStorage);
HttpURLConnectionFactory factory = new HttpsURLConnectionFactory( HttpsURLConnection.getDefaultHostnameVerifier(), getSSLConfig(casProperties));
validator.setURLConnectionFactory(factory);
validator.setProxyRetriever(new Cas20ProxyRetriever(casServerUrlPrefix, casProperties.getEncoding(), factory));
validator.setRenew(casProperties.isRenew());
validator.setEncoding(casProperties.getEncoding());
return validator;
}
示例3
protected static TicketValidator buildCas20TicketValidator(final ShiroCasProperties casProperties) {
final boolean allowAnyProxy = casProperties.isAcceptAnyProxy();
final String allowedProxyChains = casProperties.getAllowedProxyChains();
final String casServerUrlPrefix = casProperties.getCasServerUrlPrefix();
final Class<? extends Cas20ServiceTicketValidator> ticketValidatorClass = StringUtils.hasText(casProperties.getTicketValidatorClass()) ? ReflectUtils.loadClass(casProperties.getTicketValidatorClass()) : null;
final Cas20ServiceTicketValidator validator;
if (allowAnyProxy || CommonUtils.isNotBlank(allowedProxyChains)) {
final Cas20ProxyTicketValidator v = createNewTicketValidator(ticketValidatorClass, casServerUrlPrefix, Cas20ProxyTicketValidator.class);
v.setAcceptAnyProxy(allowAnyProxy);
v.setAllowedProxyChains(CommonUtils.createProxyList(allowedProxyChains));
validator = v;
} else {
validator = createNewTicketValidator(ticketValidatorClass, casServerUrlPrefix, Cas20ServiceTicketValidator.class);
}
validator.setProxyCallbackUrl(casProperties.getProxyCallbackUrl());
validator.setProxyGrantingTicketStorage(proxyGrantingTicketStorage);
HttpURLConnectionFactory factory = new HttpsURLConnectionFactory( HttpsURLConnection.getDefaultHostnameVerifier(), getSSLConfig(casProperties));
validator.setURLConnectionFactory(factory);
validator.setProxyRetriever(new Cas20ProxyRetriever(casServerUrlPrefix, casProperties.getEncoding(), factory));
validator.setRenew(casProperties.isRenew());
validator.setEncoding(casProperties.getEncoding());
return validator;
}
示例4
@Bean
public CasAuthenticationProvider casAuthenticationProvider(
TicketValidator ticketValidator,
ServiceProperties serviceProperties) {
CasAuthenticationProvider provider = new CasAuthenticationProvider();
provider.setServiceProperties(serviceProperties);
provider.setTicketValidator(ticketValidator);
provider.setUserDetailsService(
s -> new User("[email protected]", "Mellon", true, true, true, true,
AuthorityUtils.createAuthorityList("ROLE_ADMIN")));
provider.setKey("CAS_PROVIDER_LOCALHOST_8900");
return provider;
}
示例5
protected TicketValidator ensureTicketValidator() {
if (this.ticketValidator == null) {
this.ticketValidator = CasTicketValidatorUtils.createTicketValidator(casProperties);
}
return this.ticketValidator;
}
示例6
protected TicketValidator ensureTicketValidator() {
if (this.ticketValidator == null) {
this.ticketValidator = CasTicketValidatorUtils.createTicketValidator(casProperties);
}
return this.ticketValidator;
}
示例7
protected static TicketValidator buildSAMLTicketValidator(final ShiroCasProperties casProperties) {
final Saml11TicketValidator saml11TicketValidator = new Saml11TicketValidator(casProperties.getCasServerUrlPrefix());
saml11TicketValidator.setTolerance(casProperties.getTolerance());
saml11TicketValidator.setEncoding(casProperties.getEncoding());
return saml11TicketValidator;
}
示例8
protected static TicketValidator buildCas10TicketValidator(final ShiroCasProperties casProperties) {
final Cas10TicketValidator cas10TicketValidator = new Cas10TicketValidator(casProperties.getCasServerUrlPrefix());
cas10TicketValidator.setEncoding(casProperties.getEncoding());
return cas10TicketValidator;
}
示例9
@Bean
public TicketValidator ticketValidator() {
return new Cas30ServiceTicketValidator("https://localhost:8443");
}