public class HashUserRealm extends HashMap implements UserRealm, SSORealm, Externalizable
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,
Serialized FormAbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| Modifier and Type | Field and Description |
|---|---|
static String |
__SSO
HttpContext Attribute to set to activate SSO.
|
protected HashMap |
_roles |
| Constructor and Description |
|---|
HashUserRealm()
Constructor.
|
HashUserRealm(String name)
Constructor.
|
HashUserRealm(String name,
String config)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addUserToRole(String userName,
String roleName)
Add a user to a role.
|
Principal |
authenticate(String username,
Object credentials,
HttpRequest 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 |
getName() |
Principal |
getPrincipal(String username)
Get the principal for a username.
|
Credential |
getSingleSignOn(HttpRequest request,
HttpResponse response)
Get SSO credentials.
|
SSORealm |
getSSORealm() |
boolean |
isUserInRole(Principal user,
String roleName)
Check if a user is in a role.
|
void |
load(String config)
Load realm users from properties file.
|
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.
|
void |
readExternal(ObjectInput in) |
boolean |
reauthenticate(Principal user)
Re Authenticate a Principal.
|
void |
setName(String name) |
void |
setSingleSignOn(HttpRequest request,
HttpResponse response,
Principal principal,
Credential credential)
Set SSO principal and credential.
|
void |
setSSORealm(SSORealm ssoRealm)
Set the SSORealm.
|
String |
toString() |
void |
writeExternal(ObjectOutput out) |
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, putAll, remove, size, valuesequals, hashCodepublic static final String __SSO
protected HashMap _roles
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.IOExceptionpublic void writeExternal(ObjectOutput out) throws IOException
writeExternal in interface ExternalizableIOExceptionpublic void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal in interface ExternalizableIOExceptionClassNotFoundExceptionpublic void load(String config) throws IOException
config - Filename or url of user properties file.IOExceptionpublic void setName(String name)
name - The realm namepublic String getName()
public Principal getPrincipal(String username)
UserRealmgetPrincipal in interface UserRealmpublic Principal authenticate(String username, Object credentials, HttpRequest request)
UserRealmauthenticate in interface UserRealmusername - 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)
UserRealmdisassociate in interface UserRealmuser - A UserPrincipal allocated from this realm.public Principal pushRole(Principal user, String role)
UserRealmpublic Principal popRole(Principal user)
UserRealmpublic void addUserToRole(String userName, String roleName)
userName - roleName - public boolean reauthenticate(Principal user)
UserRealmreauthenticate in interface UserRealmpublic boolean isUserInRole(Principal user, String roleName)
isUserInRole in interface UserRealmuser - The user, which must be from this realmroleName - public void logout(Principal user)
UserRealmpublic String toString()
toString in class AbstractMappublic 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(HttpRequest request, HttpResponse response)
SSORealmgetSingleSignOn in interface SSORealmrequest - The request to SSO.response - The response to SSO.public void setSingleSignOn(HttpRequest request, HttpResponse response, Principal principal, Credential credential)
SSORealmsetSingleSignOn in interface SSORealmrequest - 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)
SSORealmclearSingleSignOn in interface SSORealmusername - The user to clear.Copyright © 2013. All rights reserved.