org.eclipse.jetty.security
Class JDBCLoginService
java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.security.MappedLoginService
org.eclipse.jetty.security.JDBCLoginService
- All Implemented Interfaces:
- LoginService, LifeCycle
public class JDBCLoginService
- extends MappedLoginService
HashMapped User Realm with JDBC as data source. JDBCLoginService extends
HashULoginService and adds a method to fetch user information from database.
The login() 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() 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. authenticate() is 'synchronized'.
An example properties file for configuration is in
$JETTY_HOME/etc/jdbcRealm.properties
- Version:
- $Id: JDBCLoginService.java 4792 2009-03-18 21:55:52Z gregw $
Methods inherited from class org.eclipse.jetty.security.MappedLoginService |
doStop, getIdentityService, getName, getUsers, putUser, putUser, removeUser, setIdentityService, setName, setUsers, toString, validate |
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle |
addLifeCycleListener, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop |
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
doStart
protected void doStart()
throws Exception
- Overrides:
doStart
in class MappedLoginService
- Throws:
Exception
- See Also:
MappedLoginService.doStart()
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()
login
public UserIdentity login(String username,
Object credentials)
- Description copied from interface:
LoginService
- Login a user.
- Specified by:
login
in interface LoginService
- Overrides:
login
in class MappedLoginService
- Parameters:
username
- The user namecredentials
- The users credentials
- Returns:
- A UserIdentity if the credentials matched, otherwise null
- See Also:
LoginService.login(java.lang.String, java.lang.Object)
loadUsers
protected void loadUsers()
- Specified by:
loadUsers
in class MappedLoginService
loadUser
protected UserIdentity loadUser(String username)
- Specified by:
loadUser
in class MappedLoginService
Copyright © 1995-2010 Mort Bay Consulting. All Rights Reserved.