| 
 | |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.apache.catalina.realm.RealmBase
org.jaffa.tomcat.realm.JDBCEncryptionRealm
This Realm included the functionality of both the standard tomcat
 JDBCRealm
 and the DataSourceRealm,
 in one class. It also included the ability to perform custom
 password encryption using 3rd party classes (if your encryption scheme is not
 supported by the default MessageDigest class in the JCE libraries).
 
This new version works with Tomcat 4.1 and higher, the previous version that doesn't have the DataSource code in it, works with ther earlier Tomcat 4.0 release
The code based for this classes was taken from the Tomcat 4.1.26 release
The two properties used for encryption are : encryptionClass and encryptionMethod.
With these set, the realm introspects for the named class for the names method. It is expected that the method has one of the following signatures
      public static String methodName(String password)
 
 or
 
      public static String methodName(String password, String username)
 
 The method should return a string, that should match the value retrieved from the
 database. This allow one-way encryption algorithms to be used. No decryption facility
 needs to be provided.
 In addition to the original JDBCRealm/DataSource this realm
connectionName,
 connectionPassword, connectionURL and driverName
 
| Field Summary | |
| protected  String | connectionNameThe connection username to use when trying to connect to the database. | 
| protected  String | connectionPasswordThe connection URL to use when trying to connect to the database. | 
| protected  String | connectionURLThe connection URL to use when trying to connect to the database. | 
| protected  String | dataSourceNameThe name of the JNDI JDBC DataSource | 
| protected  Connection | dbConnectionThe connection to the database. | 
| protected  Driver | driverInstance of the JDBC Driver class we use as a connection factory. | 
| protected  String | driverNameThe JDBC driver to use. | 
| protected static String | infoDescriptive information about this Realm implementation. | 
| protected static String | nameDescriptive information about this Realm implementation. | 
| protected  PreparedStatement | preparedCredentialsThe PreparedStatement to use for authenticating users. | 
| protected  PreparedStatement | preparedRolesThe PreparedStatement to use for identifying the roles for a specified user. | 
| protected  String | roleNameColThe column in the user role table that names a role | 
| protected static StringManager | smThe string manager for this package. | 
| protected  String | userCredColThe column in the user table that holds the user's credintials | 
| protected  String | userNameColThe column in the user table that holds the user's name | 
| protected  String | userRoleTableThe table that holds the relation between user's and roles | 
| protected  String | userTableThe table that holds user data. | 
| Fields inherited from class org.apache.catalina.realm.RealmBase | 
| container, debug, digest, lifecycle, md, md5Encoder, md5Helper, started, support, validate | 
| Fields inherited from interface org.apache.catalina.Lifecycle | 
| AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, START_EVENT, STOP_EVENT | 
| Constructor Summary | |
| JDBCEncryptionRealm() | |
| Method Summary | |
|  Principal | authenticate(String username,
                         String credentials)Return the Principal associated with the specified username and credentials, if there is one; otherwise return null. | 
| protected  void | close(Connection dbConnection)Close the specified database connection. | 
| protected  PreparedStatement | credentials(Connection dbConnection,
                       String username)Return a PreparedStatement configured to perform the SELECT required to retrieve user credentials for the specified username. | 
|  String | getConnectionName()Return the username to use to connect to the database. | 
|  String | getConnectionPassword()Return the password to use to connect to the database. | 
|  String | getConnectionURL()Return the URL to use to connect to the database. | 
|  String | getDataSourceName()Return the name of the JNDI JDBC DataSource. | 
|  String | getDriverName()Return the JDBC driver that will be used. | 
|  String | getEncryptionClass()Return the class used for encryption | 
|  String | getEncryptionMethod()Return the method used for encryption | 
| protected  String | getName()Return a short name for this Realm implementation. | 
| protected  String | getPassword(String username)Not Implemented - Return the password associated with the given principal's user name. | 
| protected  Principal | getPrincipal(String username)Not Implemented - Return the Principal associated with the given user name. | 
|  String | getRoleNameCol()Return the column in the user role table that names a role. | 
|  String | getRoleSelect()Return the alternative select statement for reading the roles | 
|  String | getUserClause()Getter for property userClause. | 
|  String | getUserCredCol()Return the column in the user table that holds the user's credentials. | 
|  String | getUserNameCol()Return the column in the user table that holds the user's name. | 
|  String | getUserRoleTable()Return the table that holds the relation between user's and roles. | 
|  String | getUserTable()Return the table that holds user data. | 
| protected  Connection | open()Open (if necessary) and return a database connection for use by this Realm. | 
| protected  void | release(Connection dbConnection)Release our use of this connection so that it can be recycled. | 
| protected  PreparedStatement | roles(Connection dbConnection,
           String username)Return a PreparedStatement configured to perform the SELECT required to retrieve user roles for the specified username. | 
