public final class Authenticator extends Object
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.
| Constructor and Description |
|---|
Authenticator()
Default constructor.
|
Authenticator(String loginModule)
Create a new authenticator for the specified login module.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
public Authenticator()
loginModule to a system property
with the key com.sptci.auth.Authenticator.module to use as
the JAAS module to use.public Authenticator(String loginModule)
loginModule - The JAAS login module to use.public User authenticate(String userName, char[] password) throws AuthenticationException
userName - The user/login name to authenticate.password - The password to authenticate.AuthenticationException - If the specified credentials could
not be authenticated.authenticate( String, char[], char[] )public User authenticate(String userName, char[] password, char[] key) throws AuthenticationException
userName - The user/login name to authenticate.password - The password to authenticate.key - The key to use to decrypt the stored password.AuthenticationException - If the specified credentials could
not be authenticated.