authorization
Class User

java.lang.Object
  extended by authorization.User

public class User
extends java.lang.Object

This class records the state of a particular client (Verastream) user as a simple immutable bean.

An instance of this class stores the client user name and password for each user permitted to access this model. The capabilities stored in this instance describe what parts of the model this user has access to.


Field Summary
private  java.util.HashSet capabilities
          Capabilities for this user.
private  java.lang.String name
          User name.
private  java.lang.String password
          Password for this user.
 
Constructor Summary
User(java.lang.String name, java.lang.String password, java.lang.String[] capabilities)
          Constructor.
 
Method Summary
 java.lang.String getName()
          User name getter.
 boolean hasCapability(java.lang.String capability)
          Does this user have this capability?
 boolean hasPassword(java.lang.String password)
          Does the password supplied match?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

private final java.lang.String name
User name.


password

private final java.lang.String password
Password for this user.


capabilities

private final java.util.HashSet capabilities
Capabilities for this user.

The capabilities are stored as a set of strings. The presence of a capability name in this set indicates that this user has that capability.

Constructor Detail

User

public User(java.lang.String name,
            java.lang.String password,
            java.lang.String[] capabilities)
     throws java.lang.IllegalArgumentException
Constructor. Creates an immutable object initialized with these parameters.

Parameters:
name - user name
password - user password
capabilities - null (== *all* capabilities) or an array of capability Strings
Throws:
java.lang.IllegalArgumentException - if empty name or capability supplied.
Method Detail

getName

public java.lang.String getName()
User name getter.

Returns:
user name

hasCapability

public boolean hasCapability(java.lang.String capability)
Does this user have this capability?

The null user has no capabilities. The null capability is "everything".

Parameters:
capability - name of a capability
Returns:
true if this user has this capability

hasPassword

public boolean hasPassword(java.lang.String password)
Does the password supplied match?

Returns:
true if password matches or if any password is allowed