Search in sources :

Example 1 with RefreshScope

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

the class CasPersonDirectoryConfiguration method ldapAttributeRepositories.

@ConditionalOnMissingBean(name = "ldapAttributeRepositories")
@Bean
@RefreshScope
public List<IPersonAttributeDao> ldapAttributeRepositories() {
    final List<IPersonAttributeDao> list = new ArrayList<>();
    final PrincipalAttributesProperties attrs = casProperties.getAuthn().getAttributeRepository();
    attrs.getLdap().forEach(ldap -> {
        if (StringUtils.isNotBlank(ldap.getBaseDn()) && StringUtils.isNotBlank(ldap.getLdapUrl())) {
            final LdaptivePersonAttributeDao ldapDao = new LdaptivePersonAttributeDao();
            LOGGER.debug("Configured LDAP attribute source for [{}] and baseDn [{}]", ldap.getLdapUrl(), ldap.getBaseDn());
            ldapDao.setConnectionFactory(Beans.newLdaptivePooledConnectionFactory(ldap));
            ldapDao.setBaseDN(ldap.getBaseDn());
            LOGGER.debug("LDAP attributes are fetched from [{}] via filter [{}]", ldap.getLdapUrl(), ldap.getUserFilter());
            ldapDao.setSearchFilter(ldap.getUserFilter());
            final SearchControls constraints = new SearchControls();
            if (ldap.getAttributes() != null && !ldap.getAttributes().isEmpty()) {
                LOGGER.debug("Configured result attribute mapping for [{}] to be [{}]", ldap.getLdapUrl(), ldap.getAttributes());
                ldapDao.setResultAttributeMapping(ldap.getAttributes());
                final String[] attributes = ldap.getAttributes().keySet().toArray(new String[ldap.getAttributes().keySet().size()]);
                constraints.setReturningAttributes(attributes);
            } else {
                LOGGER.debug("Retrieving all attributes as no explicit attribute mappings are defined for [{}]", ldap.getLdapUrl());
                constraints.setReturningAttributes(null);
            }
            if (ldap.isSubtreeSearch()) {
                LOGGER.debug("Configured subtree searching for [{}]", ldap.getLdapUrl());
                constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
            }
            constraints.setDerefLinkFlag(true);
            ldapDao.setSearchControls(constraints);
            ldapDao.setOrder(ldap.getOrder());
            LOGGER.debug("Initializing LDAP attribute source for [{}]", ldap.getLdapUrl());
            ldapDao.initialize();
            list.add(ldapDao);
        }
    });
    return list;
}
Also used : IPersonAttributeDao(org.apereo.services.persondir.IPersonAttributeDao) ArrayList(java.util.ArrayList) LdaptivePersonAttributeDao(org.apereo.services.persondir.support.ldap.LdaptivePersonAttributeDao) PrincipalAttributesProperties(org.apereo.cas.configuration.model.core.authentication.PrincipalAttributesProperties) SearchControls(javax.naming.directory.SearchControls) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with RefreshScope

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

the class CasCoreAuthenticationHandlersConfiguration method acceptUsersAuthenticationHandler.

@RefreshScope
@Bean
public AuthenticationHandler acceptUsersAuthenticationHandler() {
    final AcceptAuthenticationProperties acceptAuthenticationProperties = casProperties.getAuthn().getAccept();
    final HashMap<String, String> users = new HashMap<>();
    final AcceptUsersAuthenticationHandler h = new AcceptUsersAuthenticationHandler(acceptAuthenticationProperties.getName(), servicesManager, acceptUsersPrincipalFactory(), null, users);
    h.setUsers(getParsedUsers());
    h.setPasswordEncoder(Beans.newPasswordEncoder(acceptAuthenticationProperties.getPasswordEncoder()));
    if (acceptPasswordPolicyConfiguration != null) {
        h.setPasswordPolicyConfiguration(acceptPasswordPolicyConfiguration);
    }
    h.setPrincipalNameTransformer(Beans.newPrincipalNameTransformer(acceptAuthenticationProperties.getPrincipalTransformation()));
    return h;
}
Also used : HashMap(java.util.HashMap) AcceptUsersAuthenticationHandler(org.apereo.cas.authentication.AcceptUsersAuthenticationHandler) AcceptAuthenticationProperties(org.apereo.cas.configuration.model.support.generic.AcceptAuthenticationProperties) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 3 with RefreshScope

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

the class CasCoreWebflowConfiguration method initialAuthenticationAttemptWebflowEventResolver.

