org.mortbay.http
Class JDBCUserRealm
public
class
JDBCUserRealm
extends HashUserRealm
HashMapped User Realm with JDBC as data source.
JDBCUserRealm extends HashUserRealm and adds a method to fetch user
information from database.
The authenticate() method checks the inherited HashMap for the user.
If the user is not found, it will fetch details from the database
and populate the inherited HashMap. It then calls the HashUserRealm
authenticate() 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: JDBCUserRealm.java,v 1.20 2006/04/05 12:59:16 janb Exp $
Author: Arkadi Shishlov (arkadi) Fredrik Borgh Greg Wilkins (gregw) Ben Alex
public JDBCUserRealm(String name)
Constructor.
Parameters: name
public JDBCUserRealm(String name, String config)
Constructor.
Parameters: name Realm name config Filename or url of JDBC connection properties file.
Throws: IOException ClassNotFoundException
public Principal authenticate(String username, Object credentials,
HttpRequest request)
public void connectDatabase()
(re)Connect to database with parameters setup by loadConfig()
public void loadConfig(String config)
Load JDBC connection configuration from properties file.
Parameters: config Filename or url of user properties file.
Throws: IOException
public void logout(Principal user)
Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.