Search in sources :

Example 1 with HttpURLConnectionFactory

use of org.jasig.cas.client.ssl.HttpURLConnectionFactory in project cas by apereo.

the class CasCoreTicketsConfiguration method casClientTicketValidator.

@ConditionalOnMissingBean(name = "casClientTicketValidator")
@Bean
public AbstractUrlBasedTicketValidator casClientTicketValidator() {
    final String prefix = StringUtils.defaultString(casProperties.getClient().getPrefix(), casProperties.getServer().getPrefix());
    final Cas30ServiceTicketValidator validator = new Cas30ServiceTicketValidator(prefix);
    final HttpURLConnectionFactory factory = new HttpURLConnectionFactory() {

        private static final long serialVersionUID = 3692658214483917813L;

        @Override
        public HttpURLConnection buildHttpURLConnection(final URLConnection conn) {
            if (conn instanceof HttpsURLConnection) {
                final HttpsURLConnection httpsConnection = (HttpsURLConnection) conn;
                httpsConnection.setSSLSocketFactory(sslContext.getSocketFactory());
                httpsConnection.setHostnameVerifier(hostnameVerifier);
            }
            return (HttpURLConnection) conn;
        }
    };
    validator.setURLConnectionFactory(factory);
    return validator;
}
Also used : Cas30ServiceTicketValidator(org.jasig.cas.client.validation.Cas30ServiceTicketValidator) HttpURLConnection(java.net.HttpURLConnection) HttpURLConnection(java.net.HttpURLConnection) URLConnection(java.net.URLConnection) HttpsURLConnection(javax.net.ssl.HttpsURLConnection) HttpsURLConnection(javax.net.ssl.HttpsURLConnection) HttpURLConnectionFactory(org.jasig.cas.client.ssl.HttpURLConnectionFactory) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

HttpURLConnection (java.net.HttpURLConnection)1 URLConnection (java.net.URLConnection)1 HttpsURLConnection (javax.net.ssl.HttpsURLConnection)1 HttpURLConnectionFactory (org.jasig.cas.client.ssl.HttpURLConnectionFactory)1 Cas30ServiceTicketValidator (org.jasig.cas.client.validation.Cas30ServiceTicketValidator)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 Bean (org.springframework.context.annotation.Bean)1