Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.base.database
Class DbUser

java.lang.Object
  extended by com.jivesoftware.base.database.DbUser
All Implemented Interfaces:
IntrospectiveUser, User, Cacheable, com.tangosol.io.ExternalizableLite, java.io.Serializable

public class DbUser
extends java.lang.Object
implements IntrospectiveUser, Cacheable, com.tangosol.io.ExternalizableLite

Database implementation of the User interface.

See Also:
User, Serialized Form

Constructor Summary
  DbUser()
          Constructor for internal user only.
protected DbUser(long userID)
          Load a DbUser object specified by userID.
protected DbUser(long id, java.lang.String username, java.lang.String password, java.lang.String name, java.lang.String email, boolean nameVisible, boolean emailVisible, java.util.Map properties)
          Create a new DbUser with all required AND optional fields.
protected DbUser(java.lang.String username)
          Load a DbUser object specified by username.
protected DbUser(java.lang.String username, java.lang.String password, java.lang.String email)
          Create a new DbUser with all required fields.
protected DbUser(java.lang.String username, java.lang.String password, java.lang.String name, java.lang.String email, boolean nameVisible, boolean emailVisible, java.util.Map properties)
          Create a new DbUser with all required AND optional fields.
 
Method Summary
 void deleteProperty(java.lang.String name)
          Deletes an extended property.
 boolean equals(java.lang.Object object)
           
 int getCachedSize()
          Returns the approximate size of the Object in bytes.
 java.util.Date getCreationDate()
          Returns the date that the user was created.
 java.lang.String getEmail()
          Returns the user's email address.
 long getID()
          Returns the user's id.
 java.util.Date getModificationDate()
          Returns the date that the user was last modified.
 java.lang.String getName()
          Returns the user's name.
 java.lang.String getPasswordHash()
          Returns the user's password in hashed form.
 Permissions getPermissions(AuthToken auth)
          Returns the permissions for the user that correspond to the passed-in AuthToken.
 java.lang.String getProperty(java.lang.String name)
          Returns an extended property of the user.
 java.util.Iterator getPropertyNames()
          Returns an Iterator for all the names of the extended user properties.
 java.lang.String getUsername()
          Returns the user's username.
 int hashCode()
           
 boolean isAuthorized(long permissionType)
          Returns true if the handle on the object has the permission specified.
 boolean isEmailVisible()
          Returns true if the user has chosen to make her email visible to other users.
 boolean isGetPasswordHashSupported()
          Indicates whether retrieving a password hash is supported for this user.
 boolean isNameVisible()
          Returns true if the user has chosen to make her name visible to other users.
 boolean isPropertyEditSupported()
          Indicates whether the property methods (get, set, delete, etc.) are supported.
 boolean isReadOnly()
          Convenience method - returns true if the user is in a 'read only' mode - that is, none of the setter methods are implemented.
 boolean isSetEmailSupported()
          Indicates whether setting the email address is supported for this user.
 boolean isSetEmailVisibleSupported()
          Indicates whether setting the visibility of the email address is supported for this user.
 boolean isSetNameSupported()
          Indicates whether setting the full name is supported for this user.
 boolean isSetNameVisibleSupported()
          Indicates whether setting the visibility of the name is supported for this user.
 boolean isSetPasswordHashSupported()
          Indicates whether modifying the hash of the user's password is supported for this user.
 boolean isSetPasswordSupported()
          Indicates whether modifying the user's password is supported.
 void readExternal(java.io.DataInput in)
           
 void setCreationDate(java.util.Date creationDate)
          Sets the creation date of the user.
 void setEmail(java.lang.String email)
          Sets the user's email address.
 void setEmailVisible(boolean visible)
          Sets whether a user's email is visible to other users.
 void setModificationDate(java.util.Date modificationDate)
          Sets the date the user was last modified.
 void setName(java.lang.String name)
          Sets the user's name.
 void setNameVisible(boolean visible)
          Sets whether a user's name is visible to other users.
 void setPassword(java.lang.String password)
          Sets the users's password.
 void setPasswordHash(java.lang.String passwordHash)
          Sets the user's password in hashed form.
 void setProperty(java.lang.String name, java.lang.String value)
          Sets an extended property of the user.
 void setUsername(java.lang.String username)
           
 java.lang.String toString()
          Returns a String representation of the User object using the username.
 void writeExternal(java.io.DataOutput out)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DbUser

