Class LDAPAuthenticator
- All Implemented Interfaces:
Authenticator<LoginCredentials,
LDAPAuthentication>
Generic LDAP authenticator.
- Since:
- 1.5
- Author:
- Jeremy Kuhn
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The user password attribute as defined by RFC2256 Section 5.36.static final String
Default search group filter.static final String
The default search user filter.static final String
Default bind DN format. -
Constructor Summary
ConstructorDescriptionLDAPAuthenticator
(LDAPClient ldapClient, String base) Creates an LDAP authenticator with the specified LDAP client and base DN.LDAPAuthenticator
(LDAPClient ldapClient, String base, String searchGroupFilter) Creates an LDAP authenticator with the specified LDAP client, base DN and search group filter.LDAPAuthenticator
(LDAPClient ldapClient, String base, String searchGroupFilter, String usernameFormat) Creates an LDAP authenticator with the specified LDAP client, base DN and search group filter.LDAPAuthenticator
(LDAPClient ldapClient, String base, String searchGroupFilter, String usernameFormat, String searchUserFilter) Creates an LDAP authenticator with the specified LDAP client, base DN and search group filter.LDAPAuthenticator
(LDAPClient ldapClient, String base, String searchGroupFilter, String usernameFormat, String searchUserFilter, String passwordAttribute) Creates an LDAP authenticator with the specified LDAP client, base DN and search group filter. -
Method Summary
Modifier and TypeMethodDescriptionauthenticate
(LoginCredentials credentials) Authenticates the specified credentials and returns an authentication.getBase()
Returns the base DN where to search for groups.Returns the name of the password attribute.Returns the search group filter.Returns the search user filter.Returns the user DN format used when binding a user or fetching a user entry.void
setTerminal
(boolean terminal) Sets whether the authenticator is terminal and should return denied authentication on failed authentication or no authentication to indicate it was not able to authenticate credentials.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.inverno.mod.security.authentication.Authenticator
failOnDenied, failOnDeniedAndAnonymous, flatMap, map, or
-
Field Details
-
DEFAULT_USER_NAME_FORMAT
Default bind DN format.- See Also:
-
DEFAULT_SEARCH_GROUP_FILTER
Default search group filter.- See Also:
-
DEFAULT_SEARCH_USER_FILTER
The default search user filter.- See Also:
-
ATTRIBUTE_PASSWORD
The user password attribute as defined by RFC2256 Section 5.36.- See Also:
-
-
Constructor Details
-
LDAPAuthenticator
Creates an LDAP authenticator with the specified LDAP client and base DN.
The resulting authenticator is terminal and returns denied authentication on failed authentication.
- Parameters:
ldapClient
- the LDAP clientbase
- the base DN where to search for groups
-
LDAPAuthenticator
Creates an LDAP authenticator with the specified LDAP client, base DN and search group filter.
The search group filter is parameterized and is formatted using the user's DN and the uid.
The resulting authenticator is terminal and returns denied authentication on failed authentication.
- Parameters:
ldapClient
- the LDAP clientbase
- the base DN where to search for groupssearchGroupFilter
- the search group filter
-
LDAPAuthenticator
public LDAPAuthenticator(LDAPClient ldapClient, String base, String searchGroupFilter, String usernameFormat) Creates an LDAP authenticator with the specified LDAP client, base DN and search group filter.
The search group filter is parameterized and is formatted using the user's DN and the uid.
The resulting authenticator is terminal and returns denied authentication on failed authentication.
- Parameters:
ldapClient
- the LDAP clientbase
- the base DN where to search for groupssearchGroupFilter
- the search group filterusernameFormat
- the user DN format
-
LDAPAuthenticator
public LDAPAuthenticator(LDAPClient ldapClient, String base, String searchGroupFilter, String usernameFormat, String searchUserFilter) Creates an LDAP authenticator with the specified LDAP client, base DN and search group filter.
The search group filter is parameterized and is formatted using the user's DN and the uid.
The resulting authenticator is terminal and returns denied authentication on failed authentication.
- Parameters:
ldapClient
- the LDAP clientbase
- the base DN where to search for groupssearchGroupFilter
- the search group filterusernameFormat
- the user DN formatsearchUserFilter
- the search user filter
-
LDAPAuthenticator
public LDAPAuthenticator(LDAPClient ldapClient, String base, String searchGroupFilter, String usernameFormat, String searchUserFilter, String passwordAttribute) Creates an LDAP authenticator with the specified LDAP client, base DN and search group filter.
The search group filter is formatted using the user's DN and the uid.
The bind name formatted using the uid.
The resulting authenticator is terminal and returns denied authentication on failed authentication.
- Parameters:
ldapClient
- the LDAP clientbase
- the base DN where to search for groupssearchGroupFilter
- the search group filterusernameFormat
- the user DN formatsearchUserFilter
- the search user filterpasswordAttribute
- the id of the password attribute
-
-
Method Details
-
setTerminal
public void setTerminal(boolean terminal) Sets whether the authenticator is terminal and should return denied authentication on failed authentication or no authentication to indicate it was not able to authenticate credentials.
- Parameters:
terminal
- true to terminate authentication, false otherwise
-
getBase
Returns the base DN where to search for groups.
- Returns:
- the base DN
-
getUsernameFormat
Returns the user DN format used when binding a user or fetching a user entry.
- Returns:
- a user DN format
-
getSearchGroupFilter
Returns the search group filter.
- Returns:
- a filter
-
getSearchUserFilter
Returns the search user filter.
- Returns:
- a filter
-
getPasswordAttribute
Returns the name of the password attribute.
- Returns:
- an attribute name
-
authenticate
Description copied from interface:Authenticator
Authenticates the specified credentials and returns an authentication.
Implementations can return an empty mono to indicate that they were unable to authenticate the credentials. This does not mean credentials are invalid, this simply mean that a particular authenticator does not manage them and therefore can's possibly determine whether they are valid. For example, when considering login credentials composed of a user and a password, an authenticator which does not manage that particular user can return an empty mono.
Implementations must return denied authentications with
AuthenticationException
when they were able to authenticate credentials which turned out to be invalid. For example, a login credentials authenticator must return a denied authentication exception when it does manage a particular username but the provided password was invalid.A denied authentication can also bre reported by throwing an
AuthenticationException
when returning an actual authentication instance is not practical.- Specified by:
authenticate
in interfaceAuthenticator<LoginCredentials,
LDAPAuthentication> - Parameters:
credentials
- the credentials to authenticate- Returns:
- a mono emitting an authentication, an error mono or an empty mono if the authenticator could not authenticate the credentials
-