org.jasig.cas.client.validation.TicketValidator Java Examples

The following examples show how to use org.jasig.cas.client.validation.TicketValidator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CasTicketValidatorUtils.java    From shiro-cas-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
/**
 * 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());
       }
}
 
Example #2
Source File: CasTicketValidatorUtils.java    From shiro-cas-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
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;
      
  }
 
Example #3
Source File: CasTicketValidatorUtils.java    From shiro-cas-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
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;
  }
 
Example #4
Source File: CasSecuredApplication.java    From tutorials with MIT License 5 votes vote down vote up
@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;
}
 
Example #5
Source File: CasStatefulAuthorizingRealm.java    From shiro-cas-spring-boot-starter with Apache License 2.0 4 votes vote down vote up
protected TicketValidator ensureTicketValidator() {
    if (this.ticketValidator == null) {
        this.ticketValidator = CasTicketValidatorUtils.createTicketValidator(casProperties);
    }
    return this.ticketValidator;
}
 
Example #6
Source File: CasStatelessAuthorizingRealm.java    From shiro-cas-spring-boot-starter with Apache License 2.0 4 votes vote down vote up
protected TicketValidator ensureTicketValidator() {
    if (this.ticketValidator == null) {
    	this.ticketValidator = CasTicketValidatorUtils.createTicketValidator(casProperties);
    }
    return this.ticketValidator;
}
 
Example #7
Source File: CasTicketValidatorUtils.java    From shiro-cas-spring-boot-starter with Apache License 2.0 4 votes vote down vote up
protected static TicketValidator buildSAMLTicketValidator(final ShiroCasProperties casProperties) {
    final Saml11TicketValidator saml11TicketValidator = new Saml11TicketValidator(casProperties.getCasServerUrlPrefix());
    saml11TicketValidator.setTolerance(casProperties.getTolerance());
    saml11TicketValidator.setEncoding(casProperties.getEncoding());
    return saml11TicketValidator;
}
 
Example #8
Source File: CasTicketValidatorUtils.java    From shiro-cas-spring-boot-starter with Apache License 2.0 4 votes vote down vote up
protected static TicketValidator buildCas10TicketValidator(final ShiroCasProperties casProperties) {
    final Cas10TicketValidator cas10TicketValidator = new Cas10TicketValidator(casProperties.getCasServerUrlPrefix());
    cas10TicketValidator.setEncoding(casProperties.getEncoding());
    return cas10TicketValidator;
}
 
Example #9
Source File: CasSecuredApplication.java    From tutorials with MIT License 4 votes vote down vote up
@Bean
public TicketValidator ticketValidator() {
    return new Cas30ServiceTicketValidator("https://localhost:8443");
}