Class KeyValuePermissionImpl

java.lang.Object
ddf.security.permission.impl.KeyValuePermissionImpl
All Implemented Interfaces:
ddf.security.permission.KeyValuePermission, org.apache.shiro.authz.Permission

public class KeyValuePermissionImpl extends Object implements ddf.security.permission.KeyValuePermission
Permission class comprised of a key and a list of corresponding values. Contains the logic to determine if this key/value permission can imply another key/value permission.
  • Constructor Details

    • KeyValuePermissionImpl

      public KeyValuePermissionImpl(String key)
      Creates a new KeyValuePermission with the specified key and an empty list of values.
      Parameters:
      key - the key to be used for this permission
    • KeyValuePermissionImpl

      public KeyValuePermissionImpl(String key, List<String> values)
      Deprecated.
      Creates a new KeyValuePermission with the specified key and corresponding list of values.
      Parameters:
      key - the key to be used for this permission
      values - the list of values to be used for this permission
      Throws:
      IllegalArgumentException - if the key is null - a valid key is required
    • KeyValuePermissionImpl

      public KeyValuePermissionImpl(String key, Set<String> values)
      Creates a new KeyValuePermission with the specified key and corresponding list of values.
      Parameters:
      key - the key to be used for this permission
      values - the list of values to be used for this permission
      Throws:
      IllegalArgumentException - if the key is null - a valid key is required
  • Method Details

    • getKey

      public String getKey()
      Specified by:
      getKey in interface ddf.security.permission.KeyValuePermission
    • getValues

      public Set<String> getValues()
      Specified by:
      getValues in interface ddf.security.permission.KeyValuePermission
    • addValue

      public void addValue(String value)
      Adds an additional value to the existing values.
      Specified by:
      addValue in interface ddf.security.permission.KeyValuePermission
      Parameters:
      value - new value to be added to the existing values for this key/value pair
    • implies

      public boolean implies(org.apache.shiro.authz.Permission p)
      Returns true if this current instance implies all the functionality and/or resource access described by the specified Permission argurment, false otherwise.

      That is, this current instance must be exactly equal to or a superset of the functionality and/or resource access described by the given Permission argument. Yet another way of saying this would be:

      If "permission1 implies permission2", i.e. permission1.implies(permission2) , then any Subject granted permission1 would have ability greater than or equal to that defined by permission2.

      For KeyValuePermission objects this is determined as follows:

      If the keys of each permission are equal and if the values from this object implies the values from the passed in permission, then this permission will imply the passed in permission.

      Specified by:
      implies in interface org.apache.shiro.authz.Permission
      Parameters:
      p - permission to checked to see if this permission implies p
      Returns:
      true if this current instance implies all the functionality and/or resource access described by the specified Permission argument, false otherwise.
    • toString

      public String toString()
      Creates a string representation of this key/value permission object.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this key/value permission object