Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

org.objectweb.cjdbc.controller.authentication.PasswordAuthenticator Class Reference

Collaboration diagram for org.objectweb.cjdbc.controller.authentication.PasswordAuthenticator:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 PasswordAuthenticator (String username, String password)
Subject authenticate (Object credentials) throws SecurityException

Static Public Member Functions

Object createCredentials (String username, String password)

Static Public Attributes

final PasswordAuthenticator NO_AUTHENICATION

Static Package Attributes

Trace logger

Detailed Description

This class defines a PasswordAuthenticator

Author:
Marc Wick
Version:
1.0

Definition at line 38 of file PasswordAuthenticator.java.


Constructor & Destructor Documentation

org.objectweb.cjdbc.controller.authentication.PasswordAuthenticator.PasswordAuthenticator String  username,
String  password
 

Creates a new PasswordAuthenticator.java object

Parameters:
username username/loginname
password password

Definition at line 61 of file PasswordAuthenticator.java.

00062   {
00063     this.username = username;
00064     this.password = password;
00065   }


Member Function Documentation

Subject org.objectweb.cjdbc.controller.authentication.PasswordAuthenticator.authenticate Object  credentials  )  throws SecurityException
 

See also:
javax.management.remote.JMXAuthenticator#authenticate(java.lang.Object)

Definition at line 82 of file PasswordAuthenticator.java.

00083   {
00084     try
00085     {
00086       if (username == null && password == null)
00087       {
00088         // no authentication is required we return
00089         return new Subject();
00090       }
00091 
00092       if (credentials == null)
00093       {
00094         throw new SecurityException("credentials are required");
00095       }
00096 
00097       try
00098       {
00099         String[] credentialsArray = (String[]) credentials;
00100         if (username.equals(credentialsArray[0])
00101             && password.equals(credentialsArray[1]))
00102         {
00103           // username and password are ok
00104           if (logger.isDebugEnabled())
00105           {
00106             logger.debug("successfully authenitcated ");
00107           }
00108           return new Subject();
00109         }
00110       }
00111       catch (Exception e)
00112       {
00113         // the credentials object makes problems, is was probably not created
00114         // with the createCredentials method
00115         throw new SecurityException("problems with credentials object : "
00116             + e.getMessage());
00117       }
00118 
00119       // username and password do not match
00120       throw new SecurityException("invalid credentials");
00121     }
00122     catch (SecurityException e)
00123     {
00124       logger.error(e.getMessage());
00125       try
00126       {
00127         String clientId = java.rmi.server.RemoteServer.getClientHost();
00128         logger.warn("refused unauthorized access for client " + clientId);
00129       }
00130       catch (Exception ex)
00131       {
00132 
00133       }
00134       throw e;
00135     }
00136   }

Object org.objectweb.cjdbc.controller.authentication.PasswordAuthenticator.createCredentials String  username,
String  password
[static]
 

create a credentials object with the supplied username and password

Parameters:
username username
password password
Returns:
credentials Object to be used for authentication,

Definition at line 74 of file PasswordAuthenticator.java.

00075   {
00076     return new String[]{username, password};
00077   }


Member Data Documentation

Trace org.objectweb.cjdbc.controller.authentication.PasswordAuthenticator.logger [static, package]
 

Initial value:

 Trace
                                                                 .getLogger("org.objectweb.cjdbc.controller.authentication")

Definition at line 49 of file PasswordAuthenticator.java.

final PasswordAuthenticator org.objectweb.cjdbc.controller.authentication.PasswordAuthenticator.NO_AUTHENICATION [static]
 

Initial value:

 new PasswordAuthenticator(
                                                                 null, null)
to enable subject delegation we use a dummy authentication even if none is configured

Definition at line 46 of file PasswordAuthenticator.java.


The documentation for this class was generated from the following file:
Generated on Mon Apr 11 22:03:24 2005 for C-JDBC by  doxygen 1.3.9.1