|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.mortbay.component.AbstractLifeCycle
org.mortbay.jetty.security.HashUserRealm
org.mortbay.jetty.security.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
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.mortbay.component.LifeCycle |
---|
LifeCycle.Listener |
Field Summary |
---|
Fields inherited from class org.mortbay.jetty.security.HashUserRealm |
---|
__SSO, _roles, _users |
Fields inherited from class org.mortbay.component.AbstractLifeCycle |
---|
_listeners |
Constructor Summary | |
---|---|
JDBCUserRealm()
Constructor. |
|
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,
Request request)
Authenticate a users credentials. |
void |
connectDatabase()
(re)Connect to database with parameters setup by loadConfig() |
boolean |
isUserInRole(java.security.Principal user,
java.lang.String roleName)
Check if a user is in a role. |
protected void |
loadConfig()
Load JDBC connection configuration from properties file. |
void |
logout(java.security.Principal user)
logout a user Principal. |
Methods inherited from class org.mortbay.jetty.security.HashUserRealm |
---|
addUserToRole, clearSingleSignOn, disassociate, doStart, doStop, dump, getConfig, getConfigResource, getName, getPrincipal, getRefreshInterval, getSingleSignOn, getSSORealm, popRole, pushRole, put, reauthenticate, setConfig, setName, setRefreshInterval, setSingleSignOn, setSSORealm, toString |
Methods inherited from class org.mortbay.component.AbstractLifeCycle |
---|
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.mortbay.jetty.security.UserRealm |
---|
disassociate, getName, getPrincipal, popRole, pushRole, reauthenticate |
Constructor Detail |
---|
public JDBCUserRealm()
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 |
---|
protected void loadConfig() throws java.io.IOException
loadConfig
in class HashUserRealm
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, Request 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).
public boolean isUserInRole(java.security.Principal user, java.lang.String roleName)
isUserInRole
in interface UserRealm
isUserInRole
in class HashUserRealm
user
- The user, which must be from this realmroleName
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |