DataSourceRealm (Apache Tomcat 6.0.51 API Documentation)
Keywords: org.apache.catalina.realm.DataSourceRealm class

Overview | Package | Class | Tree | Deprecated | Index | Help
| Apache Tomcat 6.0.51
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.catalina.realm
Class DataSourceRealm

    java.lang.Object
      org.apache.catalina.realm.RealmBase
          org.apache.catalina.realm.DataSourceRealm

All Implemented Interfaces:
  javax.management.MBeanRegistration, Lifecycle, Realm

    public class DataSourceRealm

extends 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

Nested Class Summary

Nested classes/interfaces inherited from class org.apache.catalina.realm.RealmBase
`RealmBase.AllRolesMode`

Field Summary
`protected java.lang.String` | `dataSourceName` The name of the JNDI JDBC DataSource
`protected static java.lang.String` | `info` Descriptive information about this Realm implementation.
`protected boolean` | `localDataSource` Context local datasource.
`protected static java.lang.String` | `name` Descriptive information about this Realm implementation.
`protected java.lang.String` | `roleNameCol` The column in the user role table that names a role
`protected static StringManager` | `sm` The string manager for this package.
`protected java.lang.String` | `userCredCol` The column in the user table that holds the user's credintials
`protected java.lang.String` | `userNameCol` The column in the user table that holds the user's name
`protected java.lang.String` | `userRoleTable` The table that holds the relation between user's and roles
`protected java.lang.String` | `userTable` The 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 org.apache.catalina.realm.RealmBase
`addLifecycleListener, addPropertyChangeListener, authenticate, authenticate, authenticate, backgroundProcess, destroy, digest, Digest, findLifecycleListeners, findSecurityConstraints, getAllRolesMode, getContainer, getController, getDigest, getDigest, getDigestEncoding, getDomain, getObjectName, getPrincipal, getRealmPath, getRealmSuffix, getType, getValidate, getX509UsernameRetrieverClassName, hasMessageDigest, hasResourcePermission, hasRole, hasUserDataPermission, init, main, postDeregister, postRegister, preDeregister, preRegister, removeLifecycleListener, removePropertyChangeListener, setAllRolesMode, setContainer, setController, setDigest, setDigestEncoding, setRealmPath, setValidate, setX509UsernameRetrieverClassName`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### dataSourceName

    protected java.lang.String dataSourceName

  The name of the JNDI JDBC DataSource

### info

    protected static final java.lang.String info

  Descriptive information about this Realm implementation.

  See Also:
    Constant Field Values

### localDataSource

    protected boolean localDataSource

  Context local datasource.

### name

    protected static final java.lang.String name

  Descriptive information about this Realm implementation.

  See Also:
    Constant Field Values

### roleNameCol

    protected java.lang.String roleNameCol

  The column in the user role table that names a role

### sm

    protected static final StringManager sm

  The string manager for this package.

### userCredCol

    protected java.lang.String userCredCol

  The column in the user table that holds the user's credintials

### userNameCol

    protected java.lang.String userNameCol

  The column in the user table that holds the user's name

### userRoleTable

    protected java.lang.String userRoleTable

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

### userTable

    protected java.lang.String userTable

  The table that holds user data.

Constructor Detail

### DataSourceRealm

    public DataSourceRealm()

Method Detail

### getDataSourceName

    public java.lang.String getDataSourceName()

  Return the name of the JNDI JDBC DataSource.

### setDataSourceName

    public void setDataSourceName(java.lang.String dataSourceName)

  Set the name of the JNDI JDBC DataSource.

  Parameters:
    `dataSourceName` - the name of the JNDI JDBC DataSource

### getLocalDataSource

    public boolean getLocalDataSource()

  Return if the datasource will be looked up in the webapp JNDI Context.

### setLocalDataSource

    public void setLocalDataSource(boolean localDataSource)

  Set to true to cause the datasource to be looked up in the webapp JNDI Context.

  Parameters:
    `localDataSource` - the new flag value

### getRoleNameCol

    public java.lang.String getRoleNameCol()

  Return the column in the user role table that names a role.

