public class JDBCLoginService extends MappedLoginService
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 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.JDBCKnownUser
JDBCKnownUser
|
MappedLoginService.Anonymous, MappedLoginService.KnownUser, MappedLoginService.RolePrincipal, MappedLoginService.UserPrincipal
AbstractLifeCycle.AbstractLifeCycleListener
LifeCycle.Listener
Modifier and Type | Field and Description |
---|---|
protected int |
_cacheTime |
protected Connection |
_con |
protected String |
_config |
protected String |
_jdbcDriver |
protected long |
_lastHashPurge |
protected String |
_password |
protected String |
_roleSql |
protected String |
_roleTableRoleField |
protected String |
_url |
protected String |
_userName |
protected String |
_userSql |
protected String |
_userTableKey |
protected String |
_userTablePasswordField |
_identityService, _name, _users
Constructor and Description |
---|
JDBCLoginService() |
JDBCLoginService(String name) |
JDBCLoginService(String name,
IdentityService identityService,
String config) |
JDBCLoginService(String name,
String config) |
Modifier and Type | Method and Description |
---|---|
void |
connectDatabase()
(re)Connect to database with parameters setup by loadConfig()
|
protected void |
doStart() |
String |
getConfig() |
String[] |
loadRoleInfo(MappedLoginService.KnownUser user) |
protected UserIdentity |
loadUser(String username)
Deprecated.
|
MappedLoginService.KnownUser |
loadUserInfo(String username) |
protected void |
loadUsers() |
UserIdentity |
login(String username,
Object credentials,
ServletRequest request)
Login a user.
|
void |
setConfig(String config)
Load JDBC connection configuration from properties file.
|
doStop, getIdentityService, getName, getUsers, logout, putUser, putUser, putUser, removeUser, setIdentityService, setName, setUsers, toString, validate
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, setStopTimeout, start, stop
protected String _config
protected String _jdbcDriver
protected String _url
protected String _userName
protected String _password
protected String _userTableKey
protected String _userTablePasswordField
protected String _roleTableRoleField
protected int _cacheTime
protected long _lastHashPurge
protected Connection _con
protected String _userSql
protected String _roleSql
public JDBCLoginService() throws IOException
IOException
public JDBCLoginService(String name) throws IOException
IOException
public JDBCLoginService(String name, String config) throws IOException
IOException
public JDBCLoginService(String name, IdentityService identityService, String config) throws IOException
IOException
protected void doStart() throws Exception
doStart
in class MappedLoginService
Exception
MappedLoginService.doStart()
public String getConfig()
public void setConfig(String config)
config
- Filename or url of user properties file.public void connectDatabase()
public UserIdentity login(String username, Object credentials, ServletRequest request)
LoginService
login
in interface LoginService
login
in class MappedLoginService
username
- The user namecredentials
- The users credentialsrequest
- TODOLoginService.login(java.lang.String, java.lang.Object, ServletRequest)
protected void loadUsers()
loadUsers
in class MappedLoginService
@Deprecated protected UserIdentity loadUser(String username)
loadUser
in class MappedLoginService
public MappedLoginService.KnownUser loadUserInfo(String username)
loadUserInfo
in class MappedLoginService
MappedLoginService.loadUserInfo(java.lang.String)
public String[] loadRoleInfo(MappedLoginService.KnownUser user)
loadRoleInfo
in class MappedLoginService
MappedLoginService.loadRoleInfo(org.eclipse.jetty.security.MappedLoginService.KnownUser)
Copyright © 1995-2016 Webtide. All Rights Reserved.