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);
}
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);
}
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;
}
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;
}
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;
}
Aggregations