yawda.utils.realm
Class CDatasourceRealm

java.lang.Object
  extended byorg.apache.catalina.realm.RealmBase
      extended byyawda.utils.realm.CDatasourceRealm
All Implemented Interfaces:
org.apache.catalina.Lifecycle, org.apache.catalina.Realm

public final class CDatasourceRealm
extends org.apache.catalina.realm.RealmBase

Implmentation of Realm that works with any JDBC JNDI DataSource. See the JDBCRealm.howto for more details on how to set up the database and for configuration options.

Author:
Glenn L. Nielsen, Craig R. McClanahan, Carson McDonald, Ignacio Ortega modified by Quentin Anciaux for Yawda

Field Summary
protected  String dataSourceName
          The name of the JNDI JDBC DataSource
protected static String info
          Descriptive information about this Realm implementation.
protected static String name
          Descriptive information about this Realm implementation.
protected  String roleNameCol
          The column in the user role table that names a role
protected static org.apache.catalina.util.StringManager sm
          The string manager for this package.
protected  String userCredCol
          The column in the user table that holds the user's credintials
protected  String userNameCol
          The column in the user table that holds the user's name
protected  String userRoleTable
          The table that holds the relation between user's and roles
protected  String userTable
          The 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
CDatasourceRealm()
           
 
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.
 String getDataSourceName()
          Return the name of the JNDI JDBC DataSource.
protected  String getName()
          Return a short name for this Realm implementation.
protected  String getPassword(String username)
          Return the password associated with the given principal's user name.
protected  Principal getPrincipal(String username)
          Return the Principal associated with the given user name.
 String getRoleNameCol()
          Return the column in the user role table that names a role.
 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..
 void setDataSourceName(String dataSourceName)
          Set the name of the JNDI JDBC DataSource.
 void setRoleNameCol(String roleNameCol)
          Set the column in the user role table that names a role.
 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

dataSourceName

protected String dataSourceName
The name of the JNDI JDBC DataSource


info

protected static final String info
Descriptive information about this Realm implementation.

See Also:
Constant Field Values

name

protected static final String name
Descriptive information about this Realm implementation.

See Also:
Constant Field Values

roleNameCol

protected String roleNameCol
The column in the user role table that names a role


sm

protected static final org.apache.catalina.util.StringManager sm
The string manager for this package.


userCredCol

protected String userCredCol
The column in the user table that holds the user's credintials


userNameCol

protected String userNameCol
The column in the user table that holds the user's name


userRoleTable

protected String userRoleTable
The table that holds the relation between user's and roles


userTable

protected String userTable
The table that holds user data.

Constructor Detail

CDatasourceRealm

public CDatasourceRealm()
Method Detail

getDataSourceName

public final String getDataSourceName()
Return the name of the JNDI JDBC DataSource.


setDataSourceName

public final void setDataSourceName(String dataSourceName)
Set the name of the JNDI JDBC DataSource.

Parameters:
dataSourceName - the name of the JNDI JDBC DataSource

getRoleNameCol

public final String getRoleNameCol()
Return the column in the user role table that names a role.


setRoleNameCol

public final void setRoleNameCol(String roleNameCol)
Set the column in the user role table that names a role.

Parameters:
roleNameCol - The column name

getUserCredCol

public final String getUserCredCol()
Return the column in the user table that holds the user's credentials.


setUserCredCol

public final void setUserCredCol(String userCredCol)
Set the column in the user table that holds the user's credentials.

Parameters:
userCredCol - The column name

getUserNameCol

public final String getUserNameCol()
Return the column in the user table that holds the user's name.


setUserNameCol

public final void setUserNameCol(String userNameCol)
Set the column in the user table that holds the user's name.

Parameters:
userNameCol - The column name

getUserRoleTable

public final String getUserRoleTable()
Return the table that holds the relation between user's and roles.


setUserRoleTable

public final void setUserRoleTable(String userRoleTable)
Set the table that holds the relation between user's and roles.

Parameters:
userRoleTable - The table name

getUserTable

public final String getUserTable()
Return the table that holds user data..


setUserTable

public final void setUserTable(String userTable)
Set the table that holds user data.

Parameters:
userTable - The table name

authenticate

public final Principal authenticate(String username,
                                    String credentials)
Return the Principal associated with the specified username and credentials, if there is one; otherwise return 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.

Parameters:
username - Username of the Principal to look up
credentials - Password or other credentials to use in authenticating this username

getName

protected final String getName()
Return a short name for this Realm implementation.


getPassword

protected final String getPassword(String username)
Return the password associated with the given principal's user name.


getPrincipal

protected final Principal getPrincipal(String username)
Return the Principal associated with the given user name.


start

public final void start()
                 throws org.apache.catalina.LifecycleException
Prepare for active use of the public methods of this Component.

Throws:
org.apache.catalina.LifecycleException - if this component detects a fatal error that prevents it from being started

stop

public final void stop()
                throws org.apache.catalina.LifecycleException
Gracefully shut down active use of the public methods of this Component.

Throws:
org.apache.catalina.LifecycleException - if this component detects a fatal error that needs to be reported