Class GenericAttributeProviderBasedAttributeDesignatorExpression<AV extends AttributeValue>
- java.lang.Object
-
- org.ow2.authzforce.core.pdp.api.expression.GenericAttributeProviderBasedAttributeDesignatorExpression<AV>
-
- Type Parameters:
AV
- AttributeDesignator evaluation result value's primitive datatype
- All Implemented Interfaces:
AttributeDesignatorExpression<AV>
,Expression<Bag<AV>>
public final class GenericAttributeProviderBasedAttributeDesignatorExpression<AV extends AttributeValue> extends Object implements AttributeDesignatorExpression<AV>
AttributeDesignator evaluator initialized with and using anNamedAttributeProvider
to retrieve the attribute value- Version:
- $Id: $
-
-
Constructor Summary
Constructors Constructor Description GenericAttributeProviderBasedAttributeDesignatorExpression(AttributeFqn attributeName, boolean mustBePresent, BagDatatype<AV> resultDatatype, SingleNamedAttributeProvider<AV> attributeProvider)
Return an instance of an AttributeDesignator based on an AttributeDesignatorType
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
Equal iff the Attribute Category/Issuer/Id are equalBag<AV>
evaluate(EvaluationContext individualDecisionContext, Optional<EvaluationContext> mdpContext)
Evaluates the expression using the given context.AttributeFqn
getAttributeFQN()
Get Attribute Category/Issuer/IdDatatype<Bag<AV>>
getReturnType()
Gets the expected return type of the expression if evaluated.Optional<Bag<AV>>
getValue()
Get the constant value of this expression if it has a constant value, i.e.int
hashCode()
boolean
isNonEmptyBagRequired()
Indicates whether the attribute's presence is required, i.e.String
toString()
-
-
-
Constructor Detail
-
GenericAttributeProviderBasedAttributeDesignatorExpression
public GenericAttributeProviderBasedAttributeDesignatorExpression(AttributeFqn attributeName, boolean mustBePresent, BagDatatype<AV> resultDatatype, SingleNamedAttributeProvider<AV> attributeProvider)
Return an instance of an AttributeDesignator based on an AttributeDesignatorType- Parameters:
attributeName
- the AttributeDesignatorType we want to convertmustBePresent
- AttributeDesignator's MustBePresentresultDatatype
- expected datatype of the result attribute value (AV is the expected type of every element in the bag
)attributeProvider
- Attribute Provider responsible for finding the values of the attribute designated byattributeName
in a given evaluation context at runtime. Whenevaluate(EvaluationContext, Optional)
is called, all AttributeProvider(s) are called in the list order- Throws:
IllegalArgumentException
- ifattrDesignator.getCategory() == null || attrDesignator.getAttributeId() == null
-
-
Method Detail
-
getValue
public Optional<Bag<AV>> getValue()
Get the constant value of this expression if it has a constant value, i.e. independent of the evaluation context (e.g. AttributeValue, VariableReference to AttributeValue...). This is equivalent to callExpression.evaluate(EvaluationContext, Optional)
withindividualDecisionContext == null
andmdpContext == Optional.empty()
. This enables expression consumers to do optimizations, e.g. functions may pre-compile/pre-evaluate parts of their inputs knowing some are constant values.- Specified by:
getValue
in interfaceExpression<AV extends AttributeValue>
- Returns:
- the constant value iff the expression has a static/fixed/constant value, else no present value. NB: Null is not considered/possible as a constant value for expressions.
-
getAttributeFQN
public AttributeFqn getAttributeFQN()
Description copied from interface:AttributeDesignatorExpression
Get Attribute Category/Issuer/Id- Specified by:
getAttributeFQN
in interfaceAttributeDesignatorExpression<AV extends AttributeValue>
- Returns:
- attribute GUID (category, issuer, ID)
-
isNonEmptyBagRequired
public boolean isNonEmptyBagRequired()
Description copied from interface:AttributeDesignatorExpression
Indicates whether the attribute's presence is required, i.e. it must have at least one value in this context (non-empty bag). Equivalent of XACML MustBePresent flag.- Specified by:
isNonEmptyBagRequired
in interfaceAttributeDesignatorExpression<AV extends AttributeValue>
- Returns:
- true iff the resulting bag must be non-empty, i.e. there must be at least one value for this attribute in the context
-
evaluate
public Bag<AV> evaluate(EvaluationContext individualDecisionContext, Optional<EvaluationContext> mdpContext) throws IndeterminateEvaluationException
Description copied from interface:Expression
Evaluates the expression using the given context.- Specified by:
evaluate
in interfaceExpression<AV extends AttributeValue>
- Parameters:
individualDecisionContext
- Individual Decision)request contextmdpContext
- the context of the Multiple Decision request that theindividualDecisionContext
belongs to if the Multiple Decision Profile is used.- Returns:
- the result of evaluation that may be a single value T (e.g. function result, AttributeValue, Condition, Match...) or bag of values (e.g. AttributeDesignator, AttributeSelector)
- Throws:
IndeterminateEvaluationException
- if evaluation is "Indeterminate" (see XACML core specification)
-
getReturnType
public Datatype<Bag<AV>> getReturnType()
Gets the expected return type of the expression if evaluated.- Specified by:
getReturnType
in interfaceExpression<AV extends AttributeValue>
- Returns:
- expression evaluation's return type
-
-