Package org.eclipse.jetty.security
Class JDBCLoginService
java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.ContainerLifeCycle
org.eclipse.jetty.security.AbstractLoginService
org.eclipse.jetty.security.JDBCLoginService
- All Implemented Interfaces:
LoginService,org.eclipse.jetty.util.component.Container,org.eclipse.jetty.util.component.Destroyable,org.eclipse.jetty.util.component.Dumpable,org.eclipse.jetty.util.component.Dumpable.DumpableContainer,org.eclipse.jetty.util.component.LifeCycle
HashMapped User Realm with JDBC as data source.
The
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
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.eclipse.jetty.security.AbstractLoginService
AbstractLoginService.RolePrincipal, AbstractLoginService.UserPrincipalNested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListenerNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
org.eclipse.jetty.util.component.Container.InheritedListener, org.eclipse.jetty.util.component.Container.ListenerNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
org.eclipse.jetty.util.component.Dumpable.DumpableContainerNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
org.eclipse.jetty.util.component.LifeCycle.Listener -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Connectionprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected StringFields inherited from class org.eclipse.jetty.security.AbstractLoginService
_fullValidate, _identityService, _nameFields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPINGFields inherited from interface org.eclipse.jetty.util.component.Dumpable
KEY -
Constructor Summary
ConstructorsConstructorDescriptionJDBCLoginService(String name) JDBCLoginService(String name, String config) JDBCLoginService(String name, IdentityService identityService, String config) -
Method Summary
Modifier and TypeMethodDescriptionvoid(re)Connect to database with parameters setup by loadConfig()protected voiddoStart()protected voiddoStop()String[]loadUserInfo(String username) voidLoad JDBC connection configuration from properties file.Methods inherited from class org.eclipse.jetty.security.AbstractLoginService
getIdentityService, getName, isFullValidate, login, logout, setFullValidate, setIdentityService, setName, toString, validateMethods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle
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, updateBeansMethods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stopMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.jetty.util.component.Dumpable
dumpSelfMethods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer
isDumpable
-
Field Details
-
_config
-
_jdbcDriver
-
_url
-
_userName
-
_password
-
_userTableKey
-
_userTablePasswordField
-
_roleTableRoleField
-
_con
-
_userSql
-
_roleSql
-
-
Constructor Details
-
JDBCLoginService
- Throws:
IOException
-
JDBCLoginService
- Throws:
IOException
-
JDBCLoginService
- Throws:
IOException
-
JDBCLoginService
public JDBCLoginService(String name, IdentityService identityService, String config) throws IOException - Throws:
IOException
-
-
Method Details
-
doStart
- Overrides:
doStartin classorg.eclipse.jetty.util.component.ContainerLifeCycle- Throws:
Exception
-
getConfig
-
setConfig
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
- Specified by:
loadUserInfoin classAbstractLoginService
-
loadRoleInfo
- Specified by:
loadRoleInfoin classAbstractLoginService
-
doStop
- Overrides:
doStopin classorg.eclipse.jetty.util.component.ContainerLifeCycle- Throws:
Exception- See Also:
-
AbstractLifeCycle.doStop()
-