|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.util.AbstractMap | +--java.util.HashMap | +--org.mortbay.http.HashUserRealm
HashMapped User Realm. An implementation of UserRealm that stores users and roles in-memory in HashMaps.
Typically these maps are populated by calling the load() method or passing a properties resource to the constructor. The format of the properties file is:
username: password [,rolename ...]Passwords may be clear text, obfuscated or checksummed. The class com.mortbay.Util.Password should be used to generate obfuscated passwords or password checksums. If DIGEST Authentication is used, the password must be in a recoverable format, either plain text or OBF:.
Password
,
Serialized FormField Summary |
Fields inherited from interface org.mortbay.http.UserRealm |
__UserRole |
Constructor Summary | |
HashUserRealm()
Constructor. |
|
HashUserRealm(java.lang.String name)
Constructor. |
|
HashUserRealm(java.lang.String name,
java.lang.String config)
Constructor. |
Method Summary | |
void |
addUserToRole(java.lang.String userName,
java.lang.String roleName)
Add a user to a role. |
UserPrincipal |
authenticate(java.lang.String username,
java.lang.Object credentials,
HttpRequest request)
Authenticate a users credentials. |
void |
disassociate(UserPrincipal user)
Dissassociate the calling context with a Principal. |
void |
dump(java.io.PrintStream out)
|
java.lang.String |
getName()
|
boolean |
isUserInRole(UserPrincipal user,
java.lang.String roleName)
Check if a user is in a role. |
void |
load(java.lang.String config)
Load realm users from properties file. |
UserPrincipal |
popRole(UserPrincipal user)
Pop role from a Principal. |
UserPrincipal |
pushRole(UserPrincipal user,
java.lang.String role)
Push role onto a Principal. |
java.lang.Object |
put(java.lang.Object name,
java.lang.Object credentials)
Put user into realm. |
void |
readExternal(java.io.ObjectInput in)
|
void |
setName(java.lang.String name)
|
java.lang.String |
toString()
|
void |
writeExternal(java.io.ObjectOutput out)
|
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 |
getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
equals, hashCode |
Constructor Detail |
public HashUserRealm()
public HashUserRealm(java.lang.String name)
name
- Realm Namepublic HashUserRealm(java.lang.String name, java.lang.String config) throws java.io.IOException
name
- Realm nameconfig
- Filename or url of user properties file.Method Detail |
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
java.io.IOException
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
readExternal
in interface java.io.Externalizable
java.io.IOException
java.lang.ClassNotFoundException
public void load(java.lang.String config) throws java.io.IOException
config
- Filename or url of user properties file.
java.io.IOException
public void setName(java.lang.String name)
name
- The realm namepublic java.lang.String getName()
getName
in interface UserRealm
public UserPrincipal authenticate(java.lang.String username, java.lang.Object credentials, HttpRequest request)
UserRealm
authenticate
in interface UserRealm
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 void disassociate(UserPrincipal user)
UserRealm
disassociate
in interface UserRealm
user
- A UserPrincipal allocated from this realm.public UserPrincipal pushRole(UserPrincipal user, java.lang.String role)
UserRealm
pushRole
in interface UserRealm
user
- An existing UserPrincipal or null for an anonymous user.role
- The role to add.
public UserPrincipal popRole(UserPrincipal user)
UserRealm
popRole
in interface UserRealm
user
- A UserPrincipal previously returned from pushRole
public java.lang.Object put(java.lang.Object name, java.lang.Object credentials)
put
in interface java.util.Map
put
in class java.util.HashMap
name
- User namecredentials
- String password, Password or UserPrinciple
instance.
public void addUserToRole(java.lang.String userName, java.lang.String roleName)
userName
- roleName
- public boolean isUserInRole(UserPrincipal user, java.lang.String roleName)
user
- The user, which must be from this realmroleName
-
public java.lang.String toString()
toString
in class java.util.AbstractMap
public void dump(java.io.PrintStream out)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |