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
FieldsModifier and TypeFieldDescriptionprotected StringThe description of this principal.protected intThe flags of this principal.protected CmsUUIDThe unique id of this principal.protected StringThe 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintcompareTo(I_CmsPrincipal obj) booleanCompares 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 thanuntouched.I_CmsPrincipal.FLAG_CORE_LIMITfilterCoreGroups(List<CmsGroup> groups) Filters out all groups with flags greater than.I_CmsPrincipal.FLAG_CORE_LIMITfilterCoreUsers(List<CmsUser> users) Filters out all users with flags greater than.I_CmsPrincipal.FLAG_CORE_LIMITstatic 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.intgetFlags()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 StringgetPrefixedGroup(String name) Returns the provided group name prefixed with.I_CmsPrincipal.PRINCIPAL_GROUP.Returns this principals unique name prefixed with it's type.static StringgetPrefixedUser(String name) Returns the provided user name prefixed with.I_CmsPrincipal.PRINCIPAL_USER.Returns the simple name of this organizational unit.static StringgetType(I_CmsPrincipal principal) Gets the type of a principal.inthashCode()Returns the hash code of this object.booleanReturnstrueif this principal is enabled.booleanisGroup()Returnstrueif this principal is of type.CmsGroupbooleanisUser()Returnstrueif this principal is of type.CmsUserstatic I_CmsPrincipalreadPrefixedPrincipal(CmsObject cms, String name) Utility function to read a prefixed principal from the OpenCms database using the provided OpenCms user context.static I_CmsPrincipalreadPrincipal(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_CmsPrincipalreadPrincipal(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_CmsPrincipalreadPrincipal(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_CmsPrincipalUtility function to read a principal by its id from the OpenCms database using the provided OpenCms user context.voidsetDescription(String description) Sets the description of this principal.voidsetEnabled(boolean enabled) Enables (or disables) this principal, depending on the given status.voidsetFlags(int value) Sets this principals flags to the specified value.voidSets the unique name of this principal.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods 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 thanuntouched.I_CmsPrincipal.FLAG_CORE_LIMITThe given parameter list is directly modified, so the returned list is the same object as the input list.
- Parameters:
principals- a list ofobjectsCmsPrincipalflag- the flag for filtering- Returns:
- the filtered principal list
-
filterCoreGroups
Filters out all groups with flags greater than.I_CmsPrincipal.FLAG_CORE_LIMITThe given parameter list is directly modified, so the returned list is the same object as the input list.
- Parameters:
groups- a list ofobjectsCmsGroup- Returns:
- the filtered principal list
-
filterCoreUsers
Filters out all users with flags greater than.I_CmsPrincipal.FLAG_CORE_LIMITThe given parameter list is directly modified, so the returned list is the same object as the input list.
- Parameters:
users- a list ofobjectsCmsUser- 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 ofobjectsCmsPrincipalflag- 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:
compareToin interfaceComparable<I_CmsPrincipal>- See Also:
-
equals
Description copied from interface:I_CmsPrincipalCompares the given object with this principal. -
getDescription
Description copied from interface:I_CmsPrincipalReturns the description of this principal.- Specified by:
getDescriptionin 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_CmsPrincipalReturns 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:
getFlagsin interfaceI_CmsPrincipal- Returns:
- the flags of this principal
- See Also:
-
getId
Description copied from interface:I_CmsPrincipalReturns the unique id of this principal.- Specified by:
getIdin interfaceI_CmsPrincipal- Returns:
- the unique id of this principal
- See Also:
-
getName
Returns the fully qualified name of this principal.- Specified by:
getNamein interfaceI_CmsPrincipal- Specified by:
getNamein interfacePrincipal- Returns:
- the fully qualified name of this principal
- See Also:
-
getOuFqn
Returns the fully qualified name of the associated organizational unit.- Specified by:
getOuFqnin interfaceI_CmsPrincipal- Returns:
- the fully qualified name of the associated organizational unit
-
getPrefixedName
Description copied from interface:I_CmsPrincipalReturns 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:
getPrefixedNamein 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:
getSimpleNamein interfaceI_CmsPrincipal- Returns:
- the simple name of this organizational unit.
-
hashCode
Description copied from interface:I_CmsPrincipalReturns the hash code of this object. -
isEnabled
Description copied from interface:I_CmsPrincipalReturnstrueif 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:
isEnabledin interfaceI_CmsPrincipal- Returns:
trueif this principal is enabled- See Also:
-
isGroup
Description copied from interface:I_CmsPrincipalReturnstrueif this principal is of type.CmsGroup- Specified by:
isGroupin interfaceI_CmsPrincipal- Returns:
trueif this principal is of typeCmsGroup- See Also:
-
isUser
Description copied from interface:I_CmsPrincipalReturnstrueif this principal is of type.CmsUser- Specified by:
isUserin interfaceI_CmsPrincipal- Returns:
trueif this principal is of typeCmsUser- See Also:
-
setDescription
Description copied from interface:I_CmsPrincipalSets the description of this principal.- Specified by:
setDescriptionin interfaceI_CmsPrincipal- Parameters:
description- the principal description to set- See Also:
-
setEnabled
Description copied from interface:I_CmsPrincipalEnables (or disables) this principal, depending on the given status.- Specified by:
setEnabledin interfaceI_CmsPrincipal- Parameters:
enabled- the principal status to set- See Also:
-
setFlags
Description copied from interface:I_CmsPrincipalSets 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:
setFlagsin interfaceI_CmsPrincipal- Parameters:
value- the value to set this principals flags to- See Also:
-
setName
Description copied from interface:I_CmsPrincipalSets the unique name of this principal.- Specified by:
setNamein interfaceI_CmsPrincipal- Parameters:
name- the unique name of this principal to set- See Also:
-