Package org.jivesoftware.openfire.user
Class User
- java.lang.Object
-
- org.jivesoftware.openfire.user.User
-
- All Implemented Interfaces:
Externalizable
,Serializable
,Cacheable
,org.xmpp.resultsetmanagement.Result
public class User extends Object implements Cacheable, Externalizable, org.xmpp.resultsetmanagement.Result
Encapsulates information about a user. New users are created usingUserManager.createUser(String, String, String, String)
. The currently-installedUserProvider
is used for setting all other user data and some operations may not be supported depending on the capabilities of theUserProvider
. All user properties are loaded on demand from the currently-installedUserPropertyProvider
.- Author:
- Matt Tucker
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object object)
int
getCachedSize()
Returns the approximate size of the Object in bytes.Date
getCreationDate()
String
getEmail()
Returns the email address of the user ornull
if none is defined.int
getIterations()
Date
getModificationDate()
String
getName()
Map<String,String>
getProperties()
Returns all extended properties of the user.static String
getPropertyValue(String username, String propertyName)
Returns the value of the specified property for the given username.Roster
getRoster()
Returns the user's roster.String
getSalt()
String
getServerKey()
String
getStoredKey()
String
getUID()
String
getUsername()
Returns this user's username.int
hashCode()
boolean
isEmailVisible()
Returns true if email is visible to everyone or not.boolean
isNameVisible()
Returns true if name is visible to everyone or not.void
readExternal(ObjectInput in)
void
setCreationDate(Date creationDate)
void
setEmail(String email)
void
setEmailVisible(boolean visible)
Sets if the email is visible to everyone or not.void
setIterations(int iterations)
void
setModificationDate(Date modificationDate)
void
setName(String name)
void
setNameVisible(boolean visible)
Sets if name is visible to everyone or not.void
setPassword(String password)
Sets a new password for this user.void
setSalt(String salt)
void
setServerKey(String serverKey)
void
setStoredKey(String storedKey)
String
toString()
void
writeExternal(ObjectOutput out)
-
-
-
Constructor Detail
-
User
public User()
Constructor added for Externalizable. Do not use this constructor.
-
User
public User(String username, String name, String email, Date creationDate, Date modificationDate)
Constructs a new user. Normally, all arguments can benull
except the username. However, a UserProvider -may- require a name or email address. In those cases, the isNameRequired or isEmailRequired UserProvider tests indicate whethernull
is allowed. Typically, User objects should not be constructed by end-users of the API. Instead, user objects should be retrieved usingUserManager.getUser(String)
.- Parameters:
username
- the username.name
- the name.email
- the email address.creationDate
- the date the user was created.modificationDate
- the date the user was last modified.
-
-
Method Detail
-
getPropertyValue
public static String getPropertyValue(String username, String propertyName) throws UserNotFoundException
Returns the value of the specified property for the given username. This method is an optimization to avoid loading a user to get a specific property.- Parameters:
username
- the username of the user to get a specific property value.propertyName
- the name of the property to return its value.- Returns:
- the value of the specified property for the given username.
- Throws:
UserNotFoundException
- Depending on the installed user provider (some will return null instead).
-
getUsername
public String getUsername()
Returns this user's username.- Returns:
- the username..
-
setPassword
public void setPassword(String password) throws UnsupportedOperationException
Sets a new password for this user.- Parameters:
password
- the new password for the user.- Throws:
UnsupportedOperationException
- exception
-
getStoredKey
public String getStoredKey()
-
setStoredKey
public void setStoredKey(String storedKey)
-
getServerKey
public String getServerKey()
-
setServerKey
public void setServerKey(String serverKey)
-
getSalt
public String getSalt()
-
setSalt
public void setSalt(String salt)
-
getIterations
public int getIterations()
-
setIterations
public void setIterations(int iterations)
-
getName
public String getName()
-
setName
public void setName(String name)
-
isNameVisible
public boolean isNameVisible()
Returns true if name is visible to everyone or not.- Returns:
- true if name is visible to everyone, false if not.
-
setNameVisible
public void setNameVisible(boolean visible)
Sets if name is visible to everyone or not.- Parameters:
visible
- true if name is visible, false if not.
-
getEmail
public String getEmail()
Returns the email address of the user ornull
if none is defined.- Returns:
- the email address of the user or null if none is defined.
-
setEmail
public void setEmail(String email)
-
isEmailVisible
public boolean isEmailVisible()
Returns true if email is visible to everyone or not.- Returns:
- true if email is visible to everyone, false if not.
-
setEmailVisible
public void setEmailVisible(boolean visible)
Sets if the email is visible to everyone or not.- Parameters:
visible
- true if the email is visible, false if not.
-
getCreationDate
public Date getCreationDate()
-
setCreationDate
public void setCreationDate(Date creationDate)
-
getModificationDate
public Date getModificationDate()
-
setModificationDate
public void setModificationDate(Date modificationDate)
-
getProperties
public Map<String,String> getProperties()
Returns all extended properties of the user. Users have an arbitrary number of extended properties. The returned collection can be modified to add new properties or remove existing ones.- Returns:
- the extended properties.
-
getRoster
public Roster getRoster()
Returns the user's roster. A roster is a list of users that the user wishes to know if they are online. Rosters are similar to buddy groups in popular IM clients.- Returns:
- the user's roster.
-
getCachedSize
public int getCachedSize() throws CannotCalculateSizeException
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 interfaceCacheable
- Returns:
- the size of the Object in bytes.
- Throws:
CannotCalculateSizeException
- if the size cannot be calculated
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-
getUID
public String getUID()
- Specified by:
getUID
in interfaceorg.xmpp.resultsetmanagement.Result
-
-