org.openqa.jetty.http
Class JDBCUserRealm
java.lang.Object
   java.util.AbstractMap<K,V>
java.util.AbstractMap<K,V>
       java.util.HashMap
java.util.HashMap
           org.openqa.jetty.http.HashUserRealm
org.openqa.jetty.http.HashUserRealm
               org.openqa.jetty.http.JDBCUserRealm
org.openqa.jetty.http.JDBCUserRealm
- All Implemented Interfaces: 
- java.io.Externalizable, java.io.Serializable, java.lang.Cloneable, java.util.Map, SSORealm, UserRealm
- 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
- See Also:
- Serialized Form
 
| Nested classes/interfaces inherited from class java.util.AbstractMap | 
| java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V> | 
 
 
 
| Constructor Summary | 
| JDBCUserRealm(java.lang.String name)Constructor.
 | 
| JDBCUserRealm(java.lang.String name,
              java.lang.String config)Constructor.
 | 
 
| Method Summary | 
|  java.security.Principal | authenticate(java.lang.String username,
             java.lang.Object credentials,
             HttpRequest request)Authenticate a users credentials.
 | 
|  void | connectDatabase()(re)Connect to database with parameters setup by loadConfig()
 | 
|  void | loadConfig(java.lang.String config)Load JDBC connection configuration from properties file.
 | 
|  void | logout(java.security.Principal user)logout a user Principal.
 | 
 
| Methods inherited from class org.openqa.jetty.http.HashUserRealm | 
| addUserToRole, clearSingleSignOn, disassociate, dump, getName, getPrincipal, getSingleSignOn, getSSORealm, isUserInRole, load, popRole, pushRole, put, readExternal, reauthenticate, setName, setSingleSignOn, setSSORealm, toString, writeExternal | 
 
| Methods inherited from class java.util.HashMap | 
| clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, putAll, remove, size, values | 
 
| Methods inherited from class java.util.AbstractMap | 
| equals, hashCode | 
 
| Methods inherited from class java.lang.Object | 
| finalize, getClass, notify, notifyAll, wait, wait, wait | 
 
| Methods inherited from interface java.util.Map | 
| equals, hashCode | 
 
JDBCUserRealm
public JDBCUserRealm(java.lang.String name)
- Constructor.
 
- Parameters:
- name-
 
JDBCUserRealm
public JDBCUserRealm(java.lang.String name,
                     java.lang.String config)
              throws java.io.IOException,
                     java.lang.ClassNotFoundException,
                     java.lang.InstantiationException,
                     java.lang.IllegalAccessException
- Constructor.
 
- Parameters:
- name- Realm name
- config- Filename or url of JDBC connection properties file.
- Throws:
- java.io.IOException
- java.lang.ClassNotFoundException
- java.lang.InstantiationException
- java.lang.IllegalAccessException
 
loadConfig
public void loadConfig(java.lang.String config)
                throws java.io.IOException
- Load JDBC connection configuration from properties file.
 
- 
- Parameters:
- config- Filename or url of user properties file.
- Throws:
- java.io.IOException
 
logout
public void logout(java.security.Principal user)
- Description copied from interface: UserRealm
- logout a user Principal.
 Called by authentication mechanisms (eg FORM) that can detect logout.
 
- 
- Specified by:
- logoutin interface- UserRealm
- Overrides:
- logoutin class- HashUserRealm
 
- 
- Parameters:
- user- A Principal previously returned from this realm
 
connectDatabase
public void connectDatabase()
- (re)Connect to database with parameters setup by loadConfig()
 
- 
 
authenticate
public java.security.Principal authenticate(java.lang.String username,
                                            java.lang.Object credentials,
                                            HttpRequest request)
- Description copied from interface: UserRealm
- Authenticate a users credentials.
 Implementations of this method may adorn the calling context to
 assoicate it with the authenticated principal (eg ThreadLocals). If
 such context associations are made, they should be considered valid
 until a UserRealm.deAuthenticate(UserPrincipal) call is made for this
 UserPrincipal.
 
- 
- Specified by:
- authenticatein interface- UserRealm
- Overrides:
- authenticatein class- HashUserRealm
 
- 
- Parameters:
- username- The username.
- credentials- The user credentials, normally a String password.
- request- The request to be authenticated. Additional
 parameters may be extracted or set on this request as needed
 for the authentication mechanism (none required for BASIC and
 FORM authentication).
- Returns:
- The authenticated UserPrincipal.
 
Copyright © 2011. All Rights Reserved.