Class ResourceCriteria

java.lang.Object
com.randomnoun.common.security.ResourceCriteria
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ResourceCriteriaImpl

public abstract class ResourceCriteria extends Object implements Serializable
A criteria than can be used to evaluate fine-grained resources. (e.g. an 'account' resource where account.balance > 1000). This class should be subclassed by security implementations that wish to perform access control over fine-grained resources.

It is the responsibility of this class to translate its criteriaString into a form that can return a true or false value when supplied a criteria context (in this case, an instance of the account). This class provides a default implementation of the evaluate(Map) method, which currently always returns true.

Author:
knoxg
See Also:
  • Constructor Details

  • Method Details

    • getCriteriaString

      Returns the string used to construct this ResourceCriteria object.
      Returns:
      the string used to construct this ResourceCriteria object.
    • toString

      public String toString()
      Returns a string representing this ResourceCriteria object. This method Should be overridden by subclasses.
      Overrides:
      toString in class Object
      Returns:
      a string representing this ResourceCriteria object
    • evaluate

      public boolean evaluate(Map<String,Object> criteriaContext)
      Returns true if this resourceCriteria identifies a resource with the supplied criteriaContext. The context used is resource-specific, but is always expressed as a name/value Map. e.g. for a message resource, the context may include a the headers of that message, and the values for those headers. For a system property resource, the context may just be the name of that system property.
      Parameters:
      criteriaContext - The context used to identify the resource
      Returns:
      true if this ResourceCriteria matches the supplied context, false if it does not.