com.sun.slamd.db
Class SLAMDUser

java.lang.Object
  extended bycom.sun.slamd.db.SLAMDUser

public class SLAMDUser
extends java.lang.Object

This class defines a set of information about a user defined in the SLAMD database, including the username and hashed password, the default folder, and the set of groups in which the user is a member.


Field Summary
static java.lang.String ELEMENT_DEFAULT_FOLDER
          The name of the encoded element that holds the name of the default folder for this user.
static java.lang.String ELEMENT_GROUPS
          The name of the enocded element that holds the groups names associated with this user.
static java.lang.String ELEMENT_HASHED_PASSWORD
          The name of the enocded element that holds the hashed password for this user.
static java.lang.String ELEMENT_IS_ADMIN
          The name of the encoded element that indicates whether this user is an administrator.
static java.lang.String ELEMENT_USER_NAME
          The name of the enocded element that holds the user name for this user.
 
Constructor Summary
SLAMDUser(java.lang.String userName, byte[] hashedPassword, java.lang.String[] groupNames, boolean isAdmin, java.lang.String defaultFolder)
          Creates a new user with the provided information.
 
Method Summary
 void addGroupName(java.lang.String groupName)
          Adds the provided group name to the set of groups associated with this user.
 boolean checkPassword(java.lang.String password)
          Determines whether the provided clear-text password is the correct password for this user.
static SLAMDUser decode(byte[] encodedUser)
          Decodes the provided byte array as information about a user.
 byte[] encode()
          Encodes the information for this user into a byte array.
 java.lang.String getDefaultFolder()
          Retrieves the name of the default folder for this user.
 java.lang.String[] getGroupNames()
          Retrieves the names of the groups in which this user is a member.
 java.lang.String getUserName()
          Retrieves the user name for this user.
 boolean isAdmin()
          Indicates whether this user is an administrator with full rights.
 boolean memberOf(java.lang.String groupName)
          Determines whether this user is a member of the specified group.
 void removeGroupName(java.lang.String groupName)
          Removes the provided group name from the set of groups associated with this user.
 void setAdmin(boolean isAdmin)
          Specifies whether this user is an administrator.
 void setDefaultFolder(java.lang.String defaultFolder)
          Specifies the name of the default folder for this user.
 void setGroupNames(java.lang.String[] groupNames)
          Specifies the names of the groups in which this user is a member.
 void setPassword(java.lang.String password)
          Specifies the password to use for the user.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ELEMENT_DEFAULT_FOLDER

public static final java.lang.String ELEMENT_DEFAULT_FOLDER
The name of the encoded element that holds the name of the default folder for this user.

See Also:
Constant Field Values

ELEMENT_GROUPS

public static final java.lang.String ELEMENT_GROUPS
The name of the enocded element that holds the groups names associated with this user.

See Also:
Constant Field Values

ELEMENT_HASHED_PASSWORD

public static final java.lang.String ELEMENT_HASHED_PASSWORD
The name of the enocded element that holds the hashed password for this user.

See Also:
Constant Field Values

ELEMENT_IS_ADMIN

public static final java.lang.String ELEMENT_IS_ADMIN
The name of the encoded element that indicates whether this user is an administrator.

See Also:
Constant Field Values

ELEMENT_USER_NAME

public static final java.lang.String ELEMENT_USER_NAME
The name of the enocded element that holds the user name for this user.

See Also:
Constant Field Values
Constructor Detail

SLAMDUser

public SLAMDUser(java.lang.String userName,
                 byte[] hashedPassword,
                 java.lang.String[] groupNames,
                 boolean isAdmin,
                 java.lang.String defaultFolder)
Creates a new user with the provided information.

Parameters:
userName - The user name for this user.
hashedPassword - The SHA-1 hash of the password for this user.
groupNames - The names of the groups in which this user is a member.
isAdmin - Indicates whether this user is an administrator.
defaultFolder - The default folder for this user.
Method Detail

getUserName

public java.lang.String getUserName()
Retrieves the user name for this user.

Returns:
The user name for this user.

checkPassword

public boolean checkPassword(java.lang.String password)
Determines whether the provided clear-text password is the correct password for this user.

Parameters:
password - The clear-text password to validate for this user.
Returns:
true if the provided password is correct, or false if not.

setPassword

public void setPassword(java.lang.String password)
Specifies the password to use for the user.

Parameters:
password - The password to use for the user.

getGroupNames

public java.lang.String[] getGroupNames()
Retrieves the names of the groups in which this user is a member.

Returns:
The names of the groups in which this user is a member.

memberOf

public boolean memberOf(java.lang.String groupName)
Determines whether this user is a member of the specified group.

Parameters:
groupName - The name of the group for which to make the determination.
Returns:
true if this user is a member of the specified group, or false if not.

setGroupNames

public void setGroupNames(java.lang.String[] groupNames)
Specifies the names of the groups in which this user is a member.

Parameters:
groupNames - The names of the groups in which this user is a member.

addGroupName

public void addGroupName(java.lang.String groupName)
Adds the provided group name to the set of groups associated with this user.

Parameters:
groupName - The name of the group to add to the set of groups for this user.

removeGroupName

public void removeGroupName(java.lang.String groupName)
Removes the provided group name from the set of groups associated with this user.

Parameters:
groupName - The name of the group to remove from the set of groups for this user.

isAdmin

public boolean isAdmin()
Indicates whether this user is an administrator with full rights.

Returns:
true if this user is an administrator, or false if not.

setAdmin

public void setAdmin(boolean isAdmin)
Specifies whether this user is an administrator.

Parameters:
isAdmin - Specifies whether this user is an administrator.

getDefaultFolder

public java.lang.String getDefaultFolder()
Retrieves the name of the default folder for this user.

Returns:
The name of the default folder for this user.

setDefaultFolder

public void setDefaultFolder(java.lang.String defaultFolder)
Specifies the name of the default folder for this user.


encode

public byte[] encode()
Encodes the information for this user into a byte array.

Returns:
The byte array containing the encoded user information.

decode

public static SLAMDUser decode(byte[] encodedUser)
                        throws DecodeException
Decodes the provided byte array as information about a user.

Parameters:
encodedUser - The byte array containing the encoded user information.
Returns:
The user decoded from the provided byte array.
Throws:
DecodeException - If a problem occurs while trying to decode the provided byte array.