edu.vt.middleware.ldap.auth
Class Authenticator

java.lang.Object
  extended by edu.vt.middleware.ldap.auth.AbstractAuthenticator<AuthenticatorConfig>
      extended by edu.vt.middleware.ldap.auth.Authenticator
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
JaasAuthenticator

public class Authenticator
extends AbstractAuthenticator<AuthenticatorConfig>
implements Serializable

Authenticator contains functions for authenticating a user against an LDAP.

Version:
$Revision: 1330 $ $Date: 2010-05-23 18:10:53 -0400 (Sun, 23 May 2010) $
Author:
Middleware Services
See Also:
Serialized Form

Field Summary
 
Fields inherited from class edu.vt.middleware.ldap.auth.AbstractAuthenticator
config, logger
 
Constructor Summary
Authenticator()
          Default constructor.
Authenticator(AuthenticatorConfig authConfig)
          This will create a new Authenticator with the supplied AuthenticatorConfig.
 
Method Summary
 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).
 Attributes authenticate(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(String user, Object credential)
          This will authenticate by binding to the LDAP with the supplied user and credential.
 boolean authenticate(String user, Object credential, AuthenticationResultHandler[] authHandler, AuthorizationHandler[] authzHandler)
          This will authenticate by binding to the LDAP with the supplied user and credential.
 boolean authenticate(String user, Object credential, SearchFilter filter)
          This will authenticate by binding to the LDAP with the supplied user and credential.
 Attributes authenticate(String user, Object credential, SearchFilter filter, String[] retAttrs)
          This will authenticate by binding to the LDAP with the supplied user and credential.
 Attributes authenticate(String user, Object credential, String[] retAttrs)
          This will authenticate by binding to the LDAP with the supplied user and credential.
 Attributes authenticate(String user, Object credential, 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.
 String getDn(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(InputStream is)
          This will set the config parameters of this Authenticator using the supplied input stream.
 
Methods inherited from class edu.vt.middleware.ldap.auth.AbstractAuthenticator
authenticateAndAuthorize, authenticateAndAuthorize, close, setAuthenticatorConfig
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Authenticator

public Authenticator()
Default constructor.


Authenticator

public Authenticator(AuthenticatorConfig authConfig)
This will create a new Authenticator with the supplied AuthenticatorConfig.

Parameters:
authConfig - AuthenticatorConfig
Method Detail

getAuthenticatorConfig

public AuthenticatorConfig getAuthenticatorConfig()
This returns the AuthenticatorConfig of the Authenticator.

Returns:
AuthenticatorConfig

loadFromProperties

public void loadFromProperties()
This will set the config parameters of this Authenticator using the default properties file, which must be located in your classpath.


loadFromProperties

public void loadFromProperties(InputStream is)
This will set the config parameters of this Authenticator using the supplied input stream.

Parameters:
is - InputStream

getDn

public String getDn(String user)
             throws NamingException
This will attempt to find the LDAP DN for the supplied user. AuthenticatorConfig.dnResolver is invoked to perform this operation.

Parameters:
user - String to find dn for
Returns:
String - user's dn
Throws:
NamingException - an LDAP error occurs

authenticate

public boolean authenticate()
                     throws NamingException
This will authenticate by binding to the LDAP using parameters given by AuthenticatorConfig.setUser(java.lang.String) and AuthenticatorConfig.setCredential(java.lang.Object). See authenticate(String, Object).

Returns:
boolean - whether the bind succeeded
Throws:
NamingException - if the authentication fails for any other reason than invalid credentials

authenticate

public boolean authenticate(String user,
                            Object credential)
                     throws NamingException
This will authenticate by binding to the LDAP with the supplied user and credential. If 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).

Parameters:
user - String username for bind
credential - Object credential for bind
Returns:
boolean - whether the bind succeeded
Throws:
NamingException - if the authentication fails for any other reason than invalid credentials

authenticate

public boolean authenticate(String user,
                            Object credential,
                            SearchFilter filter)
                     throws NamingException
This will authenticate by binding to the LDAP with the supplied user and credential. If the supplied filter is not null it will be injected into a new instance of CompareAuthorizationHandler and set as the first AuthorizationHandler to execute. If AuthenticatorConfig.setAuthenticationResultHandlers( AuthenticationResultHandler[]) has been called, then it will be used to post process authentication results. See authenticate(String, Object, AuthenticationResultHandler[], AuthorizationHandler[]).

Parameters:
user - String username for bind
credential - Object credential for bind
filter - SearchFilter to authorize user
Returns:
boolean - whether the bind succeeded
Throws:
NamingException - if the authentication fails for any other reason than invalid credentials

authenticate

public boolean authenticate(String user,
                            Object credential,
                            AuthenticationResultHandler[] authHandler,
                            AuthorizationHandler[] authzHandler)
                     throws NamingException
This will authenticate by binding to the LDAP with the supplied user and credential. The user's DN will be looked up before performing the bind by calling DnResolver.resolve(String). See AbstractAuthenticator.authenticateAndAuthorize(String, Object, AuthenticationResultHandler[], AuthorizationHandler[]).

Parameters:
user - String username for bind
credential - Object credential for bind
authHandler - AuthenticationResultHandler[] to post process authentication results
authzHandler - AuthorizationHandler[] to process authorization after authentication
Returns:
boolean - whether the bind succeeded
Throws:
NamingException - if the authentication fails for any other reason than invalid credentials

authenticate

public Attributes authenticate(String[] retAttrs)
                        throws NamingException
This will authenticate by binding to the LDAP using parameters given by AuthenticatorConfig.setUser(java.lang.String) and AuthenticatorConfig.setCredential(java.lang.Object). See authenticate(String,Object,String[])

Parameters:
retAttrs - String[] attributes to return
Returns:
Attributes - of authenticated user
Throws:
NamingException - if any of the ldap operations fail

authenticate

public Attributes authenticate(String user,
                               Object credential,
                               String[] retAttrs)
                        throws NamingException
This will authenticate by binding to the LDAP with the supplied user and credential. If 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[])

Parameters:
user - String username for bind
credential - Object credential for bind
retAttrs - String[] to return
Returns:
Attributes - of authenticated user
Throws:
NamingException - if any of the ldap operations fail

authenticate

public Attributes authenticate(String user,
                               Object credential,
                               SearchFilter filter,
                               String[] retAttrs)
                        throws NamingException
This will authenticate by binding to the LDAP with the supplied user and credential. If the supplied filter is not null it will be injected into a new instance of CompareAuthorizationHandler and set as the first AuthorizationHandler to execute. See authenticate(String, Object, String[], AuthenticationResultHandler[], AuthorizationHandler[]).

Parameters:
user - String username for bind
credential - Object credential for bind
filter - SearchFilter to authorize user
retAttrs - String[] to return
Returns:
Attributes - of authenticated user
Throws:
NamingException - if any of the ldap operations fail

authenticate

public Attributes authenticate(String user,
                               Object credential,
                               String[] retAttrs,
                               AuthenticationResultHandler[] authHandler,
                               AuthorizationHandler[] authzHandler)
                        throws NamingException
This will authenticate by binding to the LDAP with the supplied user and credential. The user's DN will be looked up before performing the bind by calling DnResolver.resolve(String). See AbstractAuthenticator.authenticateAndAuthorize(String, Object, boolean, String[], AuthenticationResultHandler[], AuthorizationHandler[]).

Parameters:
user - String username for bind
credential - Object credential for bind
retAttrs - String[] to return
authHandler - AuthenticationResultHandler[] to post process authentication results
authzHandler - AuthorizationHandler[] to process authorization after authentication
Returns:
Attributes - of authenticated user
Throws:
NamingException - if any of the ldap operations fail


Copyright © 2003-2010 Virginia Tech. All Rights Reserved.