Search in sources :

Example 6 with XPathVersion

use of org.ow2.authzforce.xacml.identifiers.XPathVersion in project core-pdp-api by authzforce.

the class BaseXacmlJaxbRequestPreprocessor method process.

@Override
public final List<IndividualXacmlJaxbRequest> process(final Request jaxbRequest, final Map<String, String> namespaceURIsByPrefix) throws IndeterminateEvaluationException {
    if (jaxbRequest == null) {
        throw NULL_REQUEST_EXCEPTION;
    }
    /*
         * No support for MultiRequests (ยง2.4 of Multiple Decision Profile).
         */
    if (jaxbRequest.getMultiRequests() != null) {
        /*
             * According to 7.19.1 Unsupported functionality, return Indeterminate with syntax-error code for unsupported element
             */
        throw UNSUPPORTED_MULTI_REQUESTS_EXCEPTION;
    }
    /*
         * No support for CombinedDecision = true if no decisionCombiner defined. (The use of the CombinedDecision attribute is specified in Multiple Decision Profile.)
         */
    if (jaxbRequest.isCombinedDecision() && !this.isCombinedDecisionSupported) {
        /*
             * According to XACML core spec, 5.42, <i>If the PDP does not implement the relevant functionality in [Multiple Decision Profile], then the PDP must return an Indeterminate with a status
             * code of urn:oasis:names:tc:xacml:1.0:status:processing-error if it receives a request with this attribute set to "true"</i>.
             */
        throw UNSUPPORTED_COMBINED_DECISION_EXCEPTION;
    }
    final RequestDefaults jaxbReqDefaults = jaxbRequest.getRequestDefaults();
    final Optional<XPathCompilerProxy> xPathCompiler;
    final Map<String, String> newNsPrefixToUriMap;
    if (jaxbReqDefaults == null) {
        xPathCompiler = Optional.empty();
        newNsPrefixToUriMap = namespaceURIsByPrefix;
    } else {
        try {
            final XPathVersion xPathVersion = XPathVersion.fromURI(jaxbReqDefaults.getXPathVersion());
            xPathCompiler = Optional.of(new BasicImmutableXPathCompilerProxy(xPathVersion, namespaceURIsByPrefix));
            /*
				namespaceURIsByPrefix already held by xPathCompiler and retrievable from it with getDeclaredNamespacePrefixToUriMap().
				 */
            newNsPrefixToUriMap = Map.of();
        } catch (IllegalArgumentException e) {
            throw new IllegalArgumentException("Invalid/unsupported XPathVersion in Request/RequestDefaults", e);
        }
    }
    final SingleCategoryXacmlAttributesParser<Attributes> xacmlAttrsParser = xacmlAttrsParserFactory.getInstance();
    return process(jaxbRequest.getAttributes(), xacmlAttrsParser, jaxbRequest.isReturnPolicyIdList(), jaxbRequest.isCombinedDecision(), xPathCompiler, newNsPrefixToUriMap);
}
Also used : BasicImmutableXPathCompilerProxy(org.ow2.authzforce.core.pdp.api.expression.BasicImmutableXPathCompilerProxy) BasicImmutableXPathCompilerProxy(org.ow2.authzforce.core.pdp.api.expression.BasicImmutableXPathCompilerProxy) XPathCompilerProxy(org.ow2.authzforce.core.pdp.api.expression.XPathCompilerProxy) Attributes(oasis.names.tc.xacml._3_0.core.schema.wd_17.Attributes) RequestDefaults(oasis.names.tc.xacml._3_0.core.schema.wd_17.RequestDefaults) XPathVersion(org.ow2.authzforce.xacml.identifiers.XPathVersion)

Aggregations

XPathCompilerProxy (org.ow2.authzforce.core.pdp.api.expression.XPathCompilerProxy)3 XPathVersion (org.ow2.authzforce.xacml.identifiers.XPathVersion)3 Policy (oasis.names.tc.xacml._3_0.core.schema.wd_17.Policy)2 IndeterminateEvaluationException (org.ow2.authzforce.core.pdp.api.IndeterminateEvaluationException)2 BasicImmutableXPathCompilerProxy (org.ow2.authzforce.core.pdp.api.expression.BasicImmutableXPathCompilerProxy)2 HashBasedTable (com.google.common.collect.HashBasedTable)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Table (com.google.common.collect.Table)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 Serializable (java.io.Serializable)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 Files (java.nio.file.Files)1 Path (java.nio.file.Path)1 Paths (java.nio.file.Paths)1 java.util (java.util)1 Entry (java.util.Map.Entry)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1