|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractMap<K,V>
java.util.HashMap
org.mortbay.http.HashUserRealm
org.mortbay.http.JDBCUserRealm
public class JDBCUserRealm
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
Field Summary |
---|
Fields inherited from class org.mortbay.http.HashUserRealm |
---|
__SSO, _roles |
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.mortbay.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 |
Constructor Detail |
---|
public JDBCUserRealm(java.lang.String name)
name
- public JDBCUserRealm(java.lang.String name, java.lang.String config) throws java.io.IOException, java.lang.ClassNotFoundException, java.lang.InstantiationException, java.lang.IllegalAccessException
name
- Realm nameconfig
- Filename or url of JDBC connection properties file.
java.io.IOException
java.lang.ClassNotFoundException
java.lang.InstantiationException
java.lang.IllegalAccessException
Method Detail |
---|
public void loadConfig(java.lang.String config) throws java.io.IOException
config
- Filename or url of user properties file.
java.io.IOException
public void logout(java.security.Principal user)
UserRealm
logout
in interface UserRealm
logout
in class HashUserRealm
user
- A Principal previously returned from this realmpublic void connectDatabase()
public java.security.Principal authenticate(java.lang.String username, java.lang.Object credentials, HttpRequest request)
UserRealm
authenticate
in interface UserRealm
authenticate
in class HashUserRealm
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).
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |