Package edu.vt.middleware.ldap.auth
Class AbstractAuthenticator<T extends AuthenticatorConfig>
- java.lang.Object
-
- edu.vt.middleware.ldap.auth.AbstractAuthenticator<T>
-
- Type Parameters:
T
- type of AuthenticatorConfig
- Direct Known Subclasses:
Authenticator
public abstract class AbstractAuthenticator<T extends AuthenticatorConfig> extends java.lang.Object
AbstractAuthenticator
provides basic functionality for authenticating against an LDAP.- Version:
- $Revision: 1743 $ $Date: 2010-11-19 18:00:18 +0100 (Fri, 19 Nov 2010) $
- Author:
- Middleware Services
-
-
Constructor Summary
Constructors Constructor Description AbstractAuthenticator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected javax.naming.directory.Attributes
authenticateAndAuthorize(java.lang.String dn, java.lang.Object credential, boolean searchAttrs, java.lang.String[] retAttrs, AuthenticationResultHandler[] authResultHandler, AuthorizationHandler[] authzHandler)
This will authenticate by binding to the LDAP with the supplied dn and credential.protected boolean
authenticateAndAuthorize(java.lang.String dn, java.lang.Object credential, AuthenticationResultHandler[] authResultHandler, AuthorizationHandler[] authzHandler)
This will authenticate by binding to the LDAP with the supplied dn and credential.void
close()
This will close the connection on the underlying DN resolver.void
setAuthenticatorConfig(T authConfig)
This will set the config parameters of thisAuthenticator
.
-
-
-
Field Detail
-
logger
protected final org.apache.commons.logging.Log logger
Log for this class.
-
config
protected T extends AuthenticatorConfig config
Authenticator configuration environment.
-
-
Method Detail
-
setAuthenticatorConfig
public void setAuthenticatorConfig(T authConfig)
This will set the config parameters of thisAuthenticator
.- Parameters:
authConfig
-AuthenticatorConfig
-
authenticateAndAuthorize
protected boolean authenticateAndAuthorize(java.lang.String dn, java.lang.Object credential, AuthenticationResultHandler[] authResultHandler, AuthorizationHandler[] authzHandler) throws javax.naming.NamingException
This will authenticate by binding to the LDAP with the supplied dn and credential. SeeauthenticateAndAuthorize( String, Object, boolean, String[], AuthenticationResultHandler[], AuthorizationHandler[])
.- Parameters:
dn
-String
for bindcredential
-Object
for bindauthResultHandler
-AuthenticationResultHandler[]
to post process authentication resultsauthzHandler
-AuthorizationHandler[]
to process authorization after authentication- Returns:
boolean
- whether the bind succeeded- Throws:
javax.naming.NamingException
- if the authentication fails for any other reason than invalid credentials
-
authenticateAndAuthorize
protected javax.naming.directory.Attributes authenticateAndAuthorize(java.lang.String dn, java.lang.Object credential, boolean searchAttrs, java.lang.String[] retAttrs, AuthenticationResultHandler[] authResultHandler, AuthorizationHandler[] authzHandler) throws javax.naming.NamingException
This will authenticate by binding to the LDAP with the supplied dn and credential. Authentication will never succeed ifLdapConfig.getAuthtype()
is set to 'none'. If retAttrs is null and searchAttrs is true then all user attributes will be returned. If retAttrs is an empty array and searchAttrs is true then no attributes will be returned. This method throws AuthenticationException if authentication fails and AuthorizationException if authorization fails.- Parameters:
dn
-String
for bindcredential
-Object
for bindsearchAttrs
-boolean
whether to perform attribute searchretAttrs
-String[]
user attributes to returnauthResultHandler
-AuthenticationResultHandler[]
to post process authentication resultsauthzHandler
-AuthorizationHandler[]
to process authorization after authentication- Returns:
Attribute
- belonging to the supplied user, returns null if searchAttrs is false- Throws:
javax.naming.NamingException
- if any of the ldap operations failjavax.naming.AuthenticationException
- if authentication failsAuthorizationException
- if authorization fails
-
close
public void close()
This will close the connection on the underlying DN resolver.
-
-