Class CmsPrincipal
- All Implemented Interfaces:
Serializable
,Comparable<I_CmsPrincipal>
,Principal
,I_CmsPrincipal
- Direct Known Subclasses:
CmsGroup
,CmsHistoryPrincipal
,CmsRoleAsPrincipal
,CmsUser
- Since:
- 6.2.0
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected String
The description of this principal.protected int
The flags of this principal.protected CmsUUID
The unique id of this principal.protected String
The fully qualified name of this principal.Fields 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
-
Method Summary
Modifier and TypeMethodDescriptionint
compareTo
(I_CmsPrincipal obj) boolean
Compares the given object with this principal.static List<? extends CmsPrincipal>
filterCoreFlag
(List<? extends CmsPrincipal> principals, int flag) Filters out all principals that do not have the given flag set, but leaving principals with flags less than
untouched.I_CmsPrincipal.FLAG_CORE_LIMIT
filterCoreGroups
(List<CmsGroup> groups) Filters out all groups with flags greater than
.I_CmsPrincipal.FLAG_CORE_LIMIT
filterCoreUsers
(List<CmsUser> users) Filters out all users with flags greater than
.I_CmsPrincipal.FLAG_CORE_LIMIT
static List<? extends CmsPrincipal>
filterFlag
(List<? extends CmsPrincipal> principals, int flag) Filters out all principals that do not have the given flag set.Returns the description of this principal.getDisplayName
(CmsObject cms, Locale locale) Returns the display name of this principal including the organizational unit.getDisplayName
(CmsObject cms, Locale locale, I_CmsGroupNameTranslation translation) Returns the translated display name of this principal if it is a group and the display name otherwise.int
getFlags()
Returns the flags of this principal.getId()
Returns the unique id of this principal.getName()
Returns the fully qualified name of this principal.getOuFqn()
Returns the fully qualified name of the associated organizational unit.static String
getPrefixedGroup
(String name) Returns the provided group name prefixed with
.I_CmsPrincipal.PRINCIPAL_GROUP
.Returns this principals unique name prefixed with it's type.static String
getPrefixedUser
(String name) Returns the provided user name prefixed with
.I_CmsPrincipal.PRINCIPAL_USER
.Returns the simple name of this organizational unit.static String
getType
(I_CmsPrincipal principal) Gets the type of a principal.int
hashCode()
Returns the hash code of this object.boolean
Returnstrue
if this principal is enabled.boolean
isGroup()
Returnstrue
if this principal is of type
.CmsGroup
boolean
isUser()
Returnstrue
if this principal is of type
.CmsUser
static I_CmsPrincipal
readPrefixedPrincipal
(CmsObject cms, String name) Utility function to read a prefixed principal from the OpenCms database using the provided OpenCms user context.static I_CmsPrincipal
readPrincipal
(CmsObject cms, String name) Utility function to read a principal by its id from the OpenCms database using the provided OpenCms user context.static I_CmsPrincipal
readPrincipal
(CmsObject cms, String type, String name) Utility function to read a principal of the given type from the OpenCms database using the provided OpenCms user context.static I_CmsPrincipal
readPrincipal
(CmsObject cms, CmsUUID id) Utility function to read a principal by its id from the OpenCms database using the provided OpenCms user context.static I_CmsPrincipal
Utility function to read a principal by its id from the OpenCms database using the provided OpenCms user context.void
setDescription
(String description) Sets the description of this principal.void
setEnabled
(boolean enabled) Enables (or disables) this principal, depending on the given status.void
setFlags
(int value) Sets this principals flags to the specified value.void
Sets the unique name of this principal.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.opencms.security.I_CmsPrincipal
checkName, getDescription
-
Field Details
-
m_description
The description of this principal. -
m_flags
The flags of this principal. -
m_id
The unique id of this principal. -
m_name
The fully qualified name of this principal.
-
-
Constructor Details
-
CmsPrincipal
protected CmsPrincipal()Empty constructor for subclassing.
-
-
Method Details
-
filterCoreFlag
public static List<? extends CmsPrincipal> filterCoreFlag(List<? extends CmsPrincipal> principals, int flag) Filters out all principals that do not have the given flag set, but leaving principals with flags less than
untouched.I_CmsPrincipal.FLAG_CORE_LIMIT
The given parameter list is directly modified, so the returned list is the same object as the input list.
- Parameters:
principals
- a list of
objectsCmsPrincipal
flag
- the flag for filtering- Returns:
- the filtered principal list
-
filterCoreGroups
Filters out all groups with flags greater than
.I_CmsPrincipal.FLAG_CORE_LIMIT
The given parameter list is directly modified, so the returned list is the same object as the input list.
- Parameters:
groups
- a list of
objectsCmsGroup
- Returns:
- the filtered principal list
-
filterCoreUsers
Filters out all users with flags greater than
.I_CmsPrincipal.FLAG_CORE_LIMIT
The given parameter list is directly modified, so the returned list is the same object as the input list.
- Parameters:
users
- a list of
objectsCmsUser
- Returns:
- the filtered principal list
-
filterFlag
public static List<? extends CmsPrincipal> filterFlag(List<? extends CmsPrincipal> principals, int flag) Filters out all principals that do not have the given flag set.The given parameter list is directly modified, so the returned list is the same object as the input list.
- Parameters:
principals
- the list of
objectsCmsPrincipal
flag
- the flag for filtering- Returns:
- the filtered principal list
-
getPrefixedGroup
Returns the provided group name prefixed with
.I_CmsPrincipal.PRINCIPAL_GROUP
.- Parameters:
name
- the name to add the prefix to- Returns:
- the provided group name prefixed with
I_CmsPrincipal.PRINCIPAL_GROUP
.
-
getPrefixedUser
Returns the provided user name prefixed with
.I_CmsPrincipal.PRINCIPAL_USER
.- Parameters:
name
- the name to add the prefix to- Returns:
- the provided user name prefixed with
I_CmsPrincipal.PRINCIPAL_USER
.
-
getType
Gets the type of a principal.- Parameters:
principal
- the principal- Returns:
- the principal type
-
readPrefixedPrincipal
Utility function to read a prefixed principal from the OpenCms database using the provided OpenCms user context.The principal must be either prefixed with
orI_CmsPrincipal.PRINCIPAL_GROUP
.
.I_CmsPrincipal.PRINCIPAL_USER
.- Parameters:
cms
- the OpenCms user context to use when reading the principalname
- the prefixed principal name- Returns:
- the principal read from the OpenCms database
- Throws:
CmsException
- in case the principal could not be read
-
readPrincipal
Utility function to read a principal by its id from the OpenCms database using the provided OpenCms user context.- Parameters:
cms
- the OpenCms user context to use when reading the principalid
- the id of the principal to read- Returns:
- the principal read from the OpenCms database
- Throws:
CmsException
- in case the principal could not be read
-
readPrincipal
Utility function to read a principal by its id from the OpenCms database using the provided OpenCms user context.- Parameters:
cms
- the OpenCms user context to use when reading the principalname
- the name of the principal to read- Returns:
- the principal read from the OpenCms database
- Throws:
CmsException
- in case the principal could not be read
-
readPrincipal
public static I_CmsPrincipal readPrincipal(CmsObject cms, String type, String name) throws CmsException Utility function to read a principal of the given type from the OpenCms database using the provided OpenCms user context.The type must either be
orI_CmsPrincipal.PRINCIPAL_GROUP
.I_CmsPrincipal.PRINCIPAL_USER
- Parameters:
cms
- the OpenCms user context to use when reading the principaltype
- the principal typename
- the principal name- Returns:
- the principal read from the OpenCms database
- Throws:
CmsException
- in case the principal could not be read
-
readPrincipalIncludingHistory
public static I_CmsPrincipal readPrincipalIncludingHistory(CmsObject cms, CmsUUID id) throws CmsException Utility function to read a principal by its id from the OpenCms database using the provided OpenCms user context.- Parameters:
cms
- the OpenCms user context to use when reading the principalid
- the id of the principal to read- Returns:
- the principal read from the OpenCms database
- Throws:
CmsException
- in case the principal could not be read
-
compareTo
- Specified by:
compareTo
in interfaceComparable<I_CmsPrincipal>
- See Also:
-
equals
Description copied from interface:I_CmsPrincipal
Compares the given object with this principal. -
getDescription
Description copied from interface:I_CmsPrincipal
Returns the description of this principal.- Specified by:
getDescription
in interfaceI_CmsPrincipal
- Returns:
- the description of this principal
- See Also:
-
getDisplayName
Returns the display name of this principal including the organizational unit.- 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
-
getDisplayName
public String getDisplayName(CmsObject cms, Locale locale, I_CmsGroupNameTranslation translation) throws CmsException Returns the translated display name of this principal if it is a group and the display name otherwise.- Parameters:
cms
- the current CMS contextlocale
- the localetranslation
- the group name translation to use- Returns:
- the translated display name
- Throws:
CmsException
- if something goes wrong
-
getFlags
Description copied from interface:I_CmsPrincipal
Returns the flags of this principal.The principal flags are used to store special information about the principals state encoded bitwise. Usually the flags int value should not be directly accessed. Utility methods like
provide a much easier way to access the information contained in the flags.I_CmsPrincipal.isEnabled()
- Specified by:
getFlags
in interfaceI_CmsPrincipal
- Returns:
- the flags of this principal
- See Also:
-
getId
Description copied from interface:I_CmsPrincipal
Returns the unique id of this principal.- Specified by:
getId
in interfaceI_CmsPrincipal
- Returns:
- the unique id of this principal
- See Also:
-
getName
Returns the fully qualified name of this principal.- Specified by:
getName
in interfaceI_CmsPrincipal
- Specified by:
getName
in interfacePrincipal
- Returns:
- the fully qualified name of this principal
- See Also:
-
getOuFqn
Returns the fully qualified name of the associated organizational unit.- Specified by:
getOuFqn
in interfaceI_CmsPrincipal
- Returns:
- the fully qualified name of the associated organizational unit
-
getPrefixedName
Description copied from interface:I_CmsPrincipal
Returns this principals unique name prefixed with it's type.The type prefix can either be
(for groups) orI_CmsPrincipal.PRINCIPAL_GROUP
.
(for users).I_CmsPrincipal.PRINCIPAL_USER
.- Specified by:
getPrefixedName
in interfaceI_CmsPrincipal
- Returns:
- this principals unique name prefixed with this principals type
- See Also:
-
getSimpleName
Returns the simple name of this organizational unit.- Specified by:
getSimpleName
in interfaceI_CmsPrincipal
- Returns:
- the simple name of this organizational unit.
-
hashCode
Description copied from interface:I_CmsPrincipal
Returns the hash code of this object. -
isEnabled
Description copied from interface:I_CmsPrincipal
Returnstrue
if this principal is enabled.A principal may be disabled in order to disable it, for example to prevent logins of a user. If a principal is just disabled but not deleted, the credentials of the principal in the VFS are still valid.
- Specified by:
isEnabled
in interfaceI_CmsPrincipal
- Returns:
true
if this principal is enabled- See Also:
-
isGroup
Description copied from interface:I_CmsPrincipal
Returnstrue
if this principal is of type
.CmsGroup
- Specified by:
isGroup
in interfaceI_CmsPrincipal
- Returns:
true
if this principal is of typeCmsGroup
- See Also:
-
isUser
Description copied from interface:I_CmsPrincipal
Returnstrue
if this principal is of type
.CmsUser
- Specified by:
isUser
in interfaceI_CmsPrincipal
- Returns:
true
if this principal is of typeCmsUser
- See Also:
-
setDescription
Description copied from interface:I_CmsPrincipal
Sets the description of this principal.- Specified by:
setDescription
in interfaceI_CmsPrincipal
- Parameters:
description
- the principal description to set- See Also:
-
setEnabled
Description copied from interface:I_CmsPrincipal
Enables (or disables) this principal, depending on the given status.- Specified by:
setEnabled
in interfaceI_CmsPrincipal
- Parameters:
enabled
- the principal status to set- See Also:
-
setFlags
Description copied from interface:I_CmsPrincipal
Sets this principals flags to the specified value.The principal flags are used to store special information about the principals state encoded bitwise. Usually the flags integer value should not be directly accessed. Utility methods like
provide a much easier way to manipulate the information contained in the flags.I_CmsPrincipal.setEnabled(boolean)
- Specified by:
setFlags
in interfaceI_CmsPrincipal
- Parameters:
value
- the value to set this principals flags to- See Also:
-
setName
Description copied from interface:I_CmsPrincipal
Sets the unique name of this principal.- Specified by:
setName
in interfaceI_CmsPrincipal
- Parameters:
name
- the unique name of this principal to set- See Also:
-