URI issuer, URI subjectCategory,
EvaluationCtx context,
int designatorType) {
// make sure this is the identifier we support
if (! attributeId.toString().equals(ROLE_IDENTIFIER))
return new EvaluationResult(BagAttribute.
createEmptyBag(attributeType));
// make sure we've been asked for a string
if (! attributeType.toString().equals(StringAttribute.identifier))
return new EvaluationResult(BagAttribute.
createEmptyBag(attributeType));
// retrieve the subject identifer from the context
EvaluationResult result =
context.getSubjectAttribute(attributeType, subjectIdentifier,
issuer, subjectCategory);
if (result.indeterminate())
return result;
// check that we succeeded in getting the subject identifier
BagAttribute bag = (BagAttribute)(result.getAttributeValue());
if (bag.isEmpty()) {
ArrayList code = new ArrayList();
code.add(Status.STATUS_MISSING_ATTRIBUTE);
Status status = new Status(code, "missing subject-id");
return new EvaluationResult(status);
}
// finally, look for the subject who has the role-mapping defined,
// and if they're the identified subject, add their role
BagAttribute returnBag = null;
Iterator it = bag.iterator();
while (it.hasNext()) {
StringAttribute attr = (StringAttribute)(it.next());
if (attr.getValue().equals("Julius Hibbert")) {
Set set = new HashSet();
set.add(new StringAttribute("Physician"));
returnBag = new BagAttribute(attributeType, set);
break;
}
}
return new EvaluationResult(returnBag);
}