String resource = getResource(message);
String actionToUse = getAction(message);
// Subject
List<AttributeType> attributes = new ArrayList<AttributeType>();
AttributeValueType subjectIdAttributeValue =
RequestComponentBuilder.createAttributeValueType(principal.getName());
AttributeType subjectIdAttribute =
RequestComponentBuilder.createAttributeType(
XACMLConstants.SUBJECT_ID,
XACMLConstants.XS_STRING,
issuer,
Collections.singletonList(subjectIdAttributeValue)
);
attributes.add(subjectIdAttribute);
for (String role : roles) {
AttributeValueType subjectRoleAttributeValue =
RequestComponentBuilder.createAttributeValueType(role);
AttributeType subjectRoleAttribute =
RequestComponentBuilder.createAttributeType(
XACMLConstants.SUBJECT_ROLE,
XACMLConstants.XS_ANY_URI,
issuer,
Collections.singletonList(subjectRoleAttributeValue)
);
attributes.add(subjectRoleAttribute);
}
SubjectType subjectType = RequestComponentBuilder.createSubjectType(attributes, null);
// Resource
AttributeValueType resourceAttributeValue =
RequestComponentBuilder.createAttributeValueType(resource);
AttributeType resourceAttribute =
RequestComponentBuilder.createAttributeType(
XACMLConstants.RESOURCE_ID,
XACMLConstants.XS_STRING,
null,
Collections.singletonList(resourceAttributeValue)
);
attributes.clear();
attributes.add(resourceAttribute);
ResourceType resourceType = RequestComponentBuilder.createResourceType(attributes, null);
// Action
AttributeValueType actionAttributeValue =
RequestComponentBuilder.createAttributeValueType(actionToUse);
AttributeType actionAttribute =
RequestComponentBuilder.createAttributeType(
XACMLConstants.ACTION_ID,
XACMLConstants.XS_STRING,
null,
Collections.singletonList(actionAttributeValue)
);
attributes.clear();
attributes.add(actionAttribute);
ActionType actionType = RequestComponentBuilder.createActionType(attributes);
// Environment
attributes.clear();
if (sendDateTime) {
DateTime dateTime = new DateTime();
AttributeValueType environmentAttributeValue =
RequestComponentBuilder.createAttributeValueType(dateTime.toString());
AttributeType environmentAttribute =
RequestComponentBuilder.createAttributeType(
XACMLConstants.CURRENT_DATETIME,
XACMLConstants.XS_DATETIME,