Class EntitlementCombiner

  • Direct Known Subclasses:
    DenyOverride

    public abstract class EntitlementCombiner
    extends Object
    Encapsulates a Strategy for combining the results of two Entitlements. Across the system, these can also be referred to as "decision combiners"; for example, the set of registered EntitlementCombiners can be retrieved from the /json/decisioncombiners REST endpoint. This is the base class and is, for example, extended by DenyOverride. init needs to be called after it is created.
    • Constructor Detail

      • EntitlementCombiner

        public EntitlementCombiner()
    • Method Detail

      • init

        public void init​(String realm,
                         String applicationName,
                         String normalisedResourceName,
                         String requestedResourceName,
                         Set<String> actions,
                         boolean isRecursive)
                  throws EntitlementException
        Initializes the combiner.
        Parameters:
        realm - Realm name.
        applicationName - Application Name.
        normalisedResourceName - The normalised resource name.
        requestedResourceName - The requested resource name.
        actions - Action names to be evaluated.
        isRecursive - true< for subtree evaluation.
        Throws:
        EntitlementException
      • init

        public void init​(String normalisedResourceName,
                         String requestedResourceName,
                         Set<String> actions,
                         boolean isRecursive,
                         Application application)
                  throws EntitlementException
        Initializes the combiner.
        Parameters:
        normalisedResourceName - The normalised resource name.
        requestedResourceName - The requested resource name.
        actions - Action names to be evaluated.
        isRecursive - true< for subtree evaluation.
        application - The defining application.
        Throws:
        EntitlementException
      • add

        public void add​(List<Entitlement> entitlements)
        Adds a set of entitlements to the overall entitlement decision. These entitlements will be combined with existing decision.
        Parameters:
        entitlements - Set of entitlements.
      • mergeActionValues

        protected void mergeActionValues​(Entitlement e1,
                                         Entitlement e2)
        Sets the action values of the first entitlement to be the union of all action values from the first and second entitlements; if a particular action value is contained in both entitlements, then the two values are combined (using the implementation-dependent) combine(java.lang.Boolean, java.lang.Boolean) method) before being added to the first entitlement.
        Parameters:
        e1 - Entitlement.
        e2 - Entitlement.
      • mergeAdvices

        protected void mergeAdvices​(Entitlement e1,
                                    Entitlement e2)
        Sets the advices of the first entitlement to be the union of all advices from the first and second entitlements.
        Parameters:
        e1 - Entitlement.
        e2 - Entitlement.
      • mergeAttributes

        protected void mergeAttributes​(Entitlement e1,
                                       Entitlement e2)
        Sets the attributes of the first entitlement to be the union of all attributes from the first and second entitlements.
        Parameters:
        e1 - Entitlement
        e2 - Entitlement
      • mergeTimeToLiveValue

        protected void mergeTimeToLiveValue​(Entitlement e1,
                                            Entitlement e2)
        Merges time to live values. The lowest of the TTL values is set as the TTL.
        Parameters:
        e1 - Entitlement
        e2 - Entitlement
      • getActions

        protected Set<String> getActions()
        Returns action names.
        Returns:
        action names.
      • isRecursive

        protected boolean isRecursive()
        Returns true if this entitlement combiner is working on sub tree evaluation.
        Returns:
        true if this entitlement combiner is working on sub tree evaluation.
      • getRootE

        protected Entitlement getRootE()
        Returns the entitlement which will act as the root for sub tree evaluations.
        Returns:
        root entitlement for sub tree evaluations.
      • getResourceComparator

        protected ResourceName getResourceComparator()
        Returns the resource comparator.
        Returns:
        resource comparator.
      • isDone

        public boolean isDone()
        Returns true if policy decision can also be determined.
        Returns:
        true if policy decision can also be determined.
      • getResults

        public List<Entitlement> getResults()
        Returns entitlements which are the result of combining a set of entitlements.
        Returns:
        entitlement results.
      • combine

        protected abstract boolean combine​(Boolean b1,
                                           Boolean b2)
        Returns the result of combining two entitlement decisions.
        Parameters:
        b1 - entitlement decision.
        b2 - entitlement decision.
        Returns:
        result of combining two entitlement decisions.
      • isCompleted

        protected abstract boolean isCompleted()
        Returns true if policy decision can also be determined. This method is called by derived classes. #isDone method shall be set if this returns true.
        Returns:
        true if policy decision can also be determined.
      • getName

        public String getName()
        Returns the name of this class for ease of reference.
        Returns:
        The simple name of this instance's class