| 
 | Apache Tomcat 6.0.53 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.catalina.realm.RealmBase
org.apache.catalina.realm.DataSourceRealm
public class DataSourceRealm
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.
| Nested Class Summary | 
|---|
| Nested classes/interfaces inherited from class org.apache.catalina.realm.RealmBase | 
|---|
| RealmBase.AllRolesMode | 
| Field Summary | |
|---|---|
| protected  java.lang.String | dataSourceNameThe name of the JNDI JDBC DataSource | 
| protected static java.lang.String | infoDescriptive information about this Realm implementation. | 
| protected  boolean | localDataSourceContext local datasource. | 
| protected static java.lang.String | nameDescriptive information about this Realm implementation. | 
| protected  java.lang.String | roleNameColThe column in the user role table that names a role | 
| protected static StringManager | smThe string manager for this package. | 
| protected  java.lang.String | userCredColThe column in the user table that holds the user's credintials | 
| protected  java.lang.String | userNameColThe column in the user table that holds the user's name | 
| protected  java.lang.String | userRoleTableThe table that holds the relation between user's and roles | 
| protected  java.lang.String | userTableThe table that holds user data. | 
| Fields inherited from class org.apache.catalina.realm.RealmBase | 
|---|
| allRolesMode, container, containerLog, controller, digest, digestEncoding, domain, host, initialized, lifecycle, md, md5Encoder, md5Helper, mserver, oname, path, realmPath, started, support, type, validate, x509UsernameRetriever, x509UsernameRetrieverClassName | 
| Fields inherited from interface org.apache.catalina.Lifecycle | 
|---|
| AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, DESTROY_EVENT, INIT_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT | 
| Constructor Summary | |
|---|---|
| DataSourceRealm() | |
| Method Summary | |
|---|---|
| protected  java.security.Principal | authenticate(java.sql.Connection dbConnection,
             java.lang.String username,
             java.lang.String credentials)Return the Principal associated with the specified username and credentials, if there is one; otherwise return null. | 
|  java.security.Principal | authenticate(java.lang.String username,
             java.lang.String credentials)Return the Principal associated with the specified username and credentials, if there is one; otherwise return null. | 
| protected  void | close(java.sql.Connection dbConnection)Close the specified database connection. | 
|  java.lang.String | getDataSourceName()Return the name of the JNDI JDBC DataSource. | 
|  java.lang.String | getInfo()Return descriptive information about this Realm implementation and the corresponding version number, in the format <description>/<version>. | 
|  boolean | getLocalDataSource()Return if the datasource will be looked up in the webapp JNDI Context. | 
| protected  java.lang.String | getName()Return a short name for this Realm implementation. | 
| protected  java.lang.String | getPassword(java.sql.Connection dbConnection,
            java.lang.String username)Return the password associated with the given principal's user name. | 
| protected  java.lang.String | getPassword(java.lang.String username)Return the password associated with the given principal's user name. | 
| protected  java.security.Principal | getPrincipal(java.lang.String username)Return the Principal associated with the given user name. | 
|  java.lang.String | getRoleNameCol()Return the column in the user role table that names a role. | 
| protected  java.util.ArrayList<java.lang.String> | getRoles(java.sql.Connection dbConnection,
         java.lang.String username)Return the roles associated with the given user name | 
