SalesPoint Framework v3.0

users
Class User

java.lang.Object
  |
  +--users.User

public class User
extends Object
implements Serializable

A user, having a name, a password for log-in purposes, and a set of capabilities.

User objects are used to store all information associated with a user. As a default users have a name, a password for log-in purposes, and a set of capabilities that can be used to restrict the users usage of the application. Additional information stored in subclasses of User could include statistics on application usage, bonus data etc.

Hooks:
Display User Capability , Incorporate a process that does not need user interaction
Since:
v2.0
Version:
2.0 05/05/1999
Author:
Steffen Zschaler
See Also:
UserManager, Capability, Serialized Form

Field Summary
static PassWDGarbler DEFAULT_PASSWORD_GARBLER
          The default password garbler.
protected  ListenerHelper m_lhListeners
          The list of all listeners that showed an interest in this user.
 
Constructor Summary
User(String sName)
          Create a new User with a given name.
 
Method Summary
 void addCapabilityDataListener(CapabilityDataListener cdl)
          Add a CapabilityDataListener.
 boolean equals(Object o)
          Check whether the given object equals this user.
protected  void fireCapabilitiesAdded(Set stCapNames)
          Fire a capabilitiesAdded event.
protected  void fireCapabilitiesReplaced(Set stCapNames)
          Fire a capabilitiesReplaced event.
static String garblePassWD(String sPassWD)
          Garble a password using the global password garbler, if any.
 Capability getCapability(String sCapName)
          Retrieve one of this user's capabilities.
 JCheckBox getCapabilityCheckBox(String sCapName)
          Return a checkbox that can be used to visualize and change the value of a certain capability of this user.
static PassWDGarbler getGlobalPassWDGarbler()
          Get the global password garbler.
 String getName()
          Retrieve the name of this user.
 boolean isPassWd(String sPassWd)
          Check whether a given string is identical to the password of this user.
 void loggedOff(Object oFrom)
          Method called by the UserManager when the user was disassociated from some object.
 void loggedOn(Object oTo)
          Method called by the UserManager when the user was associated with some object.
 void removeCapabilityDataListener(CapabilityDataListener cdl)
          Remove a CapabilityDataListener.
 void setCapabilities(Map mpCapabilities)
          Set a range of the user's capabilities to new values.
 Capability setCapability(Capability cap)
          Set one capability.
static PassWDGarbler setGlobalPassWDGarbler(PassWDGarbler pwdgNew)
          Set the global password garbler.
 void setPassWd(String sPassWd)
          Set the password of this user.
 String toString()
          Return a String representation.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_lhListeners

protected ListenerHelper m_lhListeners
The list of all listeners that showed an interest in this user.

DEFAULT_PASSWORD_GARBLER

public static final PassWDGarbler DEFAULT_PASSWORD_GARBLER
The default password garbler.

The default password garbling algorithm is very simple and should only be used if no real security concerns are present. It will take the input String and perform a one-complement and add 7 for each byte in the String.

Constructor Detail

User

public User(String sName)
Create a new User with a given name. The password will initially be the empty string and there will be no capabilities.
Parameters:
sName - the new user's name.
Method Detail

getName

public final String getName()
Retrieve the name of this user.
Override:
Never.
Returns:
the name of the user.

isPassWd

public final boolean isPassWd(String sPassWd)
Check whether a given string is identical to the password of this user.

For security reasons there is no getPassWd() method. The only way to check a user's password is this method. The string you pass as a parameter will be compared to the user's password as it is stored, i.e. if the password is stored in a garbled form (recommended) the string you pass as a parameter must also be in garbled form.

Override:
Never.
Parameters:
sPassWd - the string to be compared to the user's password. Must be in the same form as the actual password, i.e. esp. it must be garbled if the actual password is.
Returns:
true if the password and the string passed as a parameter are equal.
See Also:
garblePassWD(java.lang.String)

setPassWd

public final void setPassWd(String sPassWd)
Set the password of this user.

The password is stored exactly as given, i.e. no garbling of any kind is performed. It is strongly recommended, though, that you pass a garbled password, so that passwords are not stored as plain text.

Override:
Never.
Parameters:
sPassWd - the new password
See Also:
garblePassWD(java.lang.String), PassWDGarbler

equals

public boolean equals(Object o)
Check whether the given object equals this user.

Two users are considered equal if their names are equal.

Override:
Sometimes.
Override this method if you need to implement a different notion of equality between users.
Parameters:
o - the object to be compared to.
Returns:
true if the given object equals this user.
Overrides:
equals in class Object

toString

public String toString()
Return a String representation.
Override:
Sometimes.
Returns:
the name of the user.
Overrides:
toString in class Object

