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
| 限定符和类型 | 类和说明 |
|---|---|
class |
JDBCLoginService.JDBCUserPrincipal
JDBCKnownUser
|
AbstractLoginService.RolePrincipal, AbstractLoginService.UserPrincipal| 限定符和类型 | 字段和说明 |
|---|---|
protected Connection |
_con |
protected String |
_config |
protected String |
_jdbcDriver |
protected String |
_password |
protected String |
_roleSql |
protected String |
_roleTableRoleField |
protected String |
_url |
protected String |
_userName |
protected String |
_userSql |
protected String |
_userTableKey |
protected String |
_userTablePasswordField |
_fullValidate, _identityService, _name| 构造器和说明 |
|---|
JDBCLoginService() |
JDBCLoginService(String name) |
JDBCLoginService(String name,
IdentityService identityService,
String config) |
JDBCLoginService(String name,
String config) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
connectDatabase()
(re)Connect to database with parameters setup by loadConfig()
|
protected void |
doStart() |
protected void |
doStop() |
String |
getConfig() |
String[] |
loadRoleInfo(AbstractLoginService.UserPrincipal user) |
AbstractLoginService.UserPrincipal |
loadUserInfo(String username) |
void |
setConfig(String config)
Load JDBC connection configuration from properties file.
|
getIdentityService, getName, isFullValidate, login, logout, setFullValidate, setIdentityService, setName, toString, validateprotected String _config
protected String _jdbcDriver
protected String _url
protected String _userName
protected String _password
protected String _userTableKey
protected String _userTablePasswordField
protected String _roleTableRoleField
protected Connection _con
protected String _userSql
protected String _roleSql
public JDBCLoginService()
throws IOException
IOExceptionpublic JDBCLoginService(String name) throws IOException
IOExceptionpublic JDBCLoginService(String name, String config) throws IOException
IOExceptionpublic JDBCLoginService(String name, IdentityService identityService, String config) throws IOException
IOExceptionprotected void doStart()
throws Exception
doStart 在类中 org.eclipse.jetty.util.component.AbstractLifeCycleExceptionpublic String getConfig()
public void setConfig(String config)
config - Filename or url of user properties file.public void connectDatabase()
public AbstractLoginService.UserPrincipal loadUserInfo(String username)
loadUserInfo 在类中 AbstractLoginServicepublic String[] loadRoleInfo(AbstractLoginService.UserPrincipal user)
loadRoleInfo 在类中 AbstractLoginServiceCopyright © 2017. All rights reserved.