| protected  java.util.ArrayList | getRoles(java.lang.String username)Return the roles associated with the given user name. | 
|  java.lang.String | getUserCredCol()Return the column in the user table that holds the user's credentials. | 
|  java.lang.String | getUserNameCol()Return the column in the user table that holds the user's name. | 
|  java.lang.String | getUserRoleTable()Return the table that holds the relation between user's and roles. | 
|  java.lang.String | getUserTable()Return the table that holds user data.. | 
| protected  java.sql.Connection | open()Open the specified database connection. | 
|  void | setDataSourceName(java.lang.String dataSourceName)Set the name of the JNDI JDBC DataSource. | 
|  void | setLocalDataSource(boolean localDataSource)Set to true to cause the datasource to be looked up in the webapp JNDI Context. | 
|  void | setRoleNameCol(java.lang.String roleNameCol)Set the column in the user role table that names a role. | 
|  void | setUserCredCol(java.lang.String userCredCol)Set the column in the user table that holds the user's credentials. | 
|  void | setUserNameCol(java.lang.String userNameCol)Set the column in the user table that holds the user's name. | 
|  void | setUserRoleTable(java.lang.String userRoleTable)Set the table that holds the relation between user's and roles. | 
|  void | setUserTable(java.lang.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 java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
|---|
protected java.lang.String dataSourceName
protected static final java.lang.String info
protected boolean localDataSource
protected static final java.lang.String name
protected java.lang.String roleNameCol
protected static final StringManager sm
protected java.lang.String userCredCol
protected java.lang.String userNameCol
protected java.lang.String userRoleTable
protected java.lang.String userTable
| Constructor Detail | 
|---|
public DataSourceRealm()
| Method Detail | 
|---|
public java.lang.String getDataSourceName()
public void setDataSourceName(java.lang.String dataSourceName)
dataSourceName - the name of the JNDI JDBC DataSourcepublic boolean getLocalDataSource()
public void setLocalDataSource(boolean localDataSource)
localDataSource - the new flag valuepublic java.lang.String getRoleNameCol()
public void setRoleNameCol(java.lang.String roleNameCol)
roleNameCol - The column namepublic java.lang.String getUserCredCol()
public void setUserCredCol(java.lang.String userCredCol)
userCredCol - The column namepublic java.lang.String getUserNameCol()
public void setUserNameCol(java.lang.String userNameCol)
userNameCol - The column namepublic java.lang.String getUserRoleTable()
public void setUserRoleTable(java.lang.String userRoleTable)
userRoleTable - The table namepublic java.lang.String getUserTable()
public void setUserTable(java.lang.String userTable)
userTable - The table namepublic java.lang.String getInfo()
<description>/<version>.
getInfo in interface RealmgetInfo in class RealmBase
public java.security.Principal authenticate(java.lang.String username,
                                            java.lang.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.
authenticate in interface Realmauthenticate in class RealmBaseusername - Username of the Principal to look upcredentials - Password or other credentials to use in
  authenticating this username
protected java.security.Principal authenticate(java.sql.Connection dbConnection,
                                               java.lang.String username,
                                               java.lang.String credentials)
null.
dbConnection - The database connection to be usedusername - Username of the Principal to look upcredentials - Password or other credentials to use in
  authenticating this usernameprotected void close(java.sql.Connection dbConnection)
dbConnection - The connection to be closedprotected java.sql.Connection open()
protected java.lang.String getName()
getName in class RealmBaseprotected java.lang.String getPassword(java.lang.String username)
getPassword in class RealmBase
protected java.lang.String getPassword(java.sql.Connection dbConnection,
                                       java.lang.String username)
dbConnection - The database connection to be usedusername - Username for which password should be retrievedprotected java.security.Principal getPrincipal(java.lang.String username)
getPrincipal in class RealmBaseprotected java.util.ArrayList getRoles(java.lang.String username)
username - Username for which roles should be retrieved
protected java.util.ArrayList<java.lang.String> getRoles(java.sql.Connection dbConnection,
                                                         java.lang.String username)
dbConnection - The database connection to be usedusername - Username for which roles should be retrieved
public void start()
           throws LifecycleException
start in interface Lifecyclestart in class RealmBaseLifecycleException - if this component detects a fatal error
  that prevents it from being started
public void stop()
          throws LifecycleException
stop in interface Lifecyclestop in class RealmBaseLifecycleException - if this component detects a fatal error
  that needs to be reported| 
 | Apache Tomcat 6.0.53 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||