public class JDBCLoginService extends AbstractLoginService
AbstractLoginService.login(String, Object, ServletRequest)
method checks the inherited Map for the user. If the user is not
found, it will fetch details from the database and populate the inherited
Map. It then calls the superclass AbstractLoginService.login(String, Object, ServletRequest)
method to perform the actual
authentication. Periodically (controlled by configuration parameter),
internal hashes are cleared. Caching can be disabled by setting cache refresh
interval to zero. Uses one database connection that is initialized at
startup. Reconnect on failures.
An example properties file for configuration is in
${jetty.home}/etc/jdbcRealm.properties
Modifier and Type | Class and Description |
---|---|
class |
JDBCLoginService.JDBCUserPrincipal
JDBCKnownUser
|
AbstractLoginService.RolePrincipal, AbstractLoginService.UserPrincipal
AbstractLifeCycle.AbstractLifeCycleListener
Container.InheritedListener, Container.Listener
LifeCycle.Listener
Modifier and Type | Field and Description |
---|---|
protected java.sql.Connection |
_con |
protected java.lang.String |
_config |
protected java.lang.String |
_jdbcDriver |
protected java.lang.String |
_password |
protected java.lang.String |
_roleSql |
protected java.lang.String |
_roleTableRoleField |
protected java.lang.String |
_url |
protected java.lang.String |
_userName |
protected java.lang.String |
_userSql |
protected java.lang.String |
_userTableKey |
protected java.lang.String |
_userTablePasswordField |
private static Logger |
LOG |
_fullValidate, _identityService, _name
Constructor and Description |
---|
JDBCLoginService() |
JDBCLoginService(java.lang.String name) |
JDBCLoginService(java.lang.String name,
IdentityService identityService,
java.lang.String config) |
JDBCLoginService(java.lang.String name,
java.lang.String config) |
Modifier and Type | Method and Description |
---|---|
private void |
closeConnection()
Close an existing connection
|
void |
connectDatabase()
(re)Connect to database with parameters setup by loadConfig()
|
protected void |
doStart()
Starts the managed lifecycle beans in the order they were added.
|
protected void |
doStop()
Stops the managed lifecycle beans in the reverse order they were added.
|
java.lang.String |
getConfig() |
java.lang.String[] |
loadRoleInfo(AbstractLoginService.UserPrincipal user) |
AbstractLoginService.UserPrincipal |
loadUserInfo(java.lang.String username) |
void |
setConfig(java.lang.String config)
Load JDBC connection configuration from properties file.
|
getIdentityService, getName, isFullValidate, login, logout, setFullValidate, setIdentityService, setName, toString, validate
addBean, addBean, addEventListener, addManaged, contains, destroy, dump, dump, dump, dump, dump, dumpBeans, dumpObject, dumpObjects, dumpStdErr, dumpThis, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBean, updateBeans
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
dumpContainer, dumpIterable, dumpMapEntries, dumpObjects, dumpSelf, named
private static final Logger LOG
protected java.lang.String _config
protected java.lang.String _jdbcDriver
protected java.lang.String _url
protected java.lang.String _userName
protected java.lang.String _password
protected java.lang.String _userTableKey
protected java.lang.String _userTablePasswordField
protected java.lang.String _roleTableRoleField
protected java.sql.Connection _con
protected java.lang.String _userSql
protected java.lang.String _roleSql
public JDBCLoginService() throws java.io.IOException
java.io.IOException
public JDBCLoginService(java.lang.String name) throws java.io.IOException
java.io.IOException
public JDBCLoginService(java.lang.String name, java.lang.String config) throws java.io.IOException
java.io.IOException
public JDBCLoginService(java.lang.String name, IdentityService identityService, java.lang.String config) throws java.io.IOException
java.io.IOException
protected void doStart() throws java.lang.Exception
ContainerLifeCycle
doStart
in class ContainerLifeCycle
java.lang.Exception
public java.lang.String getConfig()
public void setConfig(java.lang.String config)
config
- Filename or url of user properties file.public void connectDatabase()
public AbstractLoginService.UserPrincipal loadUserInfo(java.lang.String username)
loadUserInfo
in class AbstractLoginService
public java.lang.String[] loadRoleInfo(AbstractLoginService.UserPrincipal user)
loadRoleInfo
in class AbstractLoginService
protected void doStop() throws java.lang.Exception
ContainerLifeCycle
doStop
in class ContainerLifeCycle
java.lang.Exception
AbstractLifeCycle.doStop()
private void closeConnection()