|  void | setConnectionName(String connectionName)Set the username to use to connect to the database. | 
|  void | setConnectionPassword(String connectionPassword)Set the password to use to connect to the database. | 
|  void | setConnectionURL(String connectionURL)Set the URL to use to connect to the database. | 
|  void | setDataSourceName(String dataSourceName)Set the name of the JNDI JDBC DataSource. | 
|  void | setDriverName(String driverName)Set the JDBC driver that will be used. | 
|  void | setEncryptionClass(String encryptionClass)Setter for property encryptionClass. | 
|  void | setEncryptionMethod(String encryptionMethod)Setter for property encryptionMethod. | 
|  void | setRoleNameCol(String roleNameCol)Set the column in the user role table that names a role. | 
|  void | setRoleSelect(String roleSelect)Setter for property roleSelect. | 
|  void | setUserClause(String userClause)Setter for property userClause. | 
|  void | setUserCredCol(String userCredCol)Set the column in the user table that holds the user's credentials. | 
|  void | setUserNameCol(String userNameCol)Set the column in the user table that holds the user's name. | 
|  void | setUserRoleTable(String userRoleTable)Set the table that holds the relation between user's and roles. | 
|  void | setUserTable(String userTable)Set the table that holds user data. | 
|  void | start()Prepare for active use of the public methods of this Component. | 
|  void | stop()Gracefully shut down active use of the public methods of this Component. | 
| Methods inherited from class org.apache.catalina.realm.RealmBase | 
| addLifecycleListener, addPropertyChangeListener, authenticate, authenticate, authenticate, digest, Digest, findLifecycleListeners, getContainer, getDebug, getDigest, getDigest, getInfo, getValidate, hasMessageDigest, hasRole, log, log, main, removeLifecycleListener, removePropertyChangeListener, setContainer, setDebug, setDigest, setValidate | 
| Methods inherited from class java.lang.Object | 
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
protected String dataSourceName
protected String connectionName
protected String connectionPassword
protected String connectionURL
protected Connection dbConnection
protected Driver driver
protected String driverName
protected static final String info
protected static final String name
protected PreparedStatement preparedCredentials
protected PreparedStatement preparedRoles
protected String roleNameCol
protected static final StringManager sm
protected String userCredCol
protected String userNameCol
protected String userRoleTable
protected String userTable
| Constructor Detail | 
public JDBCEncryptionRealm()
| Method Detail | 
public String getDataSourceName()
public void setDataSourceName(String dataSourceName)
dataSourceName - the name of the JNDI JDBC DataSourcepublic String getConnectionName()
public void setConnectionName(String connectionName)
connectionName - Usernamepublic String getConnectionPassword()
public void setConnectionPassword(String connectionPassword)
connectionPassword - User passwordpublic String getConnectionURL()
public void setConnectionURL(String connectionURL)
connectionURL - The new connection URLpublic String getDriverName()
public void setDriverName(String driverName)
driverName - The driver namepublic String getRoleNameCol()
public void setRoleNameCol(String roleNameCol)
roleNameCol - The column namepublic String getUserCredCol()
public void setUserCredCol(String userCredCol)
userCredCol - The column namepublic String getUserNameCol()
public void setUserNameCol(String userNameCol)
userNameCol - The column namepublic String getUserRoleTable()
public void setUserRoleTable(String userRoleTable)
userRoleTable - The table namepublic String getUserTable()
public void setUserTable(String userTable)
userTable - The table namepublic void setEncryptionClass(String encryptionClass)
encryptionClass - New value of property encryptionClass.public String getEncryptionClass()
public void setEncryptionMethod(String encryptionMethod)
encryptionMethod - New value of property encryptionMethod.public String getEncryptionMethod()
public void setRoleSelect(String roleSelect)
roleSelect - New value of property roleSelect.public String getRoleSelect()
public String getUserClause()
public void setUserClause(String userClause)
userClause - New value of property userClause.
public Principal authenticate(String username,
                              String credentials)
null.
 If there are any errors with the JDBC connection, executing
 the query or anything we return null (don't authenticate). This
 event is also logged, and the connection will be closed so that
 a subsequent request will automatically re-open it.
username - Username of the Principal to look upcredentials - Password or other credentials to use in
 authenticating this username
protected void close(Connection dbConnection)
dbConnection - The connection to be closed
protected PreparedStatement credentials(Connection dbConnection,
                                        String username)
                                 throws SQLException
dbConnection - The database connection to be usedusername - Username for which credentials should be retrieved
SQLException - if a database error occursprotected String getName()
protected String getPassword(String username)
username - User's Name
protected Principal getPrincipal(String username)
username - User's Name
protected Connection open()
                   throws SQLException
SQLException - if a database error occurs
protected void release(Connection dbConnection)
                throws SQLException
dbConnection - Connection to release
SQLException - If there is an error with the database
protected PreparedStatement roles(Connection dbConnection,
                                  String username)
                           throws SQLException
dbConnection - The database connection to be usedusername - Username for which roles should be retrieved
SQLException - if a database error occurs
public void start()
           throws LifecycleException
LifecycleException - if this component detects a fatal error
  that prevents it from being started
public void stop()
          throws LifecycleException
LifecycleException - if this component detects a fatal error
  that needs to be reported| 
 | |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||