protected DbUser(java.lang.String username,
                 java.lang.String password,
                 java.lang.String email)
Create a new DbUser with all required fields.

Parameters:
username - the username for the user.
password - a password for the user.
email - the email address for the user.

DbUser

protected DbUser(java.lang.String username,
                 java.lang.String password,
                 java.lang.String name,
                 java.lang.String email,
                 boolean nameVisible,
                 boolean emailVisible,
                 java.util.Map properties)
Create a new DbUser with all required AND optional fields. Using this constructor can result in significantly fewer database operations than calling the other create constructor and then using setter methods.

Parameters:
username - the username for the user.
password - a password for the user.
email - the email address for the user.

DbUser

protected DbUser(long id,
                 java.lang.String username,
                 java.lang.String password,
                 java.lang.String name,
                 java.lang.String email,
                 boolean nameVisible,
                 boolean emailVisible,
                 java.util.Map properties)
Create a new DbUser with all required AND optional fields. This constructor is only intended to be used for mass importing users via the xml export/import utility.


DbUser

protected DbUser(long userID)
          throws UserNotFoundException
Load a DbUser object specified by userID.

Parameters:
userID - the userID of the user to load.
Throws:
UserNotFoundException

DbUser

protected DbUser(java.lang.String username)
          throws UserNotFoundException
Load a DbUser object specified by username.

Parameters:
username - the username of the user to load.
Throws:
UserNotFoundException

DbUser

public DbUser()
Constructor for internal user only.

Method Detail

readExternal

public void readExternal(java.io.DataInput in)
                  throws java.io.IOException
Specified by:
readExternal in interface com.tangosol.io.ExternalizableLite
Throws:
java.io.IOException

writeExternal