setCapabilities

public void setCapabilities(Map mpCapabilities)
Set a range of the user's capabilities to new values.

Sets all capabilities from mpCapabilities to the new values. This will fire capabilitiesAdded events, and capabilitiesReplaced events if capabilities were changed.

Attention: A capability that has been set cannot be removed again. Capabilities have two states (Granted and Not Granted). If you want to remove a certain capability, set its state to Not Granted.

Override:
Never.
Parameters:
mpCapabilities - the capabilities to be set. The keys of this map must be the names of the capabilities to be set, whereas the corresponding values must be the actual Capability objects.
See Also:
Capability, setCapability(users.Capability), CapabilityDataListener

setCapability

public Capability setCapability(Capability cap)
Set one capability.

Attention: A capability that has been set cannot be removed again. Capabilities have two states (Granted and Not Granted). If you want to remove a certain capability, set its state to Not Granted.

This will fire a capabilitiesAdded or a capabilitiesReplaced event.

Override:
Never.
Parameters:
cap - the capability to be set.
Returns:
the previous value of the capability or null if none.

getCapability

public Capability getCapability(String sCapName)
Retrieve one of this user's capabilities.

Retrieves the capability of this user that is identified by sCapName.

Override:
Never.
Parameters:
sCapName - the name of the capability to be returned.
Returns:
the capability associated with the given name or null if none.
See Also:
Capability

getCapabilityCheckBox

public JCheckBox getCapabilityCheckBox(String sCapName)
Return a checkbox that can be used to visualize and change the value of a certain capability of this user.

The checkbox will be backed by the capability, i.e. changes of the capability will be directly reflected in the checkbox and vice-versa. There will be a NullPointerException if the specified capability does not exist.

Override:
Never.
Parameters:
sCapName - the name of the capability to be visualized by the checkbox.
Returns:
a checkbox that can be used to visualize and change the capability.
Throws:
NullPointerException - if Capability does not exist.
Hooks:
Display User Capability
See Also:
JCheckBox, Capability, Capability.getDisplayName()

addCapabilityDataListener

public void addCapabilityDataListener(CapabilityDataListener cdl)
Add a CapabilityDataListener. CapabilityDataListeners receive events whenever a user's capability list changed.
Override:
Never.
Parameters:
cdl - the CapabilityDataListener to add.

removeCapabilityDataListener

public void removeCapabilityDataListener(CapabilityDataListener cdl)
Remove a CapabilityDataListener. CapabilityDataListeners receive events whenever a user's capability list changed.
Override:
Never.
Parameters:
cdl - the CapabilityDataListener to remove.

fireCapabilitiesAdded

protected void fireCapabilitiesAdded(Set stCapNames)
Fire a capabilitiesAdded event.
Override:
Never.
Parameters:
stCapNames - the set of capability names that where added.
See Also:
CapabilityDataListener.capabilitiesAdded(users.events.CapabilityDataEvent)

fireCapabilitiesReplaced

protected void fireCapabilitiesReplaced(Set stCapNames)
Fire a capabilitiesReplaced event.
Override:
Never.
Parameters:
stCapNames - the set of capability names that where replaced.
See Also:
CapabilityDataListener.capabilitiesReplaced(users.events.CapabilityDataEvent)

loggedOn

public void loggedOn(Object oTo)
Method called by the UserManager when the user was associated with some object.
Override:
Sometimes.
Override this method if you need to be informed when the user was logged on to some object.
Parameters:
oTo - the object this user was associated with.
See Also:
UserManager

loggedOff

public void loggedOff(Object oFrom)
Method called by the UserManager when the user was disassociated from some object.
Override:
Sometimes.
Override this method if you need to be informed when the user was logged off from some object.
Parameters:
oFrom - the object this user was disassociated from.
See Also:
UserManager

setGlobalPassWDGarbler

public static PassWDGarbler setGlobalPassWDGarbler(PassWDGarbler pwdgNew)
Set the global password garbler.

The global password garbler can be used as a central instance for garbling your users' passwords. It defaults to DEFAULT_PASSWORD_GARBLER.

Parameters:
pwdgNew - the new global password garbler.
Returns:
the previous global password garbler.
Hooks:
Define Password Garbling Algorithm

getGlobalPassWDGarbler

public static PassWDGarbler getGlobalPassWDGarbler()
Get the global password garbler.
Returns:
the global password garbler.

garblePassWD

public static String garblePassWD(String sPassWD)
Garble a password using the global password garbler, if any.

If no global password garbler is installed, the password is returned unchanged. Otherwise the garbled password is returned.

Parameters:
sPassWD - the password to garble
Returns:
the garbled password.

SalesPoint Framework v3.0