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 using
UserManager.createUser(String, String, String, String).
The currently-installed UserProvider is used for setting all other user data and some operations may not be
supported depending on the capabilities of the UserProvider.
All user properties are loaded on demand from the currently-installed
UserPropertyProvider.- Author:
- Matt Tucker
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanintReturns the approximate size of the Object in bytes.getEmail()Returns the email address of the user ornullif none is defined.intDeprecated, for removal: This API element is subject to removal in a future version.This accessor exposes only the SCRAM-SHA-1 credential.getName()Returns all extended properties of the user.static StringgetPropertyValue(String username, String propertyName) Returns the value of the specified property for the given username.Returns the user's roster.getSalt()Deprecated, for removal: This API element is subject to removal in a future version.This accessor exposes only the SCRAM-SHA-1 credential.Deprecated, for removal: This API element is subject to removal in a future version.This accessor exposes only the SCRAM-SHA-1 credential.Deprecated, for removal: This API element is subject to removal in a future version.This accessor exposes only the SCRAM-SHA-1 credential.getUID()Returns this user's username.inthashCode()booleanReturns true if email is visible to everyone or not.booleanReturns true if name is visible to everyone or not.voidvoidsetCreationDate(Date creationDate) voidvoidsetEmailVisible(boolean visible) Sets if the email is visible to everyone or not.voidsetIterations(int iterations) Deprecated, for removal: This API element is subject to removal in a future version.This accessor exposes only the SCRAM-SHA-1 credential.voidsetModificationDate(Date modificationDate) voidvoidsetNameVisible(boolean visible) Sets if name is visible to everyone or not.voidsetPassword(String password) Sets a new password for this user.voidDeprecated, for removal: This API element is subject to removal in a future version.This accessor exposes only the SCRAM-SHA-1 credential.voidsetServerKey(String serverKey) Deprecated, for removal: This API element is subject to removal in a future version.This accessor exposes only the SCRAM-SHA-1 credential.voidsetStoredKey(String storedKey) Deprecated, for removal: This API element is subject to removal in a future version.This accessor exposes only the SCRAM-SHA-1 credential.toString()void
-
Constructor Details
-
User
public User()Constructor added for Externalizable. Do not use this constructor. -
User
Constructs a new user. Normally, all arguments can benullexcept the username. However, a UserProvider -may- require a name or email address. In those cases, the isNameRequired or isEmailRequired UserProvider tests indicate whethernullis 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 Details
-
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
Returns this user's username.- Returns:
- the username..
-
setPassword
Sets a new password for this user.- Parameters:
password- the new password for the user.- Throws:
UnsupportedOperationException- exception
-
getStoredKey
Deprecated, for removal: This API element is subject to removal in a future version.This accessor exposes only the SCRAM-SHA-1 credential. SCRAM credentials are stored per mechanism (see theofUserScramtable) and should be obtained through the authentication provider rather than from theUserobject. Retained for backwards compatibility with third-party integrations.Returns the SCRAM-SHA-1 stored key for this user, ornullif the user has no SCRAM-SHA-1 credential.- Returns:
- the SCRAM-SHA-1 stored key, or
null.
-
setStoredKey
Deprecated, for removal: This API element is subject to removal in a future version.This accessor exposes only the SCRAM-SHA-1 credential. SeegetStoredKey().Sets the SCRAM-SHA-1 stored key for this user.- Parameters:
storedKey- the SCRAM-SHA-1 stored key.
-
getServerKey
Deprecated, for removal: This API element is subject to removal in a future version.This accessor exposes only the SCRAM-SHA-1 credential. SCRAM credentials are stored per mechanism (see theofUserScramtable) and should be obtained through the authentication provider rather than from theUserobject. Retained for backwards compatibility with third-party integrations.Returns the SCRAM-SHA-1 server key for this user, ornullif the user has no SCRAM-SHA-1 credential.- Returns:
- the SCRAM-SHA-1 server key, or
null.
-
setServerKey
Deprecated, for removal: This API element is subject to removal in a future version.This accessor exposes only the SCRAM-SHA-1 credential. SeegetServerKey().Sets the SCRAM-SHA-1 server key for this user.- Parameters:
serverKey- the SCRAM-SHA-1 server key.
-
getSalt
Deprecated, for removal: This API element is subject to removal in a future version.This accessor exposes only the SCRAM-SHA-1 credential. SCRAM credentials are stored per mechanism (see theofUserScramtable) and should be obtained through the authentication provider rather than from theUserobject. Retained for backwards compatibility with third-party integrations.Returns the SCRAM-SHA-1 salt for this user, ornullif the user has no SCRAM-SHA-1 credential.- Returns:
- the SCRAM-SHA-1 salt, or
null.
-
setSalt
Deprecated, for removal: This API element is subject to removal in a future version.This accessor exposes only the SCRAM-SHA-1 credential. SeegetSalt().Sets the SCRAM-SHA-1 salt for this user.- Parameters:
salt- the SCRAM-SHA-1 salt.
-
getIterations
Deprecated, for removal: This API element is subject to removal in a future version.This accessor exposes only the SCRAM-SHA-1 credential. SCRAM credentials are stored per mechanism (see theofUserScramtable) and should be obtained through the authentication provider rather than from theUserobject. Retained for backwards compatibility with third-party integrations.Returns the SCRAM-SHA-1 iteration count for this user, or0if the user has no SCRAM-SHA-1 credential.- Returns:
- the SCRAM-SHA-1 iteration count, or
0.
-
setIterations
Deprecated, for removal: This API element is subject to removal in a future version.This accessor exposes only the SCRAM-SHA-1 credential. SeegetIterations().Sets the SCRAM-SHA-1 iteration count for this user.- Parameters:
iterations- the SCRAM-SHA-1 iteration count.
-
getName
-
setName
-
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
Returns the email address of the user ornullif none is defined.- Returns:
- the email address of the user or null if none is defined.
-
setEmail
-
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
-
setCreationDate
-
getModificationDate
-
setModificationDate
-
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
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
Description copied from interface:CacheableReturns 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:
getCachedSizein interfaceCacheable- Returns:
- the size of the Object in bytes.
- Throws:
CannotCalculateSizeException- if the size cannot be calculated
-
toString
-
hashCode
public int hashCode() -
equals
-
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
getUID
- Specified by:
getUIDin interfaceorg.xmpp.resultsetmanagement.Result
-