*
* @return a result containing a bag either empty because no values were found or containing at
* least one value, or status associated with an Indeterminate result
*/
public EvaluationResult evaluate(EvaluationCtx context) {
EvaluationResult result = null;
// look in the right section for some attribute values
switch (target) {
case SUBJECT_TARGET:
result = context.getSubjectAttribute(type, id, issuer, subjectCategory);
break;
case RESOURCE_TARGET:
result = context.getResourceAttribute(type, id, issuer);
break;
case ACTION_TARGET:
result = context.getActionAttribute(type, id, issuer);
break;
case ENVIRONMENT_TARGET:
result = context.getEnvironmentAttribute(type, id, issuer);
break;
}
// if the lookup was indeterminate, then we return immediately
if (result.indeterminate())
return result;
BagAttribute bag = (BagAttribute) (result.getAttributeValue());
if (bag.isEmpty()) {
// if it's empty, this may be an error
if (mustBePresent) {
if (logger.isLoggable(Level.INFO))
logger.info("AttributeDesignator failed to resolve a "
+ "value for a required attribute: " + id.toString());
ArrayList<String> code = new ArrayList<String>();
code.add(Status.STATUS_MISSING_ATTRIBUTE);
String message = "Couldn't find " + targetTypes[target]
+ "AttributeDesignator attribute";
// Note that there is a bug in the XACML spec. You can't
// specify an identifier without specifying acceptable
// values. Until this is fixed, this code will only
// return the status code, and not any hints about what
// was missing
/*
* List attrs = new ArrayList(); attrs.add(new Attribute(id, ((issuer == null) ?
* null : issuer.toString()), null, null)); StatusDetail detail = new
* StatusDetail(attrs);
*/
return new EvaluationResult(new Status(code, message));
}
}
// if we got here the bag wasn't empty, or mustBePresent was false,
// so we just return the result