public void writeExternal(java.io.DataOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface com.tangosol.io.ExternalizableLite
Throws:
java.io.IOException

isSetPasswordSupported

public boolean isSetPasswordSupported()
Description copied from interface: IntrospectiveUser
Indicates whether modifying the user's password is supported.

Specified by:
isSetPasswordSupported in interface IntrospectiveUser
Returns:
true if modifying the user's password is supported.

isGetPasswordHashSupported

public boolean isGetPasswordHashSupported()
Description copied from interface: IntrospectiveUser
Indicates whether retrieving a password hash is supported for this user.

Specified by:
isGetPasswordHashSupported in interface IntrospectiveUser
Returns:
true if you can retrieve a password hash.

isSetPasswordHashSupported

public boolean isSetPasswordHashSupported()
Description copied from interface: IntrospectiveUser
Indicates whether modifying the hash of the user's password is supported for this user.

Specified by:
isSetPasswordHashSupported in interface IntrospectiveUser
Returns:
true if setting the hash is supported.

isSetNameSupported

public boolean isSetNameSupported()
Description copied from interface: IntrospectiveUser
Indicates whether setting the full name is supported for this user.

Specified by:
isSetNameSupported in interface IntrospectiveUser
Returns:
true if setting the name is supported.

isSetEmailSupported

public boolean isSetEmailSupported()
Description copied from interface: IntrospectiveUser
Indicates whether setting the email address is supported for this user.

Specified by:
isSetEmailSupported in interface IntrospectiveUser
Returns:
true if setting the email is supported.

isSetNameVisibleSupported

public boolean isSetNameVisibleSupported()
Description copied from interface: IntrospectiveUser
Indicates whether setting the visibility of the name is supported for this user.

Specified by:
isSetNameVisibleSupported in interface IntrospectiveUser
Returns:
true if setting the name visibility flag is supported.

isSetEmailVisibleSupported

public boolean isSetEmailVisibleSupported()
Description copied from interface: IntrospectiveUser
Indicates whether setting the visibility of the email address is supported for this user.

Specified by:
isSetEmailVisibleSupported in interface IntrospectiveUser
Returns:
true if setting the email visibility flag is supported.

isPropertyEditSupported

public boolean isPropertyEditSupported()
Description copied from interface: IntrospectiveUser
Indicates whether the property methods (get, set, delete, etc.) are supported.

Specified by:
isPropertyEditSupported in interface IntrospectiveUser
Returns:
true if the property methods are supported.

isReadOnly

public boolean isReadOnly()
Description copied from interface: IntrospectiveUser
Convenience method - returns true if the user is in a 'read only' mode - that is, none of the setter methods are implemented.

Specified by:
isReadOnly in interface IntrospectiveUser
Returns:
true if the user is in 'read only' mode, false otherwise.

getID

public long getID()
Description copied from interface: User
Returns the user's id. All ids must be unique in the system.

Specified by:
getID in interface User
Returns:
the user's id.

getUsername

public java.lang.String getUsername()
Description copied from interface: User
Returns the user's username. All usernames must be unique in the system.

Specified by:
getUsername in interface User
Returns:
the username of the user.

setUsername

public void setUsername(java.lang.String username)
                 throws UnauthorizedException,
                        UserAlreadyExistsException
Throws:
UnauthorizedException
UserAlreadyExistsException

getName

public java.lang.String getName()
Description copied from interface: User
Returns the user's name. The user's name does not have to be to be unique in the system. Some users may opt to not let others see their name for privacy reasons. In that case, the user can set nameVisible to false. In that case, a call to this method will return null.

Specified by:
getName in interface User
Returns:
the name of the user.

setName

public void setName(java.lang.String name)
             throws UnauthorizedException
Description copied from interface: User
Sets the user's name. The user's name does not have to be to be unique in the system.

Specified by:
setName in interface User
Parameters:
name - new name for the user.
Throws:
UnauthorizedException - if does not have administrator permissions.

isNameVisible

public boolean isNameVisible()
Description copied from interface: User
Returns true if the user has chosen to make her name visible to other users. If the name is not visible, calling getName() will throw an UnauthorizedException.

Specified by:
isNameVisible in interface User
Returns:
true if the name is visible to other users.

setNameVisible

public void setNameVisible(boolean visible)
                    throws UnauthorizedException
Description copied from interface: User
Sets whether a user's name is visible to other users. If the field is set to not be visible, calling getName() will throw an UnauthorizedException.

Specified by:
setNameVisible in interface User
Parameters:
visible - boolean value to determin if the name should be visible.
Throws:
UnauthorizedException - if does not have administrator permissions.

setPassword

public void setPassword(java.lang.String password)
                 throws UnauthorizedException
Description copied from interface: User
Sets the users's password. The password should be passed in as plain text. The way the password is stored is implementation dependent. However, it is recommended to at least hash passwords with an algorithm such as MD5.

Specified by:
setPassword in interface User
Parameters:
password - new password for the user.
Throws:
UnauthorizedException - if does not have administrator permissions.

getPasswordHash

public java.lang.String getPasswordHash()
                                 throws UnauthorizedException
Description copied from interface: User
Returns the user's password in hashed form. This method is only intended for system administration functions and can be ignored by skin writers.

If your back-end user store does not support this operation, throw an UnsupportedOperationException.

Specified by:
getPasswordHash in interface User
Returns:
the hashed password.
Throws:
UnauthorizedException - if does not have administrator permissions.

setPasswordHash

public void setPasswordHash(java.lang.String passwordHash)
Description copied from interface: User
Sets the user's password in hashed form. This method is only intended for system administration functions and can be ignored by skin writers.

If your back-end user store does not support this operation, throw an UnsupportedOperationException.

Specified by:
setPasswordHash in interface User
Parameters:
passwordHash - the hashedPassword for the user.

getEmail

public java.lang.String getEmail()
Description copied from interface: User
Returns the user's email address. Email should be considered to be a required field of a user account since it is critical to many user operations performing. If the user sets emailVisible to false, this method will always return null.

If your back-end user store does not support this operation, always return null.

Specified by:
getEmail in interface User
Returns:
the email address of the user.

setEmail

public void setEmail(java.lang.String email)
              throws UnauthorizedException
Description copied from interface: User
Sets the user's email address. Email should be considered to be a required field of a user account since it is critical to many user operations performing.

If your back-end user store does not support this operation, throw an UnsupportedOperationException.

Specified by:
setEmail in interface User
Parameters:
email - new email address for the user.
Throws:
UnauthorizedException - if does not have administrator permissions.

isEmailVisible

public boolean isEmailVisible()
Description copied from interface: User
Returns true if the user has chosen to make her email visible to other users. If the email field is not visible, calling getEmail() will throw an UnauthorizedException.

Specified by:
isEmailVisible in interface User
Returns:
true if the name is visible to other users.

setEmailVisible

public void setEmailVisible(boolean visible)
                     throws UnauthorizedException
Description copied from interface: User
Sets whether a user's email is visible to other users. If the field is set to not be visible, calling getEmail() will throw an UnauthorizedException.

Specified by:
setEmailVisible in interface User
Parameters:
visible - boolean value to determin if the name should be visible.
Throws:
UnauthorizedException - if does not have administrator permissions.

getCreationDate

public java.util.Date getCreationDate()
Description copied from interface: User
Returns the date that the user was created.

If your back-end user store does not support this operation, throw an UnsupportedOperationException.

Specified by:
getCreationDate in interface User
Returns:
the date the user was created.

setCreationDate

public void setCreationDate(java.util.Date creationDate)
                     throws UnauthorizedException
Description copied from interface: User
Sets the creation date of the user. In most cases, the creation date will default to when the user was entered into the system. However, the date needs to be set manually when importing data. In other words, skin authors should ignore this method since it only intended for system maintenance.

Specified by:
setCreationDate in interface User
Parameters:
creationDate - the date the user was created.
Throws:
UnauthorizedException - if does not have administrator permissions.

getModificationDate

public java.util.Date getModificationDate()
Description copied from interface: User
Returns the date that the user was last modified.

Specified by:
getModificationDate in interface User
Returns:
the date the user record was last modified.

setModificationDate

public void setModificationDate(java.util.Date modificationDate)
                         throws UnauthorizedException
Description copied from interface: User
Sets the date the user was last modified. Skin authors should ignore this method since it only intended for system maintenance.

Specified by:
setModificationDate in interface User
Parameters:
modificationDate - the date the user was modified.
Throws:
UnauthorizedException - if does not have administrator permissions.

getProperty

public java.lang.String getProperty(java.lang.String name)
Description copied from interface: User
Returns an extended property of the user. Each user can have an arbitrary number of extended properties. This lets particular skins or filters provide enhanced functionality that is not part of the base interface.

Specified by:
getProperty in interface User
Parameters:
name - the name of the property to get.
Returns:
the value of the property

setProperty

public void setProperty(java.lang.String name,
                        java.lang.String value)
Description copied from interface: User
Sets an extended property of the user. Each user can have an arbitrary number of extended properties. This lets particular skins or filters provide enhanced functionality that is not part of the base interface. Property names and values must be valid Strings. If null or an empty length String is used, a NullPointerException will be thrown.

Specified by:
setProperty in interface User
Parameters:
name - the name of the property to set.
value - the new value for the property.

deleteProperty

public void deleteProperty(java.lang.String name)
Description copied from interface: User
Deletes an extended property. If the property specified by name does not exist, this method will do nothing.

Specified by:
deleteProperty in interface User
Parameters:
name - the name of the property to delete.

getPropertyNames

public java.util.Iterator getPropertyNames()
Description copied from interface: User
Returns an Iterator for all the names of the extended user properties.

This method should typically be implemented as:

 if (auth.getUserID() == id) {
     return new Permissions(Permissions.USER_ADMIN);
 }
 else {
     return new Permissions(Permissions.NONE);
 }

Specified by:
getPropertyNames in interface User
Returns:
an Iterator for the property names.

getPermissions

public Permissions getPermissions(AuthToken auth)
Description copied from interface: User
Returns the permissions for the user that correspond to the passed-in AuthToken.

Specified by:
getPermissions in interface User
Parameters:
auth - the auth token to look up permissions with.

isAuthorized

public boolean isAuthorized(long permissionType)
Description copied from interface: User
Returns true if the handle on the object has the permission specified. A list of possible permissions can be found in the Permissions class. Certain methods of this class are restricted to certain permissions as specified in the method comments.

Because proxy objects will implement real security checking, this method should be implemented as:
return true;
.

Specified by:
isAuthorized in interface User
Parameters:
permissionType - the permission to check for.
See Also:
Permissions

getCachedSize

public int getCachedSize()
Description copied from interface: Cacheable
Returns the approximate size of the Object in bytes. The size should be considered to be a best estimate of how much memory the Object occupies and may be based on empirical trials or dynamic calculations.

Specified by:
getCachedSize in interface Cacheable
Returns:
the size of the Object in bytes.

toString

public java.lang.String toString()
Returns a String representation of the User object using the username.

Overrides:
toString in class java.lang.Object
Returns:
a String representation of the User object.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object object)
Overrides:
equals in class java.lang.Object

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.