Search in sources :

Example 1 with LdapConfiguration

use of io.micronaut.security.ldap.configuration.LdapConfiguration 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)1 Named (io.micronaut.core.naming.Named)1 ValueResolver (io.micronaut.core.value.ValueResolver)1 LdapConfiguration (io.micronaut.security.ldap.configuration.LdapConfiguration)1