Search in sources :

Example 66 with RefreshScope

use of org.springframework.cloud.context.config.annotation.RefreshScope in project cas by apereo.

the class CasRestAuthenticationConfiguration method restAuthenticationTemplate.

@Bean
@RefreshScope
@SneakyThrows
public RestTemplate restAuthenticationTemplate() {
    final URI casHost = new URI(casProperties.getServer().getName());
    final HttpHost host = new HttpHost(casHost.getHost(), casHost.getPort(), casHost.getScheme());
    final ClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactoryBasicAuth(host);
    return new RestTemplate(factory);
}
Also used : ClientHttpRequestFactory(org.springframework.http.client.ClientHttpRequestFactory) HttpComponentsClientHttpRequestFactory(org.springframework.http.client.HttpComponentsClientHttpRequestFactory) HttpHost(org.apache.http.HttpHost) RestTemplate(org.springframework.web.client.RestTemplate) URI(java.net.URI) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) SneakyThrows(lombok.SneakyThrows) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 67 with RefreshScope

use of org.springframework.cloud.context.config.annotation.RefreshScope in project cas by apereo.

the class RestServiceRegistryConfiguration method restfulServiceRegistry.

@Bean
@RefreshScope
@SneakyThrows
public ServiceRegistry restfulServiceRegistry() {
    final ServiceRegistryProperties registry = casProperties.getServiceRegistry();
    final RestTemplate restTemplate = new RestTemplate();
    final MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
    if (StringUtils.isNotBlank(registry.getRest().getBasicAuthUsername()) && StringUtils.isNotBlank(registry.getRest().getBasicAuthPassword())) {
        final String auth = registry.getRest().getBasicAuthUsername() + ":" + registry.getRest().getBasicAuthPassword();
        final byte[] encodedAuth = EncodingUtils.encodeBase64ToByteArray(auth.getBytes(StandardCharsets.UTF_8));
        final String authHeader = "Basic " + new String(encodedAuth, StandardCharsets.UTF_8);
        headers.put("Authorization", CollectionUtils.wrap(authHeader));
    }
    return new RestServiceRegistry(restTemplate, registry.getRest().getUrl(), headers);
}
Also used : LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) ServiceRegistryProperties(org.apereo.cas.configuration.model.core.services.ServiceRegistryProperties) RestTemplate(org.springframework.web.client.RestTemplate) RestServiceRegistry(org.apereo.cas.services.RestServiceRegistry) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) SneakyThrows(lombok.SneakyThrows) Bean(org.springframework.context.annotation.Bean)

Example 68 with RefreshScope

use of org.springframework.cloud.context.config.annotation.RefreshScope in project cas by apereo.

the class X509AuthenticationConfiguration method x509SubjectDNPrincipalResolver.

@Bean
@RefreshScope
public PrincipalResolver x509SubjectDNPrincipalResolver() {
    final X509Properties x509 = casProperties.getAuthn().getX509();
    final X509SubjectDNPrincipalResolver r = new X509SubjectDNPrincipalResolver(attributeRepository, x509PrincipalFactory(), x509.getPrincipal().isReturnNull(), x509.getPrincipal().getPrincipalAttribute());
    return r;
}
Also used : X509SubjectDNPrincipalResolver(org.apereo.cas.adaptors.x509.authentication.principal.X509SubjectDNPrincipalResolver) X509Properties(org.apereo.cas.configuration.model.support.x509.X509Properties) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 69 with RefreshScope

use of org.springframework.cloud.context.config.annotation.RefreshScope in project cas by apereo.

the class X509AuthenticationConfiguration method x509SerialNumberPrincipalResolver.

@Bean
@RefreshScope
public PrincipalResolver x509SerialNumberPrincipalResolver() {
    final X509Properties x509 = casProperties.getAuthn().getX509();
    final X509SerialNumberPrincipalResolver r;
    final int radix = x509.getPrincipalSNRadix();
    if (Character.MIN_RADIX <= radix && radix <= Character.MAX_RADIX) {
        if (radix == HEX) {
            r = new X509SerialNumberPrincipalResolver(attributeRepository, x509PrincipalFactory(), x509.getPrincipal().isReturnNull(), x509.getPrincipal().getPrincipalAttribute(), radix, x509.isPrincipalHexSNZeroPadding());
        } else {
            r = new X509SerialNumberPrincipalResolver(attributeRepository, x509PrincipalFactory(), x509.getPrincipal().isReturnNull(), x509.getPrincipal().getPrincipalAttribute(), radix, false);
        }
    } else {
        r = new X509SerialNumberPrincipalResolver(attributeRepository, x509PrincipalFactory(), x509.getPrincipal().isReturnNull(), x509.getPrincipal().getPrincipalAttribute());
    }
    return r;
}
Also used : X509Properties(org.apereo.cas.configuration.model.support.x509.X509Properties) X509SerialNumberPrincipalResolver(org.apereo.cas.adaptors.x509.authentication.principal.X509SerialNumberPrincipalResolver) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 70 with RefreshScope

use of org.springframework.cloud.context.config.annotation.RefreshScope in project cas by apereo.

the class X509AuthenticationConfiguration method x509SubjectAlternativeNameUPNPrincipalResolver.

@Bean
@RefreshScope
public PrincipalResolver x509SubjectAlternativeNameUPNPrincipalResolver() {
    final X509Properties x509 = casProperties.getAuthn().getX509();
    final X509SubjectAlternativeNameUPNPrincipalResolver r = new X509SubjectAlternativeNameUPNPrincipalResolver(attributeRepository, x509PrincipalFactory(), x509.getPrincipal().isReturnNull(), x509.getPrincipal().getPrincipalAttribute());
    return r;
}
Also used : X509SubjectAlternativeNameUPNPrincipalResolver(org.apereo.cas.adaptors.x509.authentication.principal.X509SubjectAlternativeNameUPNPrincipalResolver) X509Properties(org.apereo.cas.configuration.model.support.x509.X509Properties) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)167 Bean (org.springframework.context.annotation.Bean)167 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)114 Autowired (org.springframework.beans.factory.annotation.Autowired)20 ArrayList (java.util.ArrayList)15 STSPropertiesMBean (org.apache.cxf.sts.STSPropertiesMBean)11 ServletRegistrationBean (org.springframework.boot.web.servlet.ServletRegistrationBean)11 CasConfigurationProperties (org.apereo.cas.configuration.CasConfigurationProperties)8 EncryptionJwtSigningJwtCryptographyProperties (org.apereo.cas.configuration.model.core.util.EncryptionJwtSigningJwtCryptographyProperties)8 EnableConfigurationProperties (org.springframework.boot.context.properties.EnableConfigurationProperties)8 List (java.util.List)7 SneakyThrows (lombok.SneakyThrows)7 IPersonAttributeDao (org.apereo.services.persondir.IPersonAttributeDao)7 FilterRegistrationBean (org.springframework.boot.web.servlet.FilterRegistrationBean)7 ConnectionFactory (org.ldaptive.ConnectionFactory)6 Resource (org.springframework.core.io.Resource)5 Properties (java.util.Properties)4 GrouperPrincipalAttributesProperties (org.apereo.cas.configuration.model.core.authentication.GrouperPrincipalAttributesProperties)4 PrincipalAttributesProperties (org.apereo.cas.configuration.model.core.authentication.PrincipalAttributesProperties)4 IgniteProperties (org.apereo.cas.configuration.model.support.ignite.IgniteProperties)4