edu.vt.middleware.ldap.auth
public class Authenticator extends AbstractAuthenticator<AuthenticatorConfig> implements java.io.Serializable
Authenticator
contains functions for authenticating a user
against an LDAP.config, logger
Constructor and Description |
---|
Authenticator()
Default constructor.
|
Authenticator(AuthenticatorConfig authConfig)
This will create a new
Authenticator with the supplied
AuthenticatorConfig . |
Modifier and Type | Method and Description |
---|---|
boolean |
authenticate()
This will authenticate by binding to the LDAP using parameters given by
AuthenticatorConfig.setUser(java.lang.String) and AuthenticatorConfig.setCredential(java.lang.Object) . |
javax.naming.directory.Attributes |
authenticate(java.lang.String[] retAttrs)
This will authenticate by binding to the LDAP using parameters given by
AuthenticatorConfig.setUser(java.lang.String) and AuthenticatorConfig.setCredential(java.lang.Object) . |
boolean |
authenticate(java.lang.String user,
java.lang.Object credential)
This will authenticate by binding to the LDAP with the supplied user and
credential.
|
boolean |
authenticate(java.lang.String user,
java.lang.Object credential,
AuthenticationResultHandler[] authHandler,
AuthorizationHandler[] authzHandler)
This will authenticate by binding to the LDAP with the supplied user and
credential.
|
boolean |
authenticate(java.lang.String user,
java.lang.Object credential,
SearchFilter filter)
This will authenticate by binding to the LDAP with the supplied user and
credential.
|
javax.naming.directory.Attributes |
authenticate(java.lang.String user,
java.lang.Object credential,
SearchFilter filter,
java.lang.String[] retAttrs)
This will authenticate by binding to the LDAP with the supplied user and
credential.
|
javax.naming.directory.Attributes |
authenticate(java.lang.String user,
java.lang.Object credential,
java.lang.String[] retAttrs)
This will authenticate by binding to the LDAP with the supplied user and
credential.
|
javax.naming.directory.Attributes |
authenticate(java.lang.String user,
java.lang.Object credential,
java.lang.String[] retAttrs,
AuthenticationResultHandler[] authHandler,
AuthorizationHandler[] authzHandler)
This will authenticate by binding to the LDAP with the supplied user and
credential.
|
AuthenticatorConfig |
getAuthenticatorConfig()
This returns the
AuthenticatorConfig of the
Authenticator . |
java.lang.String |
getDn(java.lang.String user)
This will attempt to find the LDAP DN for the supplied user.
|
void |
loadFromProperties()
This will set the config parameters of this
Authenticator
using the default properties file, which must be located in your classpath. |
void |
loadFromProperties(java.io.InputStream is)
This will set the config parameters of this
Authenticator
using the supplied input stream. |
authenticateAndAuthorize, authenticateAndAuthorize, close, setAuthenticatorConfig
public Authenticator()
public Authenticator(AuthenticatorConfig authConfig)
Authenticator
with the supplied
AuthenticatorConfig
.authConfig
- AuthenticatorConfig
public AuthenticatorConfig getAuthenticatorConfig()
AuthenticatorConfig
of the
Authenticator
.AuthenticatorConfig
public void loadFromProperties()
Authenticator
using the default properties file, which must be located in your classpath.public void loadFromProperties(java.io.InputStream is)
Authenticator
using the supplied input stream.is
- InputStream
public java.lang.String getDn(java.lang.String user) throws javax.naming.NamingException
AuthenticatorConfig.dnResolver
is invoked to perform this operation.user
- String
to find dn forString
- user's dnjavax.naming.NamingException
- an LDAP error occurspublic boolean authenticate() throws javax.naming.NamingException
AuthenticatorConfig.setUser(java.lang.String)
and AuthenticatorConfig.setCredential(java.lang.Object)
. See authenticate(String,
Object)
.boolean
- whether the bind succeededjavax.naming.NamingException
- if the authentication fails for any other reason
than invalid credentialspublic boolean authenticate(java.lang.String user, java.lang.Object credential) throws javax.naming.NamingException
AuthenticatorConfig.setAuthorizationFilter(java.lang.String)
has been
called, then it will be used to authorize the user by performing an ldap
compare. See authenticate(String, Object, SearchFilter)
.user
- String
username for bindcredential
- Object
credential for bindboolean
- whether the bind succeededjavax.naming.NamingException
- if the authentication fails for any other reason
than invalid credentialspublic boolean authenticate(java.lang.String user, java.lang.Object credential, SearchFilter filter) throws javax.naming.NamingException
AuthenticatorConfig.setAuthenticationResultHandlers(
AuthenticationResultHandler[])
has been called, then it will be used to
post process authentication results. See authenticate(String,
Object, AuthenticationResultHandler[], AuthorizationHandler[])
.user
- String
username for bindcredential
- Object
credential for bindfilter
- SearchFilter
to authorize userboolean
- whether the bind succeededjavax.naming.NamingException
- if the authentication fails for any other reason
than invalid credentialspublic boolean authenticate(java.lang.String user, java.lang.Object credential, AuthenticationResultHandler[] authHandler, AuthorizationHandler[] authzHandler) throws javax.naming.NamingException
DnResolver.resolve(String)
. See AbstractAuthenticator.authenticateAndAuthorize(String, Object, AuthenticationResultHandler[],
AuthorizationHandler[])
.user
- String
username for bindcredential
- Object
credential for bindauthHandler
- AuthenticationResultHandler[]
to post
process authentication resultsauthzHandler
- AuthorizationHandler[]
to process
authorization after authenticationboolean
- whether the bind succeededjavax.naming.NamingException
- if the authentication fails for any other reason
than invalid credentialspublic javax.naming.directory.Attributes authenticate(java.lang.String[] retAttrs) throws javax.naming.NamingException
AuthenticatorConfig.setUser(java.lang.String)
and AuthenticatorConfig.setCredential(java.lang.Object)
. See authenticate(String,Object,String[])
retAttrs
- String[]
attributes to returnAttributes
- of authenticated userjavax.naming.NamingException
- if any of the ldap operations failpublic javax.naming.directory.Attributes authenticate(java.lang.String user, java.lang.Object credential, java.lang.String[] retAttrs) throws javax.naming.NamingException
AuthenticatorConfig.setAuthorizationFilter(java.lang.String)
has been
called, then it will be used to authorize the user by performing an ldap
compare. See authenticate(String, Object, SearchFilter, String[])
user
- String
username for bindcredential
- Object
credential for bindretAttrs
- String[]
to returnAttributes
- of authenticated userjavax.naming.NamingException
- if any of the ldap operations failpublic javax.naming.directory.Attributes authenticate(java.lang.String user, java.lang.Object credential, SearchFilter filter, java.lang.String[] retAttrs) throws javax.naming.NamingException
authenticate(String, Object,
String[], AuthenticationResultHandler[], AuthorizationHandler[])
.user
- String
username for bindcredential
- Object
credential for bindfilter
- SearchFilter
to authorize userretAttrs
- String[]
to returnAttributes
- of authenticated userjavax.naming.NamingException
- if any of the ldap operations failpublic javax.naming.directory.Attributes authenticate(java.lang.String user, java.lang.Object credential, java.lang.String[] retAttrs, AuthenticationResultHandler[] authHandler, AuthorizationHandler[] authzHandler) throws javax.naming.NamingException
DnResolver.resolve(String)
. See AbstractAuthenticator.authenticateAndAuthorize(String, Object, boolean, String[],
AuthenticationResultHandler[], AuthorizationHandler[])
.user
- String
username for bindcredential
- Object
credential for bindretAttrs
- String[]
to returnauthHandler
- AuthenticationResultHandler[]
to post
process authentication resultsauthzHandler
- AuthorizationHandler[]
to process
authorization after authenticationAttributes
- of authenticated userjavax.naming.NamingException
- if any of the ldap operations failCopyright © 2014. All Rights Reserved.