Interface StaticPolicyProvider

    • Method Detail

      • get

        StaticTopLevelPolicyElementEvaluator get​(TopLevelPolicyElementType policyType,
                                                 String policyId,
                                                 Optional<PolicyVersionPatterns> versionConstraints,
                                                 Deque<String> policySetRefChain)
                                          throws IndeterminateEvaluationException
        Finds a policy based on an ID reference. This may involve using the reference as indexing data to lookup a policy.
        Parameters:
        policyId - the requested Policy(Set)Id

        WARNING: java.net.URI cannot be used here, because not equivalent to XML schema anyURI type. Spaces are allowed in XSD anyURI [1], not in java.net.URI.

        [1] http://www.w3.org/TR/xmlschema-2/#anyURI That's why we use String instead.

        See also:

        https://java.net/projects/jaxb/lists/users/archive/2011-07/ message/16

        From the JAXB spec: "xs:anyURI is not bound to java.net.URI by default since not all possible values of xs:anyURI can be passed to the java.net.URI constructor.

        policyType - type of requested policy element (Policy or PolicySet)
        versionConstraints - any optional constraints on the version of the referenced policy, matched against its Version attribute
        policySetRefChain - null iff this is not called to resolve a PolicySetIdReference; else (policyType == TopLevelPolicyElementType#POLICY_SET) this is the chain of PolicySets linked via PolicySetIdReference(s), from the root PolicySet up to (and including) policyId. Each item in the chain is a PolicySetId of a PolicySet that is referenced by the previous item (except the first item which is the root policy) and references the next one. This chain is used to control PolicySetIdReferences found within the result policy, in order to detect loops (circular references) and prevent exceeding reference depth.

        Beware that we only keep the IDs in the chain, and not the version, because we consider that a reference loop on the same policy ID is not allowed, no matter what the version is.

        (Do not use a Queue for policySetRefChain as it is FIFO, and we need LIFO and iteration in order of insertion, so different from Collections.asLifoQueue(Deque) as well.)

        Returns:
        the policy matching the policy reference; or null if no match
        Throws:
        IndeterminateEvaluationException - error resolving the policy
      • get

        default StaticTopLevelPolicyElementEvaluator get​(TopLevelPolicyElementType policyType,
                                                         String policyId,
                                                         Optional<PolicyVersionPatterns> policyVersionConstraints,
                                                         Deque<String> policySetRefChain,
                                                         EvaluationContext evaluationCtx)
                                                  throws IllegalArgumentException,
                                                         IndeterminateEvaluationException
        Description copied from interface: PolicyProvider
        Finds a policy based on an ID reference. This may involve using the reference as indexing data to lookup a policy.
        Specified by:
        get in interface PolicyProvider<StaticTopLevelPolicyElementEvaluator>
        Parameters:
        policyType - type of policy element requested (policy or policySet)
        policyId - the identifier used to resolve the policy by its Policy(Set)Id

        WARNING: java.net.URI cannot be used here, because not equivalent to XML schema anyURI type. Spaces are allowed in XSD anyURI [1], not in java.net.URI.

        [1] http://www.w3.org/TR/xmlschema-2/#anyURI That's why we use String instead.

        See also:

        https://java.net/projects/jaxb/lists/users/archive/2011-07/ message/16

        From the JAXB spec: "xs:anyURI is not bound to java.net.URI by default since not all possible values of xs:anyURI can be passed to the java.net.URI constructor.

        policyVersionConstraints - any optional constraints on the version of the referenced policy, matched against its Version attribute
        policySetRefChain - null iff this is not called to resolve a PolicySetIdReference; else (policyType == TopLevelPolicyElementType#POLICY_SET) this is the chain of PolicySets linked via PolicySetIdReference(s), from the root PolicySet up to (and including) policyId. Each item is a PolicySetId of a PolicySet that is referenced by the previous item (except the first item which is the root policy) and references the next one. This chain is used to control PolicySetIdReferences found within the result policy, in order to detect loops (circular references) and prevent exceeding reference depth.

        Beware that we only keep the IDs in the chain, and not the version, because we consider that a reference loop on the same policy ID is not allowed, no matter what the version is.

        (Do not use a Queue for policySetRefChain as it is FIFO, and we need LIFO and iteration in order of insertion, so different from Collections.asLifoQueue(Deque) as well.)

        evaluationCtx - evaluation context; the policy may be resolved dynamically for each evaluation request. Still, the implementation must guarantee that the same reference (same refPolicyType, policyIdRef, constraints arguments) always resolves to the same policy in the same evaluation context (for the same request) to preserve evaluation consistency. Therefore, it is recommended that the implementation caches the resolved policy matching given Policy(Set)IdReference parameters (policy type, ID, version constraints) in the request context evaluationCtx once and for all using EvaluationContext.putOther(String, Object), and retrieves it in the same context using EvaluationContext.getOther(String) if necessary.
        Returns:
        the policy matching the policy reference; or null if no match
        Throws:
        IllegalArgumentException - The resolved policy is invalid. The policy Provider module may parse policies lazily or on the fly, i.e. only when the policy is requested/looked for.
        IndeterminateEvaluationException - if error determining a matching policy of type policyType