Package org.ldaptive.auth
Class CompareAuthenticationHandler
- java.lang.Object
-
- org.ldaptive.AbstractFreezable
-
- org.ldaptive.auth.AbstractAuthenticationHandler
-
- org.ldaptive.auth.CompareAuthenticationHandler
-
- All Implemented Interfaces:
AuthenticationHandler
,ConnectionFactoryManager
,Freezable
public final class CompareAuthenticationHandler extends AbstractAuthenticationHandler
Provides an LDAP authentication implementation that uses a compare operation against the userPassword attribute. The default password scheme used is 'SHA'.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CompareAuthenticationHandler.Scheme
Represents a password scheme used for attribute comparison.
-
Field Summary
Fields Modifier and Type Field Description private static String
DEFAULT_ATTRIBUTE
Default password attribute.private static String
DEFAULT_SCHEME
Default password scheme.private String
passwordAttribute
Password attribute.private CompareAuthenticationHandler.Scheme
passwordScheme
Password scheme.-
Fields inherited from class org.ldaptive.auth.AbstractAuthenticationHandler
logger
-
-
Constructor Summary
Constructors Constructor Description CompareAuthenticationHandler()
Default constructor.CompareAuthenticationHandler(ConnectionFactory cf)
Creates a new compare authentication handler.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected AuthenticationHandlerResponse
authenticateInternal(Connection c, AuthenticationCriteria criteria)
Authenticate on the supplied connection using the supplied criteria.private byte[]
digestCredential(Credential credential, String algorithm)
Digests the supplied credential using the supplied algorithm.String
getPasswordAttribute()
Returns the password attribute.String
getPasswordScheme()
Returns the password scheme.void
setPasswordAttribute(String s)
Sets the password attribute.void
setPasswordScheme(String s)
Sets the password scheme.String
toString()
-
Methods inherited from class org.ldaptive.auth.AbstractAuthenticationHandler
authenticate, freeze, getAuthenticationControls, getConnectionFactory, processRequestControls, setAuthenticationControls, setConnectionFactory
-
Methods inherited from class org.ldaptive.AbstractFreezable
assertMutable, freeze, freeze, isFrozen
-
-
-
-
Field Detail
-
DEFAULT_SCHEME
private static final String DEFAULT_SCHEME
Default password scheme. Value is "SHA:SHA".- See Also:
- Constant Field Values
-
DEFAULT_ATTRIBUTE
private static final String DEFAULT_ATTRIBUTE
Default password attribute. Value is "userPassword".- See Also:
- Constant Field Values
-
passwordScheme
private CompareAuthenticationHandler.Scheme passwordScheme
Password scheme.
-
passwordAttribute
private String passwordAttribute
Password attribute.
-
-
Constructor Detail
-
CompareAuthenticationHandler
public CompareAuthenticationHandler()
Default constructor.
-
CompareAuthenticationHandler
public CompareAuthenticationHandler(ConnectionFactory cf)
Creates a new compare authentication handler.- Parameters:
cf
- connection factory
-
-
Method Detail
-
getPasswordScheme
public String getPasswordScheme()
Returns the password scheme.- Returns:
- password scheme
-
setPasswordScheme
public void setPasswordScheme(String s)
Sets the password scheme.- Parameters:
s
- password scheme
-
getPasswordAttribute
public String getPasswordAttribute()
Returns the password attribute.- Returns:
- password attribute
-
setPasswordAttribute
public void setPasswordAttribute(String s)
Sets the password attribute. Must equal a readable attribute in LDAP scheme.- Parameters:
s
- password attribute
-
authenticateInternal
protected AuthenticationHandlerResponse authenticateInternal(Connection c, AuthenticationCriteria criteria) throws LdapException
Description copied from class:AbstractAuthenticationHandler
Authenticate on the supplied connection using the supplied criteria.- Specified by:
authenticateInternal
in classAbstractAuthenticationHandler
- Parameters:
c
- to authenticate oncriteria
- criteria to authenticate with- Returns:
- authentication handler response
- Throws:
LdapException
- if the authentication fails
-
digestCredential
private byte[] digestCredential(Credential credential, String algorithm) throws LdapException
Digests the supplied credential using the supplied algorithm.- Parameters:
credential
- to digestalgorithm
- type of digest to use- Returns:
- digested credential
- Throws:
LdapException
- if the supplied algorithm cannot be found
-
toString
public String toString()
- Overrides:
toString
in classAbstractAuthenticationHandler
-
-