### setRoleNameCol

    public void setRoleNameCol(java.lang.String roleNameCol)

  Set the column in the user role table that names a role.

  Parameters:
    `roleNameCol` - The column name

### getUserCredCol

    public java.lang.String getUserCredCol()

  Return the column in the user table that holds the user's credentials.

### setUserCredCol

    public void setUserCredCol(java.lang.String userCredCol)

  Set the column in the user table that holds the user's credentials.

  Parameters:
    `userCredCol` - The column name

### getUserNameCol

    public java.lang.String getUserNameCol()

  Return the column in the user table that holds the user's name.

### setUserNameCol

    public void setUserNameCol(java.lang.String userNameCol)

  Set the column in the user table that holds the user's name.

  Parameters:
    `userNameCol` - The column name

### getUserRoleTable

    public java.lang.String getUserRoleTable()

  Return the table that holds the relation between user's and roles.

### setUserRoleTable

    public void setUserRoleTable(java.lang.String userRoleTable)

  Set the table that holds the relation between user's and roles.

  Parameters:
    `userRoleTable` - The table name

### getUserTable

    public java.lang.String getUserTable()

  Return the table that holds user data..

### setUserTable

    public void setUserTable(java.lang.String userTable)

  Set the table that holds user data.

  Parameters:
    `userTable` - The table name

### getInfo

    public java.lang.String getInfo()

  Return descriptive information about this Realm implementation and the corresponding version number, in the format `<description>/<version>`.

  Specified by:
    `getInfo` in interface `Realm`
  Overrides:
    `getInfo` in class `RealmBase`

### authenticate

    public 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`. 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.

  Specified by:
    `authenticate` in interface `Realm`
  Overrides:
    `authenticate` in class `RealmBase`
  Parameters:
    `username` - Username of the Principal to look up
    `credentials` - Password or other credentials to use in authenticating this username

### authenticate

    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`.

  Parameters:
    `dbConnection` - The database connection to be used
    `username` - Username of the Principal to look up
    `credentials` - Password or other credentials to use in authenticating this username

### close

    protected void close(java.sql.Connection dbConnection)

  Close the specified database connection.

  Parameters:
    `dbConnection` - The connection to be closed

### open

    protected java.sql.Connection open()

  Open the specified database connection.

  Returns:
    Connection to the database

### getName

    protected java.lang.String getName()

  Return a short name for this Realm implementation.

  Specified by:
    `getName` in class `RealmBase`

### getPassword

    protected java.lang.String getPassword(java.lang.String username)

  Return the password associated with the given principal's user name.

  Specified by:
    `getPassword` in class `RealmBase`

### getPassword

    protected java.lang.String getPassword(java.sql.Connection dbConnection,
                                           java.lang.String username)

  Return the password associated with the given principal's user name.

  Parameters:
    `dbConnection` - The database connection to be used
    `username` - Username for which password should be retrieved

### getPrincipal

    protected java.security.Principal getPrincipal(java.lang.String username)

  Return the Principal associated with the given user name.

  Specified by:
    `getPrincipal` in class `RealmBase`

### getRoles

    protected java.util.ArrayList getRoles(java.lang.String username)

  Return the roles associated with the given user name.

  Parameters:
    `username` - Username for which roles should be retrieved

### getRoles

    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

  Parameters:
    `dbConnection` - The database connection to be used
    `username` - Username for which roles should be retrieved

### start

    public void start()
               throws LifecycleException

  Prepare for active use of the public methods of this Component.

  Specified by:
    `start` in interface `Lifecycle`
  Overrides:
    `start` in class `RealmBase`
  Throws:
    `LifecycleException` - if this component detects a fatal error that prevents it from being started

### stop

    public void stop()
              throws LifecycleException

  Gracefully shut down active use of the public methods of this Component.

  Specified by:
    `stop` in interface `Lifecycle`
  Overrides:
    `stop` in class `RealmBase`
  Throws:
    `LifecycleException` - if this component detects a fatal error that needs to be reported

Overview | Package | Class | Tree | Deprecated | Index | Help
| Apache Tomcat 6.0.51
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.