public class CmsUser extends CmsPrincipal implements java.lang.Cloneable
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.
CmsGroup
,
Serialized FormModifier and Type | Field and Description |
---|---|
static int |
FLAG_ADDITIONAL_INFOS
Flag indicating changed additional infos.
|
static int |
FLAG_CORE_DATA
Flag indicating changed core data.
|
static int |
FLAG_LAST_LOGIN
Flag indicating a changed last login date.
|
m_description, m_flags, m_id, m_name
FLAG_CORE_LIMIT, FLAG_DISABLED, FLAG_ENABLED, FLAG_GROUP_ROLE, FLAG_GROUP_VIRTUAL, FLAG_USER_MANAGED, FLAG_USER_WEBUSER, PRINCIPAL_GROUP, PRINCIPAL_USER
Constructor and Description |
---|
CmsUser()
Creates a new, empty OpenCms user principal.
|
CmsUser(CmsUUID id,
java.lang.String name,
java.lang.String password,
java.lang.String firstname,
java.lang.String lastname,
java.lang.String email,
long lastlogin,
int flags,
long dateCreated,
java.util.Map<java.lang.String,java.lang.Object> additionalInfo)
Creates a new OpenCms user principal.
|
Modifier and Type | Method and Description |
---|---|
static void |
checkEmail(java.lang.String email)
Validates an email address.
|
void |
checkName(java.lang.String name)
Checks if the provided user name is a valid user name and can be used as an argument value
for
CmsPrincipal.setName(String) . |
static void |
checkZipCode(java.lang.String zipcode)
Validates a zip code.
|
CmsUser |
clone() |
void |
deleteAdditionalInfo(java.lang.String key)
Deletes a value from this users "additional information" storage map.
|
java.util.Map<java.lang.String,java.lang.Object> |
getAdditionalInfo()
Returns this users complete "additional information" storage map.
|
java.lang.Object |
getAdditionalInfo(java.lang.String key)
Returns a value from this users "additional information" storage map,
or
null if no value for the given key is available. |
java.lang.String |
getAddress()
Returns the address line of this user.
|
int |
getChanges(CmsUser oldUser)
Returns the changes of this user compared to the previous user data.
|
java.lang.String |
getCity()
Returns the city information of this user.
|
java.lang.String |
getCountry()
Returns the country information of this user.
|
long |
getDateCreated()
Returns the creation date.
|
java.lang.String |
getDescription()
Returns the description of this principal.
|
java.lang.String |
getDescription(java.util.Locale locale)
Returns the description of this organizational unit.
|
java.lang.String |
getDisplayName(CmsObject cms,
java.util.Locale locale)
Returns the display name of this principal including the organizational unit.
|
java.lang.String |
getEmail()
Returns the email address of this user.
|
java.lang.String |
getFirstname()
Returns the first name of this user.
|
java.lang.String |
getFullName()
Returns the "full" name of the this user in the format
"{firstname} {lastname} ({username})" . |
static java.lang.String |
getFullName(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. |
java.lang.String |
getInstitution()
Returns the institution information of this user.
|
long |
getLastlogin()
Returns the time of the last login of this user.
|
java.lang.String |
getLastname()
Returns the last name of this user.
|
java.lang.String |
getPassword()
Returns the encrypted user password.
|
java.lang.String |
getZipcode()
Returns the zip code information of this user.
|
static boolean |
hasChangedAdditionalInfos(int changes)
Checks whether the flag indicates additional info changes.
|
static boolean |
hasChangedCoreData(int changes)
Checks whether the flag indicates core data changes.
|
static boolean |
hasChangedLastLogin(int changes)
Checks whether the flag indicates last login date changes.
|
static boolean |
hasPrefix(java.lang.String principalName)
Checks if the given String starts with
I_CmsPrincipal.PRINCIPAL_USER followed by a dot. |
boolean |
isGroup()
Returns
true if this principal is of type . |
boolean |
isGuestUser()
Checks if this user is the default guest user.
|
boolean |
isManaged()
Returns
true if this user is not able to manage itself. |
boolean |
isTouched()
Returns
true if this user was touched. |
boolean |
isUser()
Returns
true if this principal is of type . |
boolean |
isWebuser()
Checks if the user is marked as webuser.
|
static java.lang.String |
removePrefix(java.lang.String principalName)
Removes the prefix if the given String starts with
I_CmsPrincipal.PRINCIPAL_USER followed by a dot. |
void |
setAdditionalInfo(java.util.Map<java.lang.String,java.lang.Object> additionalInfo)
Sets this users complete "additional information" storage map to the given value.
|
void |
setAdditionalInfo(java.lang.String key,
java.lang.Object value)
Stores a value in this users "additional information" storage map with the given access key.
|
void |
setAddress(java.lang.String address)
Sets the address line of this user.
|
void |
setCity(java.lang.String city)
Sets the city information of this user.
|
void |
setCountry(java.lang.String country)
Sets the country information of this user.
|
void |
setDescription(java.lang.String description)
Sets the description of this principal.
|
void |
setEmail(java.lang.String email)
Sets the email address of this user.
|
void |
setFirstname(java.lang.String firstname)
Sets the first name of this user.
|
void |
setInstitution(java.lang.String institution)
Sets the institution information of this user.
|
void |
setLastlogin(long value)
Sets the last login time stamp of this user.
|
void |
setLastname(java.lang.String lastname)
Sets the last name of this user.
|
void |
setManaged(boolean value)
Sets the managed flag for this user to the given value.
|
void |
setPassword(java.lang.String value)
Sets the password of this user.
|
void |
setZipcode(java.lang.String zipcode)
Sets the zip code information of this user.
|
java.lang.String |
toString() |
void |
touch()
Sets the "touched" status of this user to
true . |
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
public static final int FLAG_ADDITIONAL_INFOS
public static final int FLAG_CORE_DATA
public static final int FLAG_LAST_LOGIN
public CmsUser()
Mostly intended to be used with the org.opencms.workplace.tools.accounts.A_CmsEditUserDialog
.
public CmsUser(CmsUUID id, java.lang.String name, java.lang.String password, java.lang.String firstname, java.lang.String lastname, java.lang.String email, long lastlogin, int flags, long dateCreated, java.util.Map<java.lang.String,java.lang.Object> additionalInfo)
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 informationpublic static void checkEmail(java.lang.String email)
That means, the parameter should only be composed by digits and standard english letters, points, underscores and exact one "At" symbol.
email
- the email to validatepublic static void checkZipCode(java.lang.String zipcode)
That means, the parameter should only be composed by digits and standard english letters.
zipcode
- the zip code to validatepublic static java.lang.String getFullName(CmsUser user)
"{firstname} {lastname} ({username})"
,
or the empty String ""
if the user is null.user
- the user to get the full name fromgetFullName()
public static boolean hasChangedAdditionalInfos(int changes)
changes
- the changes flagstrue
in case the additional infos changedpublic static boolean hasChangedCoreData(int changes)
changes
- the changes flagstrue
in case the core data changedpublic static boolean hasChangedLastLogin(int changes)
changes
- the changes flagstrue
in case the last login date changedpublic static boolean hasPrefix(java.lang.String principalName)
I_CmsPrincipal.PRINCIPAL_USER
followed by a dot.
null
.
principalName
- the user name to checktrue
in case the String starts with I_CmsPrincipal.PRINCIPAL_USER
followed by a dotpublic static java.lang.String removePrefix(java.lang.String principalName)
I_CmsPrincipal.PRINCIPAL_USER
followed by a dot.
null
.
I_CmsPrincipal.PRINCIPAL_USER
followed by a dot it is returned unchanged.
principalName
- the user name to remove the prefix fromI_CmsPrincipal.PRINCIPAL_USER
and the following dot removedpublic void checkName(java.lang.String name) throws CmsIllegalArgumentException
CmsPrincipal.setName(String)
.checkName
in interface I_CmsPrincipal
name
- the user name to checkCmsIllegalArgumentException
- if the check failspublic void deleteAdditionalInfo(java.lang.String key)
key
- the additional user information to deletegetAdditionalInfo()
public java.util.Map<java.lang.String,java.lang.Object> getAdditionalInfo()
The "additional information" storage map is a simple Map
that 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.
public java.lang.Object getAdditionalInfo(java.lang.String key)
null
if no value for the given key is available.key
- selects the value to return from the "additional information" storage mapgetAdditionalInfo()
public java.lang.String getAddress()
public int getChanges(CmsUser oldUser)
oldUser
- the old userpublic java.lang.String getCity()
This information is stored in the "additional information" storage map
using the key
.CmsUserSettings.ADDITIONAL_INFO_CITY
public java.lang.String getCountry()
This information is stored in the "additional information" storage map
using the key
.CmsUserSettings.ADDITIONAL_INFO_COUNTRY
public long getDateCreated()
public java.lang.String getDescription()
I_CmsPrincipal
getDescription
in interface I_CmsPrincipal
getDescription
in class CmsPrincipal
CmsPrincipal.getDescription()
public java.lang.String getDescription(java.util.Locale locale)
getDescription
in interface I_CmsPrincipal
locale
- the localepublic java.lang.String getDisplayName(CmsObject cms, java.util.Locale locale) throws CmsException
CmsPrincipal
getDisplayName
in class CmsPrincipal
cms
- the cms contextlocale
- the localeCmsException
- if the organizational unit could not be readCmsPrincipal.getDisplayName(org.opencms.file.CmsObject, java.util.Locale)
public java.lang.String getEmail()
public java.lang.String getFirstname()
public java.lang.String getFullName()
"{firstname} {lastname} ({username})"
.public java.lang.String getInstitution()
This information is stored in the "additional information" storage map
using the key
.CmsUserSettings.ADDITIONAL_INFO_INSTITUTION
public long getLastlogin()
public java.lang.String getLastname()
public java.lang.String getPassword()
public java.lang.String getZipcode()
This information is stored in the "additional information" storage map
using the key
.CmsUserSettings.ADDITIONAL_INFO_ZIPCODE
public boolean isGroup()
I_CmsPrincipal
true
if this principal is of type CmsGroup
.isGroup
in interface I_CmsPrincipal
isGroup
in class CmsPrincipal
true
if this principal is of type CmsGroup
I_CmsPrincipal.isGroup()
public boolean isGuestUser()
true
if this user is the default guest userpublic boolean isManaged()
true
if this user is not able to manage itself.true
if this user is not able to manage itselfpublic boolean isTouched()
true
if this user was touched.public boolean isUser()
I_CmsPrincipal
true
if this principal is of type CmsUser
.isUser
in interface I_CmsPrincipal
isUser
in class CmsPrincipal
true
if this principal is of type CmsUser
I_CmsPrincipal.isUser()
public boolean isWebuser()
true
if the user is marked as webuserpublic void setAdditionalInfo(java.util.Map<java.lang.String,java.lang.Object> additionalInfo)
additionalInfo
- the complete "additional information" map to setgetAdditionalInfo()
public void setAdditionalInfo(java.lang.String key, java.lang.Object value)
key
- the key to store the value undervalue
- the value to store in the users "additional information" storage mapgetAdditionalInfo()
public void setAddress(java.lang.String address)
address
- the address line to setpublic void setCity(java.lang.String city)
city
- the city information to setpublic void setCountry(java.lang.String country)
country
- the city information to setpublic void setDescription(java.lang.String description)
I_CmsPrincipal
setDescription
in interface I_CmsPrincipal
setDescription
in class CmsPrincipal
description
- the principal description to setCmsPrincipal.setDescription(java.lang.String)
public void setEmail(java.lang.String email)
email
- the email address to setpublic void setFirstname(java.lang.String firstname)
firstname
- the name to setpublic void setInstitution(java.lang.String institution)
institution
- the institution information to setpublic void setLastlogin(long value)
value
- the last login time stamp to setpublic void setLastname(java.lang.String lastname)
lastname
- the name to setpublic void setManaged(boolean value)
value
- the value to setpublic void setPassword(java.lang.String value)
value
- the password to setpublic void setZipcode(java.lang.String zipcode)
zipcode
- the zip code information to setpublic java.lang.String toString()
toString
in interface java.security.Principal
toString
in class java.lang.Object
Object.toString()
public void touch()
true
.