authorization
Class UserAuthorizer

java.lang.Object
  extended by authorization.UserAuthorizer
All Implemented Interfaces:
IUserAuthorizer

public class UserAuthorizer
extends java.lang.Object
implements IUserAuthorizer

This class implements the IUserAuthorizer interface using an in-memory database initialized when the model is loaded for execution.


Field Summary
private  java.util.HashMap users
          Map from user names to user authentication and authorization information (String -> User).
 
Constructor Summary
UserAuthorizer()
          Constructor: create an empty user authorization map.
 
Method Summary
 void addUser(java.lang.String userName, java.lang.String password, java.lang.String[] capabilities)
          Add a user to the authentication and authorization database.
 boolean isAuthenticated(java.lang.String userName, java.lang.String password)
          Look up this user name and password in the database.
 boolean isCapable(java.lang.String userName, java.lang.String capability)
          Determine whether or not this user has this capability.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

users

private java.util.HashMap users
Map from user names to user authentication and authorization information (String -> User).

Constructor Detail

UserAuthorizer

public UserAuthorizer()
Constructor: create an empty user authorization map.

Method Detail

addUser

public void addUser(java.lang.String userName,
                    java.lang.String password,
                    java.lang.String[] capabilities)
             throws java.lang.IllegalArgumentException
Add a user to the authentication and authorization database.

Parameters:
userName - user name
password - user password
capabilities - names of capabilities possessed by this user
Throws:
java.lang.IllegalArgumentException - for invalid user data or duplicate name.

isAuthenticated

public boolean isAuthenticated(java.lang.String userName,
                               java.lang.String password)
Look up this user name and password in the database.

Specified by:
isAuthenticated in interface IUserAuthorizer
Parameters:
userName - user name supplied
password - password supplied
Returns:
true when the user name and password match a user database entry

isCapable

public boolean isCapable(java.lang.String userName,
                         java.lang.String capability)
Determine whether or not this user has this capability.

Specified by:
isCapable in interface IUserAuthorizer
Parameters:
userName - name of user
capability - capability desired
Returns:
true only if this user has the requested capability