+ /**
+ * scanAttributes - scans the attributes that are returned in the XACML Decision and puts them into the
+ * DecisionResponse object.
+ *
+ * @param attributeCategories Collection of AttributeCategory objects
+ * @param decisionResponse DecisionResponse object used to store any attributes
+ */
+ protected void scanAttributes(Collection<AttributeCategory> attributeCategories,
+ DecisionResponse decisionResponse) {
+ var returnedAttributes = new HashMap<String, Object>();
+ for (AttributeCategory attributeCategory : attributeCategories) {
+ var mapCategory = new HashMap<String, Object>();
+ for (Attribute attribute : attributeCategory.getAttributes()) {
+ //
+ // Most attributes have a single value, thus the collection is not necessary to
+ // return. However, we will allow this to be configurable.
+ //
+ if (! booleanReturnSingleValueAttributesAsCollection && attribute.getValues().size() == 1) {
+ var iterator = attribute.getValues().iterator();
+ var value = iterator.next();
+ mapCategory.put(attribute.getAttributeId().stringValue(), value.getValue().toString());
+ } else {
+ mapCategory.put(attribute.getAttributeId().stringValue(), attribute.getValues());
+ }
+ }
+ returnedAttributes.put(attributeCategory.getCategory().stringValue(), mapCategory);
+ }
+ if (! returnedAttributes.isEmpty()) {
+ decisionResponse.setAttributes(returnedAttributes);
+ }
+ }
+