Search in sources :

Example 1 with JsonResourceSurrogateAuthenticationService

use of org.apereo.cas.authentication.surrogate.JsonResourceSurrogateAuthenticationService in project cas by apereo.

the class SurrogateAuthenticationConfiguration method surrogateAuthenticationService.

@RefreshScope
@ConditionalOnMissingBean(name = "surrogateAuthenticationService")
@Bean
@SneakyThrows
public SurrogateAuthenticationService surrogateAuthenticationService() {
    final SurrogateAuthenticationProperties su = casProperties.getAuthn().getSurrogate();
    if (su.getJson().getLocation() != null) {
        LOGGER.debug("Using JSON resource [{}] to locate surrogate accounts", su.getJson().getLocation());
        return new JsonResourceSurrogateAuthenticationService(su.getJson().getLocation(), servicesManager);
    }
    final Map<String, Set> accounts = new LinkedHashMap<>();
    su.getSimple().getSurrogates().forEach((k, v) -> accounts.put(k, StringUtils.commaDelimitedListToSet(v)));
    LOGGER.debug("Using accounts [{}] for surrogate authentication", accounts);
    return new SimpleSurrogateAuthenticationService(accounts, servicesManager);
}
Also used : JsonResourceSurrogateAuthenticationService(org.apereo.cas.authentication.surrogate.JsonResourceSurrogateAuthenticationService) SurrogateAuthenticationProperties(org.apereo.cas.configuration.model.support.surrogate.SurrogateAuthenticationProperties) Set(java.util.Set) SimpleSurrogateAuthenticationService(org.apereo.cas.authentication.surrogate.SimpleSurrogateAuthenticationService) LinkedHashMap(java.util.LinkedHashMap) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) SneakyThrows(lombok.SneakyThrows) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

LinkedHashMap (java.util.LinkedHashMap)1 Set (java.util.Set)1 SneakyThrows (lombok.SneakyThrows)1 JsonResourceSurrogateAuthenticationService (org.apereo.cas.authentication.surrogate.JsonResourceSurrogateAuthenticationService)1 SimpleSurrogateAuthenticationService (org.apereo.cas.authentication.surrogate.SimpleSurrogateAuthenticationService)1 SurrogateAuthenticationProperties (org.apereo.cas.configuration.model.support.surrogate.SurrogateAuthenticationProperties)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)1 Bean (org.springframework.context.annotation.Bean)1