Search in sources :

Example 6 with ValueResolver

use of io.micronaut.core.value.ValueResolver in project micronaut-security by micronaut-projects.

the class LdapEnabledCondition method matches.

@Override
public boolean matches(ConditionContext context) {
    AnnotationMetadataProvider component = context.getComponent();
    if (component instanceof ValueResolver) {
        Optional<String> optional = ((ValueResolver) component).get(Named.class.getName(), String.class);
        if (optional.isPresent()) {
            String name = optional.get();
            LdapConfiguration ldapConfiguration = context.getBean(LdapConfiguration.class, Qualifiers.byName(name));
            return ldapConfiguration.isEnabled();
        }
    }
    return true;
}
Also used : Named(io.micronaut.core.naming.Named) ValueResolver(io.micronaut.core.value.ValueResolver) LdapConfiguration(io.micronaut.security.ldap.configuration.LdapConfiguration) AnnotationMetadataProvider(io.micronaut.core.annotation.AnnotationMetadataProvider)

Aggregations

AnnotationMetadataProvider (io.micronaut.core.annotation.AnnotationMetadataProvider)6 Named (io.micronaut.core.naming.Named)6 ValueResolver (io.micronaut.core.value.ValueResolver)6 ApplicationContext (io.micronaut.context.ApplicationContext)5 BeanContext (io.micronaut.context.BeanContext)5 OauthClientConfiguration (io.micronaut.security.oauth2.configuration.OauthClientConfiguration)5 LdapConfiguration (io.micronaut.security.ldap.configuration.LdapConfiguration)1 OpenIdProviderMetadata (io.micronaut.security.oauth2.client.OpenIdProviderMetadata)1 ClientCredentialsConfiguration (io.micronaut.security.oauth2.client.clientcredentials.ClientCredentialsConfiguration)1 OpenIdClientConfiguration (io.micronaut.security.oauth2.configuration.OpenIdClientConfiguration)1 AuthorizationEndpointConfiguration (io.micronaut.security.oauth2.configuration.endpoints.AuthorizationEndpointConfiguration)1 DefaultOpenIdAuthenticationMapper (io.micronaut.security.oauth2.endpoint.token.response.DefaultOpenIdAuthenticationMapper)1 OpenIdAuthenticationMapper (io.micronaut.security.oauth2.endpoint.token.response.OpenIdAuthenticationMapper)1 OpenIdTokenResponseValidator (io.micronaut.security.oauth2.endpoint.token.response.validation.OpenIdTokenResponseValidator)1