use of org.apereo.cas.configuration.model.core.services.ServiceRegistryProperties 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.apereo.cas.configuration.model.core.services.ServiceRegistryProperties in project cas by apereo.
the class CasServiceRegistryInitializationConfiguration method serviceRegistryInitializer.
@RefreshScope
@Bean
public ServiceRegistryInitializer serviceRegistryInitializer() {
final ServiceRegistryProperties props = casProperties.getServiceRegistry();
final ServiceRegistry serviceRegistryInstance = serviceRegistry.getIfAvailable();
final ServiceRegistryInitializer initializer = new ServiceRegistryInitializer(embeddedJsonServiceRegistry(), serviceRegistryInstance, servicesManager.getIfAvailable(), props.isInitFromJson());
if (props.isInitFromJson()) {
LOGGER.info("Attempting to initialize the service registry [{}] from service definition resources found at [{}]", serviceRegistryInstance.getName(), getServiceRegistryInitializerServicesDirectoryResource());
}
initializer.initServiceRegistryIfNecessary();
return initializer;
}
Aggregations