SPT Core API

com.sptci.auth
Class Authenticator

java.lang.Object
  extended by com.sptci.auth.Authenticator

public final class Authenticator
extends Object

A JAAS based authenticator to implement login/authentication.

The following shows how to use this class. Note that the appropriate login module to use must be configured via JAAS.

   import com.sptci.auth.Authenticator;
   import com.sptci.auth.AuthenticationException;
   import com.sptci.auth.Group;
   import com.sptci.auth.User;

     ...
     String user = "scott";
     char[] password = "tiger".toCharArray();
     String loginmodule = "databaseauthenticator";
     Authenticator authenticator = new Authenticator( loginmodule );
     User user = null;
     try
     {
       user = authenticator.authenticate( user, password );
     }
     catch ( AuthenticationException aex )
     {
       logger.log( Level.SEVERE, "Authentication failed for user: " +
           user, aex );
       throw new ApplicationException( aex );
     }

     for ( Group group : user.groups )
     {
     }
 

Copyright 2006, Sans Pareil Technologies, Inc.

Version:
$Id: Authenticator.java 4553 2008-12-24 10:34:16Z rakesh $
Author:
Rakesh Vidyadharan 2006-11-15

Constructor Summary
Authenticator()
          Default constructor.
Authenticator(String loginModule)
          Create a new authenticator for the specified login module.
 
Method Summary
 User authenticate(String userName, char[] password)
          Authenticate the user with the specified credentials.
 User authenticate(String userName, char[] password, char[] key)
          Authenticate the user with the specified credentials.
 
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. Sets loginModule to a system property with the key com.sptci.auth.Authenticator.module to use as the JAAS module to use.


Authenticator

public Authenticator(String loginModule)
Create a new authenticator for the specified login module.

Parameters:
loginModule - The JAAS login module to use.
Method Detail

authenticate

public User authenticate(String userName,
                         char[] password)
                  throws AuthenticationException
Authenticate the user with the specified credentials.

Parameters:
userName - The user/login name to authenticate.
password - The password to authenticate.
Returns:
A user data object which may be used to perform authorisation.
Throws:
AuthenticationException - If the specified credentials could not be authenticated.
See Also:
authenticate( String, char[], char[] )

authenticate

public User authenticate(String userName,
                         char[] password,
                         char[] key)
                  throws AuthenticationException
Authenticate the user with the specified credentials.

Parameters:
userName - The user/login name to authenticate.
password - The password to authenticate.
key - The key to use to decrypt the stored password.
Returns:
A user data object which may be used to perform authorisation.
Throws:
AuthenticationException - If the specified credentials could not be authenticated.

SPT Core API