Class CmsUser
- All Implemented Interfaces:
Serializable,Cloneable,Comparable<I_CmsPrincipal>,Principal,I_CmsPrincipal
A user in OpenCms is uniquely defined by its user named returned by
.CmsPrincipal.getName()
Basic users in OpenCms are users that can access the OpenCms Workplace.
Moreover, the user must be created by another user with the
role.
These users are "content managers" that actually have write permissions in
at last some parts of the VFS.CmsRole.ACCOUNT_MANAGER
Another possibility is to have users in a 'Guests' group. These users do not have access to the OpenCms Workplace. However, an user in a 'Guests' group can be created by every user, for example the "Guest" user. The main use case is that these users are used for users of the website that can generate their own accounts, in a "please register your account..." scenario. These user accounts can then be used to build personalized web sites.
- Since:
- 6.0.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intFlag indicating changed additional infos.static final intFlag indicating changed core data.static final intFlag indicating a changed last login date.Fields inherited from class org.opencms.security.CmsPrincipal
m_description, m_flags, m_id, m_nameFields inherited from interface org.opencms.security.I_CmsPrincipal
FLAG_CORE_LIMIT, FLAG_DISABLED, FLAG_ENABLED, FLAG_GROUP_ROLE, FLAG_GROUP_VIRTUAL, FLAG_USER_MANAGED, FLAG_USER_WEBUSER, PRINCIPAL_GROUP, PRINCIPAL_USER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckEmail(String email) Validates an email address.voidChecks if the provided user name is a valid user name and can be used as an argument value forCmsPrincipal.setName(String).static voidcheckZipCode(String zipcode) Validates a zip code.clone()voidDeletes a value from this users "additional information" storage map.Returns this users complete "additional information" storage map.getAdditionalInfo(String key) Returns a value from this users "additional information" storage map, ornullif no value for the given key is available.Returns the address line of this user.intgetChanges(CmsUser oldUser) Returns the changes of this user compared to the previous user data.getCity()Returns the city information of this user.Returns the country information of this user.longReturns the creation date.Returns the description of this principal.getDescription(Locale locale) Returns the description of this organizational unit.getDisplayName(CmsObject cms, Locale locale) Returns the display name of this principal including the organizational unit.getEmail()Returns the email address of this user.Returns the first name of this user.Returns the "full" name of the this user in the format"{firstname} {lastname} ({username})".static StringgetFullName(CmsUser user) Returns the "full" name of the given user in the format"{firstname} {lastname} ({username})", or the empty String""if the user is null.Returns the institution information of this user.longReturns the time of the last login of this user.Returns the last name of this user.Returns the encrypted user password.Returns the zip code information of this user.static booleanhasChangedAdditionalInfos(int changes) Checks whether the flag indicates additional info changes.static booleanhasChangedCoreData(int changes) Checks whether the flag indicates core data changes.static booleanhasChangedLastLogin(int changes) Checks whether the flag indicates last login date changes.static booleanChecks if the given String starts withI_CmsPrincipal.PRINCIPAL_USERfollowed by a dot.booleanisGroup()Returnstrueif this principal is of type.CmsGroupbooleanChecks if this user is the default guest user.booleanReturnstrueif this user is not able to manage itself.booleanReturnstrueif this user was touched.booleanisUser()Returnstrueif this principal is of type.CmsUserbooleanChecks if the user is marked as webuser.static StringremovePrefix(String principalName) Removes the prefix if the given String starts withI_CmsPrincipal.PRINCIPAL_USERfollowed by a dot.voidsetAdditionalInfo(String key, Object value) Stores a value in this users "additional information" storage map with the given access key.voidsetAdditionalInfo(Map<String, Object> additionalInfo) Sets this users complete "additional information" storage map to the given value.voidsetAddress(String address) Sets the address line of this user.voidSets the city information of this user.voidsetCountry(String country) Sets the country information of this user.voidsetDescription(String description) Sets the description of this principal.voidSets the email address of this user.voidsetFirstname(String firstname) Sets the first name of this user.voidsetInstitution(String institution) Sets the institution information of this user.voidsetLastlogin(long value) Sets the last login time stamp of this user.voidsetLastname(String lastname) Sets the last name of this user.voidsetManaged(boolean value) Sets the managed flag for this user to the given value.voidsetPassword(String value) Sets the password of this user.voidsetZipcode(String zipcode) Sets the zip code information of this user.toString()voidtouch()Sets the "touched" status of this user totrue.Methods inherited from class org.opencms.security.CmsPrincipal
compareTo, equals, filterCoreFlag, filterCoreGroups, filterCoreUsers, filterFlag, getDisplayName, getFlags, getId, getName, getOuFqn, getPrefixedGroup, getPrefixedName, getPrefixedUser, getSimpleName, getType, hashCode, isEnabled, readPrefixedPrincipal, readPrincipal, readPrincipal, readPrincipal, readPrincipalIncludingHistory, setEnabled, setFlags, setName
-
Field Details
-
FLAG_ADDITIONAL_INFOS
Flag indicating changed additional infos.- See Also:
-
FLAG_CORE_DATA
Flag indicating changed core data.- See Also:
-
FLAG_LAST_LOGIN
Flag indicating a changed last login date.- See Also:
-
-
Constructor Details
-
CmsUser
public CmsUser()Creates a new, empty OpenCms user principal.Mostly intended to be used with the
org.opencms.workplace.tools.accounts.A_CmsEditUserDialog. -
CmsUser
public CmsUser(CmsUUID id, String name, String password, String firstname, String lastname, String email, long lastlogin, int flags, long dateCreated, Map<String, Object> additionalInfo) Creates a new OpenCms user principal.- Parameters:
id- the unique id of the new username- the fully qualified name of the new userpassword- the password of the userfirstname- the first namelastname- the last nameemail- the email addresslastlogin- time stampflags- flagsdateCreated- the creation dateadditionalInfo- user related information
-
-
Method Details
-
checkEmail
Validates an email address.That means, the parameter should only be composed by digits and standard english letters, points, underscores and exact one "At" symbol.
- Parameters:
email- the email to validate
-
checkZipCode
Validates a zip code.That means, the parameter should only be composed by digits and standard english letters.
- Parameters:
zipcode- the zip code to validate
-
getFullName
Returns the "full" name of the given user in the format"{firstname} {lastname} ({username})", or the empty String""if the user is null.- Parameters:
user- the user to get the full name from- Returns:
- the "full" name the user
- See Also:
-
hasChangedAdditionalInfos
Checks whether the flag indicates additional info changes.- Parameters:
changes- the changes flags- Returns:
truein case the additional infos changed
-
hasChangedCoreData
Checks whether the flag indicates core data changes.- Parameters:
changes- the changes flags- Returns:
truein case the core data changed
-
hasChangedLastLogin
Checks whether the flag indicates last login date changes.- Parameters:
changes- the changes flags- Returns:
truein case the last login date changed
-
hasPrefix
Checks if the given String starts withI_CmsPrincipal.PRINCIPAL_USERfollowed by a dot.- Works if the given String is
null. - Removes white spaces around the String before the check.
- Also works with prefixes not being in upper case.
- Does not check if the user after the prefix actually exists.
- Parameters:
principalName- the user name to check- Returns:
truein case the String starts withI_CmsPrincipal.PRINCIPAL_USERfollowed by a dot
- Works if the given String is
-
removePrefix
Removes the prefix if the given String starts withI_CmsPrincipal.PRINCIPAL_USERfollowed by a dot.- Works if the given String is
null. - If the given String does not start with
I_CmsPrincipal.PRINCIPAL_USERfollowed by a dot it is returned unchanged. - Removes white spaces around the user name.
- Also works with prefixes not being in upper case.
- Does not check if the user after the prefix actually exists.
- Parameters:
principalName- the user name to remove the prefix from- Returns:
- the given String with the prefix
I_CmsPrincipal.PRINCIPAL_USERand the following dot removed
- Works if the given String is
-
checkName
Checks if the provided user name is a valid user name and can be used as an argument value forCmsPrincipal.setName(String).- Specified by:
checkNamein interfaceI_CmsPrincipal- Parameters:
name- the user name to check- Throws:
CmsIllegalArgumentException- if the check fails
-
clone
-
deleteAdditionalInfo
Deletes a value from this users "additional information" storage map.- Parameters:
key- the additional user information to delete- See Also:
-
getAdditionalInfo
Returns this users complete "additional information" storage map.The "additional information" storage map is a simple
Mapthat can be used to store any key / value pairs for the user. Some information parts of the users address are stored in this map by default.- Returns:
- this users complete "additional information" storage map
-
getAdditionalInfo
Returns a value from this users "additional information" storage map, ornullif no value for the given key is available.- Parameters:
key- selects the value to return from the "additional information" storage map- Returns:
- the selected value from this users "additional information" storage map
- See Also:
-
getAddress
Returns the address line of this user.- Returns:
- the address line of this user
-
getChanges
Returns the changes of this user compared to the previous user data.- Parameters:
oldUser- the old user- Returns:
- the changes flags
-
getCity
Returns the city information of this user.This information is stored in the "additional information" storage map using the key
.CmsUserSettings.ADDITIONAL_INFO_CITY- Returns:
- the city information of this user
-
getCountry
Returns the country information of this user.This information is stored in the "additional information" storage map using the key
.CmsUserSettings.ADDITIONAL_INFO_COUNTRY- Returns:
- the country information of this user
-
getDateCreated
Returns the creation date.- Returns:
- the creation date
-
getDescription
Description copied from interface:I_CmsPrincipalReturns the description of this principal.- Specified by:
getDescriptionin interfaceI_CmsPrincipal- Overrides:
getDescriptionin classCmsPrincipal- Returns:
- the description of this principal
- See Also:
-
getDescription
Returns the description of this organizational unit.- Specified by:
getDescriptionin interfaceI_CmsPrincipal- Parameters:
locale- the locale- Returns:
- the description of this organizational unit
-
getDisplayName
Description copied from class:CmsPrincipalReturns the display name of this principal including the organizational unit.- Overrides:
getDisplayNamein classCmsPrincipal- Parameters:
cms- the cms contextlocale- the locale- Returns:
- the display name of this principal including the organizational unit
- Throws:
CmsException- if the organizational unit could not be read- See Also:
-
getEmail
Returns the email address of this user.- Returns:
- the email address of this user
-
getFirstname
Returns the first name of this user.- Returns:
- the first name of this user
-
getFullName
Returns the "full" name of the this user in the format"{firstname} {lastname} ({username})".- Returns:
- the "full" name this user
-
getInstitution
Returns the institution information of this user.This information is stored in the "additional information" storage map using the key
.CmsUserSettings.ADDITIONAL_INFO_INSTITUTION- Returns:
- the institution information of this user
-
getLastlogin
Returns the time of the last login of this user.- Returns:
- the time of the last login of this user
-
getLastname
Returns the last name of this user.- Returns:
- the last name of this user
-
getPassword
Returns the encrypted user password.- Returns:
- the encrypted user password
-
getZipcode
Returns the zip code information of this user.This information is stored in the "additional information" storage map using the key
.CmsUserSettings.ADDITIONAL_INFO_ZIPCODE- Returns:
- the zip code information of this user
-
isGroup
Description copied from interface:I_CmsPrincipalReturnstrueif this principal is of type.CmsGroup- Specified by:
isGroupin interfaceI_CmsPrincipal- Overrides:
isGroupin classCmsPrincipal- Returns:
trueif this principal is of typeCmsGroup- See Also:
-
isGuestUser
Checks if this user is the default guest user.- Returns:
trueif this user is the default guest user
-
isManaged
Returnstrueif this user is not able to manage itself.- Returns:
trueif this user is not able to manage itself
-
isTouched
Returnstrueif this user was touched.- Returns:
- boolean true if this user was touched
-
isUser
Description copied from interface:I_CmsPrincipalReturnstrueif this principal is of type.CmsUser- Specified by:
isUserin interfaceI_CmsPrincipal- Overrides:
isUserin classCmsPrincipal- Returns:
trueif this principal is of typeCmsUser- See Also:
-
isWebuser
Checks if the user is marked as webuser.- Returns:
trueif the user is marked as webuser
-
setAdditionalInfo
Sets this users complete "additional information" storage map to the given value.- Parameters:
additionalInfo- the complete "additional information" map to set- See Also:
-
setAdditionalInfo
Stores a value in this users "additional information" storage map with the given access key.- Parameters:
key- the key to store the value undervalue- the value to store in the users "additional information" storage map- See Also:
-
setAddress
Sets the address line of this user.- Parameters:
address- the address line to set
-
setCity
Sets the city information of this user.- Parameters:
city- the city information to set
-
setCountry
Sets the country information of this user.- Parameters:
country- the city information to set
-
setDescription
Description copied from interface:I_CmsPrincipalSets the description of this principal.- Specified by:
setDescriptionin interfaceI_CmsPrincipal- Overrides:
setDescriptionin classCmsPrincipal- Parameters:
description- the principal description to set- See Also:
-
setEmail
Sets the email address of this user.- Parameters:
email- the email address to set
-
setFirstname
Sets the first name of this user.- Parameters:
firstname- the name to set
-
setInstitution
Sets the institution information of this user.- Parameters:
institution- the institution information to set
-
setLastlogin
Sets the last login time stamp of this user.- Parameters:
value- the last login time stamp to set
-
setLastname
Sets the last name of this user.- Parameters:
lastname- the name to set
-
setManaged
Sets the managed flag for this user to the given value.- Parameters:
value- the value to set
-
setPassword
Sets the password of this user.- Parameters:
value- the password to set
-
setZipcode
Sets the zip code information of this user.- Parameters:
zipcode- the zip code information to set
-
toString
-
touch
Sets the "touched" status of this user totrue.
-