public class DataSourceRealm extends RealmBase
RealmBase.AllRolesMode
Lifecycle.SingleUse
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
dataSourceName
The name of the JNDI JDBC DataSource
|
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 java.lang.String |
userCredCol
The column in the user table that holds the user's credentials
|
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.
|
allRolesMode, container, containerLog, digest, digestEncoding, md, md5Helper, realmPath, sm, stripRealmForGss, support, validate, x509UsernameRetriever, x509UsernameRetrieverClassName
mserver
AFTER_DESTROY_EVENT, AFTER_INIT_EVENT, AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_DESTROY_EVENT, BEFORE_INIT_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, CONFIGURE_START_EVENT, CONFIGURE_STOP_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT
Constructor and Description |
---|
DataSourceRealm() |
Modifier and Type | Method and Description |
---|---|
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() |
boolean |
getLocalDataSource() |
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)
Get the password for the specified user.
|
protected java.security.Principal |
getPrincipal(java.lang.String username)
Return the Principal associated with the given user name.
|
java.lang.String |
getRoleNameCol() |
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<java.lang.String> |
getRoles(java.lang.String username)
Return the roles associated with the given user name.
|
java.lang.String |
getUserCredCol() |
java.lang.String |
getUserNameCol() |
java.lang.String |
getUserRoleTable() |
java.lang.String |
getUserTable() |
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.
|
protected void |
startInternal()
Prepare for the beginning of active use of the public methods of this
component and implement the requirements of
LifecycleBase.startInternal() . |
addPropertyChangeListener, authenticate, authenticate, authenticate, authenticate, backgroundProcess, compareCredentials, digest, Digest, findSecurityConstraints, getAllRolesMode, getContainer, getCredentialHandler, getDigest, getDigest, getDigestCharset, getDigestEncoding, getDomainInternal, getObjectNameKeyProperties, getPrincipal, getPrincipal, getRealmPath, getRealmSuffix, getServer, getTransportGuaranteeRedirectStatus, getValidate, getX509UsernameRetrieverClassName, hasMessageDigest, hasResourcePermission, hasRole, hasUserDataPermission, initInternal, isStripRealmForGss, main, removePropertyChangeListener, setAllRolesMode, setContainer, setCredentialHandler, setDigest, setDigestEncoding, setRealmPath, setStripRealmForGss, setTransportGuaranteeRedirectStatus, setValidate, setX509UsernameRetrieverClassName, stopInternal, toString
destroyInternal, getDomain, getObjectName, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregister
addLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, init, removeLifecycleListener, setState, setState, start, stop
protected java.lang.String dataSourceName
protected boolean localDataSource
protected static final java.lang.String name
protected java.lang.String roleNameCol
protected java.lang.String userCredCol
protected java.lang.String userNameCol
protected java.lang.String userRoleTable
protected java.lang.String userTable
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.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 Realm
authenticate
in class RealmBase
username
- Username of the Principal to look upcredentials
- Password or other credentials to use in
authenticating this usernamenull
if there is none.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 usernamenull
if there is none.protected void close(java.sql.Connection dbConnection)
dbConnection
- The connection to be closedprotected java.sql.Connection open()
protected java.lang.String getName()
protected java.lang.String getPassword(java.lang.String username)
RealmBase
getPassword
in class RealmBase
username
- The user nameprotected 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 RealmBase
username
- the user nameprotected java.util.ArrayList<java.lang.String> getRoles(java.lang.String username)
username
- User name for which roles should be retrievedprotected java.util.ArrayList<java.lang.String> getRoles(java.sql.Connection dbConnection, java.lang.String username)
dbConnection
- The database connection to be usedusername
- User name for which roles should be retrievedprotected void startInternal() throws LifecycleException
LifecycleBase.startInternal()
.startInternal
in class RealmBase
LifecycleException
- if this component detects a fatal error
that prevents this component from being usedCopyright © 2000-2018 Apache Software Foundation. All Rights Reserved.