Package org.eclipse.jetty.security
Class JDBCLoginService
- java.lang.Object
-
- org.eclipse.jetty.util.component.AbstractLifeCycle
-
- org.eclipse.jetty.security.AbstractLoginService
-
- org.eclipse.jetty.security.JDBCLoginService
-
- All Implemented Interfaces:
LoginService,org.eclipse.jetty.util.component.LifeCycle
public class JDBCLoginService extends AbstractLoginService
HashMapped User Realm with JDBC as data source. TheAbstractLoginService.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 superclassAbstractLoginService.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classJDBCLoginService.JDBCUserPrincipalJDBCKnownUser-
Nested classes/interfaces inherited from class org.eclipse.jetty.security.AbstractLoginService
AbstractLoginService.RolePrincipal, AbstractLoginService.UserPrincipal
-
-
Field Summary
Fields Modifier and Type Field Description protected Connection_conprotected String_configprotected String_jdbcDriverprotected String_passwordprotected String_roleSqlprotected String_roleTableRoleFieldprotected String_urlprotected String_userNameprotected String_userSqlprotected String_userTableKeyprotected String_userTablePasswordField-
Fields inherited from class org.eclipse.jetty.security.AbstractLoginService
_fullValidate, _identityService, _name
-
-
Constructor Summary
Constructors Constructor Description JDBCLoginService()JDBCLoginService(String name)JDBCLoginService(String name, String config)JDBCLoginService(String name, IdentityService identityService, String config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconnectDatabase()(re)Connect to database with parameters setup by loadConfig()protected voiddoStart()protected voiddoStop()StringgetConfig()String[]loadRoleInfo(AbstractLoginService.UserPrincipal user)AbstractLoginService.UserPrincipalloadUserInfo(String username)voidsetConfig(String config)Load JDBC connection configuration from properties file.-
Methods inherited from class org.eclipse.jetty.security.AbstractLoginService
getIdentityService, getName, isFullValidate, login, logout, setFullValidate, setIdentityService, setName, toString, validate
-
-
-
-
Field Detail
-
_config
protected String _config
-
_jdbcDriver
protected String _jdbcDriver
-
_url
protected String _url
-
_userName
protected String _userName
-
_password
protected String _password
-
_userTableKey
protected String _userTableKey
-
_userTablePasswordField
protected String _userTablePasswordField
-
_roleTableRoleField
protected String _roleTableRoleField
-
_con
protected Connection _con
-
_userSql
protected String _userSql
-
_roleSql
protected String _roleSql
-
-
Constructor Detail
-
JDBCLoginService
public JDBCLoginService() throws IOException- Throws:
IOException
-
JDBCLoginService
public JDBCLoginService(String name) throws IOException
- Throws:
IOException
-
JDBCLoginService
public JDBCLoginService(String name, String config) throws IOException
- Throws:
IOException
-
JDBCLoginService
public JDBCLoginService(String name, IdentityService identityService, String config) throws IOException
- Throws:
IOException
-
-
Method Detail
-
doStart
protected void doStart() throws Exception- Overrides:
doStartin classorg.eclipse.jetty.util.component.AbstractLifeCycle- Throws:
Exception
-
getConfig
public String getConfig()
-
setConfig
public void setConfig(String config)
Load JDBC connection configuration from properties file.- Parameters:
config- Filename or url of user properties file.
-
connectDatabase
public void connectDatabase()
(re)Connect to database with parameters setup by loadConfig()
-
loadUserInfo
public AbstractLoginService.UserPrincipal loadUserInfo(String username)
- Specified by:
loadUserInfoin classAbstractLoginService
-
loadRoleInfo
public String[] loadRoleInfo(AbstractLoginService.UserPrincipal user)
- Specified by:
loadRoleInfoin classAbstractLoginService
-
-