@ConditionalOnMissingBean(name = "initialAuthenticationAttemptWebflowEventResolver")
@Bean
@RefreshScope
public CasDelegatingWebflowEventResolver initialAuthenticationAttemptWebflowEventResolver() {
    final InitialAuthenticationAttemptWebflowEventResolver r = new InitialAuthenticationAttemptWebflowEventResolver(authenticationSystemSupport, centralAuthenticationService, servicesManager, ticketRegistrySupport, warnCookieGenerator, authenticationRequestServiceSelectionStrategies, selector);
    r.addDelegate(adaptiveAuthenticationPolicyWebflowEventResolver());
    r.addDelegate(globalAuthenticationPolicyWebflowEventResolver());
    r.addDelegate(requestParameterAuthenticationPolicyWebflowEventResolver());
    r.addDelegate(restEndpointAuthenticationPolicyWebflowEventResolver());
    r.addDelegate(registeredServicePrincipalAttributeAuthenticationPolicyWebflowEventResolver());
    r.addDelegate(principalAttributeAuthenticationPolicyWebflowEventResolver());
    r.addDelegate(authenticationAttributeAuthenticationPolicyWebflowEventResolver());
    r.addDelegate(registeredServiceAuthenticationPolicyWebflowEventResolver());
    r.setSelectiveResolver(selectiveAuthenticationProviderWebflowEventResolver());
    return r;
}
Also used : InitialAuthenticationAttemptWebflowEventResolver(org.apereo.cas.web.flow.resolver.impl.InitialAuthenticationAttemptWebflowEventResolver) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 4 with RefreshScope

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

the class CasCoreWebConfiguration method messageSource.

@RefreshScope
@Bean
public AbstractResourceBasedMessageSource messageSource() {
    final CasReloadableMessageBundle bean = new CasReloadableMessageBundle();
    bean.setDefaultEncoding(casProperties.getMessageBundle().getEncoding());
    bean.setCacheSeconds(casProperties.getMessageBundle().getCacheSeconds());
    bean.setFallbackToSystemLocale(casProperties.getMessageBundle().isFallbackSystemLocale());
    bean.setUseCodeAsDefaultMessage(casProperties.getMessageBundle().isUseCodeMessage());
    bean.setBasenames(casProperties.getMessageBundle().getBaseNames());
    return bean;
}
Also used : CasReloadableMessageBundle(org.apereo.cas.web.view.CasReloadableMessageBundle) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) Bean(org.springframework.context.annotation.Bean)

Example 5 with RefreshScope

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

the class AuthyAuthenticationEventExecutionPlanConfiguration method authyAuthenticatorAuthenticationProvider.

@Bean
@RefreshScope
public MultifactorAuthenticationProvider authyAuthenticatorAuthenticationProvider() {
    final AuthyMultifactorAuthenticationProvider p = new AuthyMultifactorAuthenticationProvider();
    p.setBypassEvaluator(authyBypassEvaluator());
    p.setGlobalFailureMode(casProperties.getAuthn().getMfa().getGlobalFailureMode());
    p.setOrder(casProperties.getAuthn().getMfa().getAuthy().getRank());
    p.setId(casProperties.getAuthn().getMfa().getAuthy().getId());
    return p;
}
Also used : AuthyMultifactorAuthenticationProvider(org.apereo.cas.adaptors.authy.AuthyMultifactorAuthenticationProvider) 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)97 Bean (org.springframework.context.annotation.Bean)97 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)68 STSPropertiesMBean (org.apache.cxf.sts.STSPropertiesMBean)11 ServletRegistrationBean (org.springframework.boot.web.servlet.ServletRegistrationBean)11 ArrayList (java.util.ArrayList)10 Autowired (org.springframework.beans.factory.annotation.Autowired)6 CipherBean (org.cryptacular.bean.CipherBean)5 MultifactorAuthenticationProperties (org.apereo.cas.configuration.model.support.mfa.MultifactorAuthenticationProperties)4 SpnegoProperties (org.apereo.cas.configuration.model.support.spnego.SpnegoProperties)4 WsFederationProperties (org.apereo.cas.configuration.model.support.wsfed.WsFederationProperties)4 X509Properties (org.apereo.cas.configuration.model.support.x509.X509Properties)4 IPersonAttributeDao (org.apereo.services.persondir.IPersonAttributeDao)4 HashMap (java.util.HashMap)3 List (java.util.List)3 Properties (java.util.Properties)3 CasConfigurationProperties (org.apereo.cas.configuration.CasConfigurationProperties)3 ConnectionFactory (org.ldaptive.ConnectionFactory)3 EnableConfigurationProperties (org.springframework.boot.context.properties.EnableConfigurationProperties)3 FilterRegistrationBean (org.springframework.boot.web.servlet.FilterRegistrationBean)3