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
| Modifier and Type | Class and Description |
|---|---|
| private class | |
| private class | |
| private class |
| Modifier and Type | Field and Description |
|---|---|
| public static final String | __SSO
HttpContext Attribute to set to activate SSO. |
| private String | |
| private Resource | |
| private String | |
| private int | |
| protected HashMap | |
| private Scanner | |
| private SSORealm | |
| protected HashMap |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public | HashUserRealm(String
Realm name name, String Filename or url of user properties file. config)Constructor. |
| Modifier and Type | Method and Description |
|---|---|
| public synchronized void | |
| public Principal | authenticate(String
The username. username, Object The user credentials, normally a String password. credentials, 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). request)Implements org. |
| public void | clearSingleSignOn(String
The user to clear. username)Implements org. |
| public void | disassociate(Principal
A UserPrincipal allocated from this realm. user)Implements org. |
| protected void | |
| protected void | |
| public void | |
| public String | |
| public Resource | |
| public String | |
| public Principal | getPrincipal(String username)
Implements org. |
| public int | |
| public Credential | getSingleSignOn(Request
The request to SSO. request, Response The response to SSO. response)Implements org. |
| public SSORealm | |
| public synchronized boolean | Returns: True if the user can act in the role.The user, which must be from this realm user, String roleName)Implements org. |
| protected void | |
| public void | logout(Principal
A Principal previously returned from this realm user)Implements org. |
| public Principal | popRole(Principal
A UserPrincipal previously returned from pushRole user)Implements org. |
| public Principal | pushRole(Principal
An existing UserPrincipal or null for an anonymous user. user, String The role to add. role)Implements org. |
| public synchronized Object | |
| public boolean | reauthenticate(Principal user)
Implements org. |
| public void | |
| public void | |
| public void | |
| public void | setSingleSignOn(Request
The authenticated request. request, Response The authenticated response/ response, Principal The principal that has been authenticated. principal, Credential The credentials used to authenticate. credential)Implements org. |
| public void | |
| public String |
| __SSO | back to summary |
|---|---|
| public static final String __SSO HttpContext Attribute to set to activate SSO. | |
| _config | back to summary |
|---|---|
| private String _config | |
| _configResource | back to summary |
|---|---|
| private Resource _configResource | |
| _realmName | back to summary |
|---|---|
| private String _realmName | |
| _refreshInterval | back to summary |
|---|---|
| private int _refreshInterval | |
| _roles | back to summary |
|---|---|
| protected HashMap<K, V> _roles | |
| _scanner | back to summary |
|---|---|
| private Scanner _scanner | |
| _ssoRealm | back to summary |
|---|---|
| private SSORealm _ssoRealm | |
| _users | back to summary |
|---|---|
| protected HashMap<K, V> _users | |
| HashUserRealm | back to summary |
|---|---|
| public HashUserRealm() Constructor. | |
| HashUserRealm | back to summary |
|---|---|
| public HashUserRealm(String name) Constructor.
| |
| HashUserRealm | back to summary |
|---|---|
| public HashUserRealm(String name, String config) throws IOException Constructor. | |
| addUserToRole | back to summary |
|---|---|
| public synchronized void addUserToRole(String userName, String roleName) Add a user to a role. | |
| authenticate | back to summary |
|---|---|
| public Principal authenticate(String username, Object credentials, Request request) Implements org. Doc from org. Authenticate a users credentials. Implementations of this method may adorn the calling context to assoicate it with the authenticated principal (eg ThreadLocals). If such context associations are made, they should be considered valid until a UserRealm.deAuthenticate(UserPrincipal) call is made for this UserPrincipal.
| |
| clearSingleSignOn | back to summary |
|---|---|
| public void clearSingleSignOn(String username) Implements org. Doc from org. Clear SSO for user.
| |
| disassociate | back to summary |
|---|---|
| public void disassociate(Principal user) Implements org. Doc from org. Dissassociate the calling context with a Principal. This method is called when the calling context is not longer associated with the Principal. It should be used by an implementation to remove context associations such as ThreadLocals. The UserPrincipal object remains authenticated, as it may be associated with other contexts.
| |
| doStart | back to summary |
|---|---|
| protected void doStart() throws Exception | |
| doStop | back to summary |
|---|---|
| protected void doStop() throws Exception | |
| dump | back to summary |
|---|---|
| public void dump(PrintStream out) | |
| getConfig | back to summary |
|---|---|
| public String getConfig() | |
| getConfigResource | back to summary |
|---|---|
| public Resource getConfigResource() | |
| getName | back to summary |
|---|---|
| public String getName() Implements org.
| |
| getPrincipal | back to summary |
|---|---|
| public Principal getPrincipal(String username) Implements org. Doc from org. Get the principal for a username. This method is not guaranteed to return a Principal for non-authenticated users. | |
| getRefreshInterval | back to summary |
|---|---|
| public int getRefreshInterval() | |
| getSingleSignOn | back to summary |
|---|---|
| public Credential getSingleSignOn(Request request, Response response) Implements org. Doc from org. Get SSO credentials. This call is used by an authenticator to check if a SSO exists for a request. If SSO authentiation is successful, the requests UserPrincipal and AuthUser fields are set. If available, the credential used to authenticate the user is returned. If recoverable credentials are not required then null may be return.
| |
| getSSORealm | back to summary |
|---|---|
public SSORealm getSSORealm()
| |
| isUserInRole | back to summary |
|---|---|
| public synchronized boolean isUserInRole(Principal user, String roleName) Implements org. Check if a user is in a role.
| |
| loadConfig | back to summary |
|---|---|
| protected void loadConfig() throws IOException | |
| logout | back to summary |
|---|---|
| public void logout(Principal user) Implements org. Doc from org. logout a user Principal. Called by authentication mechanisms (eg FORM) that can detect logout.
| |
| popRole | back to summary |
|---|---|
| public Principal popRole(Principal user) Implements org. Doc from org. Pop role from a Principal. | |
| pushRole | back to summary |
|---|---|
| public Principal pushRole(Principal user, String role) Implements org. Doc from org. Push role onto a Principal. This method is used to add a role to an existing principal. | |
| put | back to summary |
|---|---|
| public synchronized Object put(Object name, Object credentials) Put user into realm. | |
| reauthenticate | back to summary |
|---|---|
| public boolean reauthenticate(Principal user) Implements org. Doc from org. Re Authenticate a Principal. Authenicate a principal that has previously been return from the authenticate method. Implementations of this method may adorn the calling context to assoicate it with the authenticated principal (eg ThreadLocals). If such context associations are made, they should be considered valid until a UserRealm.deAuthenticate(UserPrincipal) call is made for this UserPrincipal.
| |
| setConfig | back to summary |
|---|---|
| public void setConfig(String config) throws IOException Load realm users from properties file. The property file maps usernames to password specs followed by an optional comma separated list of role names.
| |
| setName | back to summary |
|---|---|
public void setName(String name)
| |
| setRefreshInterval | back to summary |
|---|---|
| public void setRefreshInterval(int msec) | |
| setSingleSignOn | back to summary |
|---|---|
| public void setSingleSignOn(Request request, Response response, Principal principal, Credential credential) Implements org. Doc from org. Set SSO principal and credential. This call is used by an authenticator to inform the SSO mechanism that a user has signed on. The SSO mechanism should record the principal and credential and update the response with any cookies etc. required.
| |
| setSSORealm | back to summary |
|---|---|
| public void setSSORealm(SSORealm ssoRealm) Set the SSORealm. A SSORealm implementation may be set to enable support for SSO.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
| |
| Modifier and Type | Field and Description |
|---|---|
| private Credential | |
| private String |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv boolean | |
| public String | getName()
Overrides org. Implements java. Principal.
|
| public boolean |
| _cred | back to summary |
|---|---|
| private Credential _cred | |
| _userName | back to summary |
|---|---|
| private String _userName | |
| KnownUser | back to summary |
|---|---|
| pack-priv KnownUser(String name, Credential credential) | |
| authenticate | back to summary |
|---|---|
| pack-priv boolean authenticate(Object credentials) | |
| getName | back to summary |
|---|---|
| public String getName() Overrides org. Implements java. Doc from java. Returns the name of this
| |
| isAuthenticated | back to summary |
|---|---|
| public boolean isAuthenticated() Overrides org. | |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public String | |
| private UserRealm | |
| public boolean | |
| public String | toString()
Overrides java. Implements java. Principal.
|
| roles | back to summary |
|---|---|
| pack-priv List<E> roles | |
| User | back to summary |
|---|---|
| private User() | |
| getName | back to summary |
|---|---|
| public String getName() Implements java. Doc from java. Returns the name of this
| |
| getUserRealm | back to summary |
|---|---|
| private UserRealm getUserRealm() | |
| isAuthenticated | back to summary |
|---|---|
| public boolean isAuthenticated() | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Implements java. Doc from java. Returns a string representation of this
| |
| Modifier and Type | Field and Description |
|---|---|
| private String | |
| private Principal |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public String | getName()
Overrides org. Implements java. Principal.
|
| pack-priv Principal | |
| public boolean | |
| public boolean |
| WrappedUser | back to summary |
|---|---|
| pack-priv WrappedUser(Principal user, String role) | |
| getName | back to summary |
|---|---|
| public String getName() Overrides org. Implements java. Doc from java. Returns the name of this
| |
| getUserPrincipal | back to summary |
|---|---|
| pack-priv Principal getUserPrincipal() | |
| isAuthenticated | back to summary |
|---|---|
| public boolean isAuthenticated() Overrides org. | |
| isUserInRole | back to summary |
|---|---|
| public boolean isUserInRole(String role) | |