org.mortbay.http
Class HashUserRealm

java.lang.Object
  |
  +--java.util.AbstractMap
        |
        +--java.util.HashMap
              |
              +--org.mortbay.http.HashUserRealm
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.io.Serializable, UserRealm

public class HashUserRealm
extends java.util.HashMap
implements UserRealm

HashMapped User Realm.

Version:
$Id: HashUserRealm.java,v 1.4 2001/10/21 00:32:12 gregwilkins Exp $
Author:
Greg Wilkins (gregw)
See Also:
Password, Serialized Form

Inner classes inherited from class java.util.Map
java.util.Map.Entry
 
Fields inherited from interface org.mortbay.http.UserRealm
__UserRole
 
Constructor Summary
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.
 void dump(java.io.PrintStream out)
           
 java.lang.String getName()
           
 UserPrincipal getUser(java.lang.String username)
           
 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.
 java.lang.Object put(java.lang.Object name, java.lang.Object credentials)
          Put user into realm.
 java.lang.String toString()
           
 
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

HashUserRealm

public HashUserRealm(java.lang.String name)
Constructor.
Parameters:
name -  

HashUserRealm

public HashUserRealm(java.lang.String name,
                     java.lang.String config)
              throws java.io.IOException
Constructor.
Parameters:
name - Realm name
config - Filename or url of user properties file.
Method Detail

load

public void load(java.lang.String config)
          throws java.io.IOException
Load realm users from properties file. The property file maps usernames to password specs followed by an optional coma separated list of role names.
Parameters:
config - Filename or url of user properties file.
Throws:
java.io.IOException -  

getName

public java.lang.String getName()
Specified by:
getName in interface UserRealm

getUser

public UserPrincipal getUser(java.lang.String username)
Specified by:
getUser in interface UserRealm

put

public java.lang.Object put(java.lang.Object name,
                            java.lang.Object credentials)
Put user into realm.
Overrides:
put in class java.util.HashMap
Parameters:
name - User name
credentials - String password, Password or UserPrinciple instance.
Returns:
Old UserPrinciple value or null

addUserToRole

public void addUserToRole(java.lang.String userName,
                          java.lang.String roleName)
Add a user to a role.
Parameters:
userName -  
roleName -  

isUserInRole

public boolean isUserInRole(UserPrincipal user,
                            java.lang.String roleName)
Check if a user is in a role. All users are in the role "org.mortbay.http.User".
Parameters:
user - The user, which must be from this realm
roleName -  
Returns:
True if the user can act in the role.

toString

public java.lang.String toString()
Overrides:
toString in class java.util.AbstractMap

dump

public void dump(java.io.PrintStream out)


Copyright © 2000 Mortbay Consulting Pty. Ltd. All Rights Reserved.