Class CmsPrincipal

    • Field Detail

      • m_description

        protected java.lang.String m_description
        The description of this principal.
      • m_flags

        protected int m_flags
        The flags of this principal.
      • m_id

        protected CmsUUID m_id
        The unique id of this principal.
      • m_name

        protected java.lang.String m_name
        The fully qualified name of this principal.
    • Constructor Detail

      • CmsPrincipal

        protected CmsPrincipal()
        Empty constructor for subclassing.

    • Method Detail

      • filterCoreFlag

        public static java.util.List<? extends CmsPrincipalfilterCoreFlag​(java.util.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 I_CmsPrincipal.FLAG_CORE_LIMIT untouched.

        The given parameter list is directly modified, so the returned list is the same object as the input list.

        Parameters:
        principals - a list of CmsPrincipal objects
        flag - the flag for filtering
        Returns:
        the filtered principal list
      • filterCoreGroups

        public static java.util.List<CmsGroupfilterCoreGroups​(java.util.List<CmsGroup> groups)
        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 CmsGroup objects
        Returns:
        the filtered principal list
      • filterCoreUsers

        public static java.util.List<CmsUserfilterCoreUsers​(java.util.List<CmsUser> users)
        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 CmsUser objects
        Returns:
        the filtered principal list
      • filterFlag

        public static java.util.List<? extends CmsPrincipalfilterFlag​(java.util.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 CmsPrincipal objects
        flag - the flag for filtering
        Returns:
        the filtered principal list
      • getType

        public static java.lang.String getType​(I_CmsPrincipal principal)
        Gets the type of a principal.

        Parameters:
        principal - the principal
        Returns:
        the principal type
      • readPrincipal

        public static I_CmsPrincipal readPrincipal​(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 principal
        id - 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

        public static I_CmsPrincipal readPrincipal​(CmsObject cms,
                                                   java.lang.String name)
                                            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 principal
        name - 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,
                                                   java.lang.String type,
                                                   java.lang.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 I_CmsPrincipal.PRINCIPAL_GROUP or I_CmsPrincipal.PRINCIPAL_USER.

        Parameters:
        cms - the OpenCms user context to use when reading the principal
        type - the principal type
        name - 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 principal
        id - 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
      • equals

        public boolean equals​(java.lang.Object obj)
        Description copied from interface: I_CmsPrincipal
        Compares the given object with this principal.

        Specified by:
        equals in interface I_CmsPrincipal
        Specified by:
        equals in interface java.security.Principal
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - object to compare
        Returns:
        true if the object is equal
        See Also:
        Object.equals(java.lang.Object)
      • getDisplayName

        public java.lang.String getDisplayName​(CmsObject cms,
                                               java.util.Locale locale)
                                        throws CmsException
        Returns the display name of this principal including the organizational unit.

        Parameters:
        cms - the cms context
        locale - 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 java.lang.String getDisplayName​(CmsObject cms,
                                               java.util.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 context
        locale - the locale
        translation - the group name translation to use
        Returns:
        the translated display name
        Throws:
        CmsException - if something goes wrong
      • getFlags

        public int 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 I_CmsPrincipal.isEnabled() provide a much easier way to access the information contained in the flags.

        Specified by:
        getFlags in interface I_CmsPrincipal
        Returns:
        the flags of this principal
        See Also:
        I_CmsPrincipal.getFlags()
      • getName

        public java.lang.String getName()
        Returns the fully qualified name of this principal.

        Specified by:
        getName in interface I_CmsPrincipal
        Specified by:
        getName in interface java.security.Principal
        Returns:
        the fully qualified name of this principal
        See Also:
        Principal.getName()
      • getOuFqn

        public java.lang.String getOuFqn()
        Returns the fully qualified name of the associated organizational unit.

        Specified by:
        getOuFqn in interface I_CmsPrincipal
        Returns:
        the fully qualified name of the associated organizational unit
      • getSimpleName

        public java.lang.String getSimpleName()
        Returns the simple name of this organizational unit.
        Specified by:
        getSimpleName in interface I_CmsPrincipal
        Returns:
        the simple name of this organizational unit.
      • hashCode

        public int hashCode()
        Description copied from interface: I_CmsPrincipal
        Returns the hash code of this object.

        Specified by:
        hashCode in interface I_CmsPrincipal
        Specified by:
        hashCode in interface java.security.Principal
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the hash code
        See Also:
        Object.hashCode()
      • isEnabled

        public boolean isEnabled()
        Description copied from interface: I_CmsPrincipal
        Returns true 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 interface I_CmsPrincipal
        Returns:
        true if this principal is enabled
        See Also:
        I_CmsPrincipal.isEnabled()
      • setFlags

        public void setFlags​(int value)
        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 I_CmsPrincipal.setEnabled(boolean) provide a much easier way to manipulate the information contained in the flags.

        Specified by:
        setFlags in interface I_CmsPrincipal
        Parameters:
        value - the value to set this principals flags to
        See Also:
        I_CmsPrincipal.setFlags(int)