Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
org.apache.catalina.realm.RealmBase
org.apache.catalina.realm.JDBCRealm
public class JDBCRealm
extends RealmBase
authenticate()
does not have to be
synchronized and would fix the ugly connection logic.
Field Summary | |
protected String |
|
protected String |
|
protected String |
|
protected Connection |
|
protected Driver |
|
protected String |
|
protected static String |
|
protected static String |
|
protected PreparedStatement |
|
protected PreparedStatement |
|
protected String |
|
protected static StringManager |
|
protected String |
|
protected String |
|
protected String |
|
protected String |
|
Fields inherited from class org.apache.catalina.realm.RealmBase | |
container , controller , debug , digest , digestEncoding , domain , host , info , initialized , lifecycle , md , md5Encoder , md5Helper , mserver , oname , path , sm , started , support , type , 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 |
Method Summary | |
Principal |
|
Principal |
|
protected void |
|
protected PreparedStatement |
|
String |
|
String |
|
String |
|
String |
|
protected String |
|
protected String |
|
protected Principal |
|
String |
|
String |
|
String |
|
String |
|
String |
|
protected Connection |
|
protected void |
|
protected PreparedStatement |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
Methods inherited from class org.apache.catalina.realm.RealmBase | |
Digest , addLifecycleListener , addPropertyChangeListener , authenticate , authenticate , authenticate , authenticate , destroy , digest , findLifecycleListeners , findSecurityConstraints , getContainer , getController , getDebug , getDigest , getDigest , getDigestEncoding , getDomain , getInfo , getName , getObjectName , getPassword , getPrincipal , getType , getValidate , hasMessageDigest , hasResourcePermission , hasRole , hasUserDataPermission , init , log , log , main , postDeregister , postRegister , preDeregister , preRegister , removeLifecycleListener , removePropertyChangeListener , setContainer , setController , setDebug , setDigest , setDigestEncoding , setValidate , start , stop |
protected String connectionName
The connection username to use when trying to connect to the database.
protected String connectionPassword
The connection URL to use when trying to connect to the database.
protected String connectionURL
The connection URL to use when trying to connect to the database.
protected Connection dbConnection
The connection to the database.
protected Driver driver
Instance of the JDBC Driver class we use as a connection factory.
protected String driverName
The JDBC driver to use.
protected static final String info
Descriptive information about this Realm implementation.
protected static final String name
Descriptive information about this Realm implementation.
protected PreparedStatement preparedCredentials
The PreparedStatement to use for authenticating users.
protected PreparedStatement preparedRoles
The PreparedStatement to use for identifying the roles for a specified user.
protected String roleNameCol
The column in the user role table that names a role
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.
public Principal authenticate(Connection dbConnection, String username, String credentials) throws SQLException
Return the Principal associated with the specified username and credentials, if there is one; otherwise returnnull
.
- Parameters:
dbConnection
- The database connection to be usedusername
- Username of the Principal to look upcredentials
- Password or other credentials to use in authenticating this username
public Principal authenticate(String username, String credentials)
Return the Principal associated with the specified username and credentials, if there is one; otherwise returnnull
. 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 interface RealmBase
- Parameters:
username
- Username of the Principal to look upcredentials
- Password or other credentials to use in authenticating this username
protected void close(Connection dbConnection)
Close the specified database connection.
- Parameters:
dbConnection
- The connection to be closed
protected PreparedStatement credentials(Connection dbConnection, String username) throws SQLException
Return a PreparedStatement configured to perform the SELECT required to retrieve user credentials for the specified username.
- Parameters:
dbConnection
- The database connection to be usedusername
- Username for which credentials should be retrieved
public String getConnectionName()
Return the username to use to connect to the database.
public String getConnectionPassword()
Return the password to use to connect to the database.
public String getConnectionURL()
Return the URL to use to connect to the database.
public String getDriverName()
Return the JDBC driver that will be used.
protected String getName()
Return a short name for this Realm implementation.
- Overrides:
- getName in interface RealmBase
protected String getPassword(String username)
Return the password associated with the given principal's user name.
- Overrides:
- getPassword in interface RealmBase
protected Principal getPrincipal(String username)
Return the Principal associated with the given user name.
- Overrides:
- getPrincipal in interface RealmBase
public String getRoleNameCol()
Return the column in the user role table that names a role.
public String getUserCredCol()
Return the column in the user table that holds the user's credentials.
public String getUserNameCol()
Return the column in the user table that holds the user's name.
public String getUserRoleTable()
Return the table that holds the relation between user's and roles.
public String getUserTable()
Return the table that holds user data..
protected Connection open() throws SQLException
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.
- Parameters:
dbConnection
- The connection to be released
protected PreparedStatement roles(Connection dbConnection, String username) throws SQLException
Return a PreparedStatement configured to perform the SELECT required to retrieve user roles for the specified username.
- Parameters:
dbConnection
- The database connection to be usedusername
- Username for which roles should be retrieved
public void setConnectionName(String connectionName)
Set the username to use to connect to the database.
- Parameters:
connectionName
- Username
public void setConnectionPassword(String connectionPassword)
Set the password to use to connect to the database.
- Parameters:
connectionPassword
- User password
public void setConnectionURL(String connectionURL)
Set the URL to use to connect to the database.
- Parameters:
connectionURL
- The new connection URL
public void setDriverName(String driverName)
Set the JDBC driver that will be used.
- Parameters:
driverName
- The driver name
public void setRoleNameCol(String roleNameCol)
Set the column in the user role table that names a role.
- Parameters:
roleNameCol
- The column name
public void setUserCredCol(String userCredCol)
Set the column in the user table that holds the user's credentials.
- Parameters:
userCredCol
- The column name
public void setUserNameCol(String userNameCol)
Set the column in the user table that holds the user's name.
- Parameters:
userNameCol
- The column name
public void setUserRoleTable(String userRoleTable)
Set the table that holds the relation between user's and roles.
- Parameters:
userRoleTable
- The table name
public void setUserTable(String userTable)
Set the table that holds user data.
- Parameters:
userTable
- The table name
public void start() throws LifecycleException
Prepare for active use of the public methods of this Component.
- Overrides:
- start in interface RealmBase
- Throws:
LifecycleException
- if this component detects a fatal error that prevents it from being started
public void stop() throws LifecycleException
Gracefully shut down active use of the public methods of this Component.
- Overrides:
- stop in interface RealmBase
- Throws:
LifecycleException
- if this component detects a fatal error that needs to be reported