|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.mortbay.jetty.security.HashUserRealm
public class 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:. The HashUserRealm also implements SSORealm but provides no implementation of SSORealm. Instead setSSORealm may be used to provide a delegate SSORealm implementation.
Password
Field Summary | |
---|---|
static String |
__SSO
HttpContext Attribute to set to activate SSO. |
protected HashMap |
_roles
|
protected HashMap |
_users
|
Constructor Summary | |
---|---|
HashUserRealm()
Constructor. |
|
HashUserRealm(String name)
Constructor. |
|
HashUserRealm(String name,
String config)
Constructor. |
Method Summary | |
---|---|
void |
addUserToRole(String userName,
String roleName)
Add a user to a role. |
Principal |
authenticate(String username,
Object credentials,
Request request)
Authenticate a users credentials. |
void |
clearSingleSignOn(String username)
Clear SSO for user. |
void |
disassociate(Principal user)
Dissassociate the calling context with a Principal. |
void |
dump(PrintStream out)
|
String |
getConfig()
|
String |
getName()
|
Principal |
getPrincipal(String username)
Get the principal for a username. |
Credential |
getSingleSignOn(Request request,
Response response)
Get SSO credentials. |
SSORealm |
getSSORealm()
|
boolean |
isUserInRole(Principal user,
String roleName)
Check if a user is in a role. |
void |
logout(Principal user)
logout a user Principal. |
Principal |
popRole(Principal user)
Pop role from a Principal. |
Principal |
pushRole(Principal user,
String role)
Push role onto a Principal. |
Object |
put(Object name,
Object credentials)
Put user into realm. |
boolean |
reauthenticate(Principal user)
Re Authenticate a Principal. |
void |
setConfig(String config)
Load realm users from properties file. |
void |
setName(String name)
|
void |
setSingleSignOn(Request request,
Response response,
Principal principal,
Credential credential)
Set SSO principal and credential. |
void |
setSSORealm(SSORealm ssoRealm)
Set the SSORealm. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String __SSO
protected HashMap _users
protected HashMap _roles
Constructor Detail |
---|
public HashUserRealm()
public HashUserRealm(String name)
name
- Realm Namepublic HashUserRealm(String name, String config) throws IOException
name
- Realm nameconfig
- Filename or url of user properties file.
IOException
Method Detail |
---|
public String getConfig()
public void setConfig(String config) throws IOException
config
- Filename or url of user properties file.
IOException
public void setName(String name)
name
- The realm namepublic String getName()
getName
in interface UserRealm
public Principal getPrincipal(String username)
UserRealm
getPrincipal
in interface UserRealm
public Principal authenticate(String username, Object credentials, Request 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(Principal user)
UserRealm
disassociate
in interface UserRealm
user
- A UserPrincipal allocated from this realm.public Principal pushRole(Principal user, String role)
UserRealm
pushRole
in interface UserRealm
user
- An existing UserPrincipal or null for an anonymous user.role
- The role to add.
public Principal popRole(Principal user)
UserRealm
popRole
in interface UserRealm
user
- A UserPrincipal previously returned from pushRole
public Object put(Object name, Object credentials)
name
- User namecredentials
- String password, Password or UserPrinciple
instance.
public void addUserToRole(String userName, String roleName)
userName
- roleName
- public boolean reauthenticate(Principal user)
UserRealm
reauthenticate
in interface UserRealm
public boolean isUserInRole(Principal user, String roleName)
isUserInRole
in interface UserRealm
user
- The user, which must be from this realmroleName
-
public void logout(Principal user)
UserRealm
logout
in interface UserRealm
user
- A Principal previously returned from this realmpublic String toString()
toString
in class Object
public void dump(PrintStream out)
public SSORealm getSSORealm()
public void setSSORealm(SSORealm ssoRealm)
ssoRealm
- The SSORealm to delegate single sign on requests to.public Credential getSingleSignOn(Request request, Response response)
SSORealm
getSingleSignOn
in interface SSORealm
request
- The request to SSO.response
- The response to SSO.
public void setSingleSignOn(Request request, Response response, Principal principal, Credential credential)
SSORealm
setSingleSignOn
in interface SSORealm
request
- The authenticated request.response
- The authenticated response/principal
- The principal that has been authenticated.credential
- The credentials used to authenticate.public void clearSingleSignOn(String username)
SSORealm
clearSingleSignOn
in interface SSORealm
username
- The user to clear.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |