Class DotNamedPermission

  • All Implemented Interfaces:
    Comparable<Permission>, Permission

    @Portable
    public class DotNamedPermission
    extends Object
    implements Permission, Comparable<Permission>
    An implementation where the permission's name is formatted using dots. For instance:

    • resource.view => View all resources
    • resource.view.r1 => View only r1
    The implies(Permission other) implementation is based on the simple fact that one permission implies another just if its name starts with the another's name. This very simple mechanism can be applied to most of the resources that require authorization control, like for instance, workbench perspectives, a file system, etc.
    • Constructor Detail

      • DotNamedPermission

        public DotNamedPermission()
      • DotNamedPermission

        public DotNamedPermission​(String name)
      • DotNamedPermission

        public DotNamedPermission​(String name,
                                  Boolean granted)
    • Method Detail

      • _enableImmutability

        protected void _enableImmutability()
      • _checkImmutability

        protected void _checkImmutability()
      • getName

        public String getName()
        Description copied from interface: Permission
        A string literal that identifies a resource or set of resources this permission object relates to.

        It's up to every Permission implementation to define what's the set the name's format.

        Specified by:
        getName in interface Permission
      • setName

        public void setName​(String name)
      • getResult

        public AuthorizationResult getResult()
        Description copied from interface: Permission
        The authorization result or permission status.
        Specified by:
        getResult in interface Permission
        Returns:
        One of the available results: GRANT / DENY / ABSTAIN
      • setResult

        public void setResult​(AuthorizationResult result)
        Description copied from interface: Permission
        Change the authorzation result.
        Specified by:
        setResult in interface Permission
        Parameters:
        result - GRANT / DENY / ABSTAIN
      • implies

        public boolean implies​(Permission other)
        Description copied from interface: Permission
        Basically, "permission p1 implies permission p2" means that if one is granted permission p1, one is naturally granted permission p2. Thus, this is not an equality test, but rather more of a subset test.

        Both calls to Permission.impliesName(Permission) & Permission.impliesResult(Permission) return true.

        Specified by:
        implies in interface Permission
        Parameters:
        other - the permission to check against.
        Returns:
        true if the specified permission is implied by this object, false if not.
      • impliesName

        public boolean impliesName​(Permission other)
        Description copied from interface: Permission
        If "permission p1 impliesName permission p2" means that the feature represented by p1 is a superset of p2.
        Specified by:
        impliesName in interface Permission
        Parameters:
        other - the permission to check against.
        Returns:
        true if the specified permission name is implied by this object, false if not.
      • impliesResult

        public boolean impliesResult​(Permission other)
        Description copied from interface: Permission
        If "permission p1 impliesResult permission p2" means that both permissions give the same result.
        Specified by:
        impliesResult in interface Permission
        Parameters:
        other - the permission to check against.
        Returns:
        true if the specified permission result is implied by this object, false if not.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • equalsName

        public boolean equalsName​(Permission other)
      • equalsResult

        public boolean equalsResult​(Permission other)
      • clone

        public Permission clone()
        Description copied from interface: Permission
        Creates an exact copy of this instance.
        Specified by:
        clone in interface Permission
        Overrides:
        clone in class Object
        Returns:
        A brand new Permission instance