Class ActiveDirectoryAuthenticator
- All Implemented Interfaces:
Authenticator<LoginCredentials,
LDAPAuthentication>
Specialized LDAP authenticator that uses Active Directory semantic.
The domain
is appended to the username before authentication unless it already provides the domain. If not specified, it is assumed that the username provides the domain.
- Since:
- 1.5
- Author:
- Jeremy Kuhn
-
Field Summary
-
Constructor Summary
ConstructorDescriptionActiveDirectoryAuthenticator
(LDAPClient ldapClient, String domain) Creates an Active Directory authenticator with the specified LDAP client and domain.ActiveDirectoryAuthenticator
(LDAPClient ldapClient, String domain, String base) Creates an Active Directory authenticator with the specified LDAP client, domain and base DN.ActiveDirectoryAuthenticator
(LDAPClient ldapClient, String domain, String base, String searchUserFilter) Creates an Active Directory authenticator with the specified LDAP client, domain, base DN and search user filter. -
Method Summary
Modifier and TypeMethodDescriptionauthenticate
(LoginCredentials credentials) Authenticates the specified credentials and returns an authentication.protected String
boundDNToBaseDN
(String boundDN) Extracts the base DN from bind operation DN.getBase()
Returns the base DN where to search for users.protected String
Resolves the bind operation DN from the specified username and domain.Returns the domain.Returns the search user filter.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_SEARCH_USER_FILTER
The default search user filter.- See Also:
-
-
Constructor Details
-
ActiveDirectoryAuthenticator
Creates an Active Directory authenticator with the specified LDAP client and domain.
The resulting authenticator is terminal and returns denied authentication on failed authentication.
- Parameters:
ldapClient
- the LDAP clientdomain
- the domain
-
ActiveDirectoryAuthenticator
Creates an Active Directory authenticator with the specified LDAP client, domain and base DN.
The resulting authenticator is terminal and returns denied authentication on failed authentication.
- Parameters:
ldapClient
- the LDAP clientdomain
- the domainbase
- the base DN
-
ActiveDirectoryAuthenticator
public ActiveDirectoryAuthenticator(LDAPClient ldapClient, String domain, String base, String searchUserFilter) Creates an Active Directory authenticator with the specified LDAP client, domain, base DN and search user filter.
The resulting authenticator is terminal and returns denied authentication on failed authentication.
- Parameters:
ldapClient
- the LDAP clientdomain
- the domainbase
- the base DNsearchUserFilter
- the search user filter
-
-
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
-
getDomain
Returns the domain.
- Returns:
- the domain
-
getBase
Returns the base DN where to search for users.
- Returns:
- the base DN
-
getSearchUserFilter
Returns the search user filter.
- Returns:
- a filter
-
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
-
getBindDN
Resolves the bind operation DN from the specified username and domain.
This method basically appends the domain to the username if it doesn't already provides a domain to obtain an Active Directory login name of the form:
<username>@<domain>
.- Parameters:
username
- the name of the user to authenticatedomain
- the domain- Returns:
- bind operation DN
-
boundDNToBaseDN
Extracts the base DN from bind operation DN.
This basically converts the domain to a valid LDAP DN (e.g.
example.com
todc=example,dc=com
).- Parameters:
boundDN
- the bind operation DN- Returns:
- a base DN
- Throws:
InvalidCredentialsException
- if the bind operation DN is invalid (i.e. it does not provides a domain)
-