Class LdapAuthenticationProvider
java.lang.Object
com.codename1.backend.security.ldap.LdapAuthenticationProvider
- All Implemented Interfaces:
AuthenticationProvider
Signs users in against an LDAP directory, for form login and HTTP Basic
alike: an LdapAuthenticator checks the password, an
LdapAuthoritiesPopulator answers the roles.
LdapContextSource directory = new LdapContextSource("ldaps://ldap.corp.example/dc=corp,dc=example");
BindAuthenticator bind = new BindAuthenticator(directory);
bind.setUserDnPatterns("uid={0},ou=people");
http.authenticationProvider(new LdapAuthenticationProvider(bind,
new DefaultLdapAuthoritiesPopulator(directory, "ou=groups")))
.formLogin(Customizer.withDefaults());
or from the configuration, fromConfig(Config). The principal of the
authentication is an LdapUserDetails. For Active Directory see
ActiveDirectoryLdapAuthenticationProvider.
-
Constructor Summary
ConstructorsConstructorDescriptionLdapAuthenticationProvider(LdapAuthenticator authenticator) LdapAuthenticationProvider(LdapAuthenticator authenticator, LdapAuthoritiesPopulator authoritiesPopulator) -
Method Summary
Modifier and TypeMethodDescriptionauthenticate(Authentication authentication) The accepted authentication, or null when this provider cannot decide and the next one should be asked.static AuthenticationProviderfromConfig(Config config) The provider the configuration describes, or null whencn1.ldap.urlsis not set.booleanWhether this provider checks tokens of this class.
-
Constructor Details
-
LdapAuthenticationProvider
-
LdapAuthenticationProvider
public LdapAuthenticationProvider(LdapAuthenticator authenticator, LdapAuthoritiesPopulator authoritiesPopulator)
-
-
Method Details
-
fromConfig
The provider the configuration describes, or null when
cn1.ldap.urlsis not set. BesidesLdapContextSource's settings:cn1.ldap.user-dn-patterns:uid={0},ou=people, several separated by;cn1.ldap.user-search-baseandcn1.ldap.user-search-filter((uid={0})by default), used when no DN pattern is setcn1.ldap.group-search-base: where the groups are; none, no roles butROLE_USERcn1.ldap.group-search-filter:(member={0})by defaultcn1.ldap.group-role-attribute:cnby default
- Throws:
IOException
-
authenticate
Description copied from interface:AuthenticationProviderThe accepted authentication, or null when this provider cannot decide and the next one should be asked.
Throws
AuthenticationException: when the token is refused
- Specified by:
authenticatein interfaceAuthenticationProvider
-
supports
Description copied from interface:AuthenticationProviderWhether this provider checks tokens of this class.- Specified by:
supportsin interfaceAuthenticationProvider
-