Commit 79f92a24 authored by cdanger's avatar cdanger

- Add method getVariableExpression() to ExpressionFactory interface

- Added check for VariableReference used as sub-function arg to
high-order function (must be constant, dynamic is not supported)
- Improved javadoc of TimeValue: more info about underlying
XmlGregorianCalendar year/month/day fields (undefined)
parent 0cc6685b
......@@ -20,16 +20,16 @@ package org.ow2.authzforce.core.pdp.api.expression;
import java.io.Closeable;
import java.util.Deque;
import org.ow2.authzforce.core.pdp.api.NamedAttributeProvider;
import org.ow2.authzforce.core.pdp.api.value.AttributeValue;
import org.ow2.authzforce.core.pdp.api.value.Datatype;
import net.sf.saxon.s9api.XPathCompiler;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.DefaultsType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.ExpressionType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.VariableDefinition;
import org.ow2.authzforce.core.pdp.api.NamedAttributeProvider;
import org.ow2.authzforce.core.pdp.api.value.AttributeValue;
import org.ow2.authzforce.core.pdp.api.value.Datatype;
/**
* Expression factory for parsing XACML {@link ExpressionType}s in policies: AttributeDesignator, AttributeSelector, Apply, etc.
* <p>
......@@ -70,7 +70,7 @@ public interface ExpressionFactory extends Closeable
ConstantExpression<? extends AttributeValue> getInstance(AttributeValueType jaxbAttrVal, XPathCompiler xPathCompiler) throws IllegalArgumentException;
/**
* Add VariableDefinition to be managed
* Add VariableDefinition (variable assignment expression)
*
* @param varDef
* VariableDefinition
......@@ -87,6 +87,14 @@ public interface ExpressionFactory extends Closeable
*/
VariableReference<?> addVariable(VariableDefinition varDef, XPathCompiler xPathCompiler, Deque<String> longestVarRefChain) throws IllegalArgumentException;
/**
* Get a given variable's assignment expression (definition)
*
* @param varId
* @return the VariableReference identified by <code>varId</code> , or null if there is no such variable.
*/
VariableReference<?> getVariableExpression(String varId);
/**
* Removes the VariableReference(Definition) from the manager
*
......
......@@ -19,6 +19,7 @@ package org.ow2.authzforce.core.pdp.api.func;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;
import org.ow2.authzforce.core.pdp.api.expression.Expression;
import org.ow2.authzforce.core.pdp.api.expression.FunctionExpression;
......@@ -100,7 +101,14 @@ public abstract class HigherOrderBagFunction<RETURN_T extends Value, SUB_RETURN_
}
else if (input0 instanceof VariableReference)
{
final Value varValue = ((VariableReference<?>) input0).getValue().get();
final Optional<? extends Value> optVal = ((VariableReference<?>) input0).getValue();
if (!optVal.isPresent())
{
throw new IllegalArgumentException(this + ": Unsupported type of first argument: " + input0
+ " cannot be evaluated to a constant (Function) value (out of context). Variable Function arg to higher-order function is not supported.");
}
final Value varValue = optVal.get();
if (!(varValue instanceof Function))
{
throw new IllegalArgumentException(this + ": Invalid type of first argument: " + varValue.getClass().getSimpleName() + ". Required: Function");
......
......@@ -24,7 +24,16 @@ import org.ow2.authzforce.core.pdp.api.XmlUtils;
/**
* Representation of an xs:time value. This class supports parsing xs:time values. All objects of this class are immutable and thread-safe.
*
* <p>
* The {@link XMLGregorianCalendar} returned by {@link #getUnderlyingValue()} have the following characteristics:
* <ul>
* <li>{@link XMLGregorianCalendar#getYear()} always returns {@link DatatypeConstants#FIELD_UNDEFINED}</li>
* <li>{@link XMLGregorianCalendar#getEon()} and {@link XMLGregorianCalendar#getEonAndYear()} always return null</li>
* <li>{@link XMLGregorianCalendar#getMonth()} always returns {@link DatatypeConstants#FIELD_UNDEFINED}</li>
* <li>{@link XMLGregorianCalendar#getDay()} always returns {@link DatatypeConstants#FIELD_UNDEFINED}</li>
* <li>{@link XMLGregorianCalendar#getYear()} always returns {@link DatatypeConstants#FIELD_UNDEFINED}</li>
* </ul>
* </p>
*
* @version $Id: $
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment