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

Constructor Summary
JDBCUserRealm(String name)
Constructor.
JDBCUserRealm(String name, String config)
Constructor.
Method Summary
Principalauthenticate(String username, Object credentials, HttpRequest request)
voidconnectDatabase()
(re)Connect to database with parameters setup by loadConfig()
voidloadConfig(String config)
Load JDBC connection configuration from properties file.
voidlogout(Principal user)

Constructor Detail

JDBCUserRealm

public JDBCUserRealm(String name)
Constructor.

Parameters: name

JDBCUserRealm

public JDBCUserRealm(String name, String config)
Constructor.

Parameters: name Realm name config Filename or url of JDBC connection properties file.

Throws: IOException ClassNotFoundException

Method Detail

authenticate

public Principal authenticate(String username, Object credentials, HttpRequest request)

connectDatabase

public void connectDatabase()
(re)Connect to database with parameters setup by loadConfig()

loadConfig

public void loadConfig(String config)
Load JDBC connection configuration from properties file.

Parameters: config Filename or url of user properties file.

Throws: IOException

logout

public void logout(Principal user)
Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.