Interface Role

  • All Superinterfaces:
    Serializable
    All Known Implementing Classes:
    AbstractRole, JpaRole, MemoryRole

    public interface Role
    extends Serializable
    Role A role is assignable to a user and effectively grants that user all of the permissions that are present in that role. A role can also contain other roles which add the permissions in those roles to the available permissions for authorization. A role can contain any number of permissions A role can contain any number of other roles A role can be assigned to any number of users
    Author:
    Jesse McConnell, Joakim Erdfelt, Martin Stockhammer
    • Method Detail

      • addPermission

        void addPermission​(Permission permission)
        Adds a permission to the list
        Parameters:
        permission - the permission to add to the list
      • addChildRoleName

        void addChildRoleName​(String name)
        Adds a role to the list of child roles
        Parameters:
        name - the name of the child role.
      • addChildRole

        void addChildRole​(Role child)
        Adds a child role and sets the list of child names and child ids.
        Parameters:
        child - the child role
      • hasChildRoles

        boolean hasChildRoles()
        Convenience method to see if Role has Child Roles.
        Returns:
        true if child roles exists and has any roles being tracked.
      • getDescription

        String getDescription()
        Long description of the role.
        Returns:
        the role description
      • getName

        String getName()
        Get the name. Must be unique. NOTE: This field is considered the Primary Key for this object.
        Returns:
        the name of the role
      • getPermissions

        List<? extends PermissiongetPermissions()
        Returns the list of permissions assigned to this role.
        Returns:
        the list of permissions assigned to this role
      • isAssignable

        boolean isAssignable()
        True, if this role is available to be assigned to a user, otherwise false.
        Returns:
        true, if this role can be assigned to users, otherwise false
      • removePermission

        void removePermission​(Permission permission)
        Removes the given permission from the list. If the permission does not exist in the list of assigned permissions, nothing happens.
        Parameters:
        permission - the permission to remove.
      • setAssignable

        void setAssignable​(boolean assignable)
        Set to true, if this role should available to be assigned to a user
        Parameters:
        assignable - the assignable flag
      • setChildRoleNames

        void setChildRoleNames​(List<String> names)
        Sets the names of children roles. Children roles inherit the permissions of the parent role.
        Parameters:
        names - the list of names of child roles.
      • setDescription

        void setDescription​(String description)
        Set the Description
        Parameters:
        description - the role description
      • setName

        void setName​(String name)
        Set the role name NOTE: This field is considered the Primary Key for this object.
        Parameters:
        name - the role name
      • setPermissions

        void setPermissions​(List<Permission> permissions)
        Set role permissions. The list of assigned permissions is replaced by this list.
        Parameters:
        permissions - the permissions to set
      • isPermanent

        boolean isPermanent()
        Test to see if the object is a permanent object or not.
        Returns:
        true, if the object is permanent.
      • setPermanent

        void setPermanent​(boolean permanent)
        Set flag indicating if the object is a permanent object or not.
        Parameters:
        permanent - true if the object is permanent.
      • getId

        String getId()
        The role identifier. Should be built from the modelId and the resource. And must be unique.
        Returns:
        the role identifier
        Since:
        3.0
      • setId

        void setId​(String id)
        Sets the role id
        Parameters:
        id - the identifier of the role, should not be null or empty.
        Since:
        3.0
      • getModelId

        default String getModelId()
        Returns the model the role is derived from.
        Returns:
        The model id or empty string, if this role was not created from a model
        Since:
        3.0
      • setModelId

        void setModelId​(String modelId)
        Sets the model id.
        Parameters:
        modelId - the identifier of the model, or empty string. Should not be null.
      • isTemplateInstance

        default boolean isTemplateInstance()
        Returns true, if this role is a instance of a template role, otherwise false. Templated roles are built from a template together with a resource identifier.
        Returns:
        true, if this role is a templated role, otherwise false
        Since:
        3.0
      • setTemplateInstance

        void setTemplateInstance​(boolean templateInstanceFlag)
        Sets the template instance flag.
        Parameters:
        templateInstanceFlag - Set to true, if this is a template instance, otherwise false
        Since:
        3.0
      • getResource

        default String getResource()
        Returns the resource that is used to build this role from a template. If this is not a templated role, a empty string should be returned.
        Returns:
        the resource identifier, used to build this role or a empty string, if this role is not templated
        Since:
        3.0
      • setResource

        void setResource​(String resource)
        Sets the resource, this template instance is attached to.
        Parameters:
        resource - the resource identifier. Must not be null.