/** {@inheritDoc} */ protected void marshallAttributes(XMLObject samlObject, Element domElement) throws MarshallingException { AttributeConsumingService service = (AttributeConsumingService) samlObject; domElement.setAttributeNS(null, AttributeConsumingService.INDEX_ATTRIB_NAME, Integer.toString(service .getIndex())); if (service.isDefaultXSBoolean() != null) { domElement.setAttributeNS(null, AttributeConsumingService.IS_DEFAULT_ATTRIB_NAME, service .isDefaultXSBoolean().toString()); } } }
/** * Select the default service. * * @param candidates the list of candiate services * @return the selected candidate or null */ private AttributeConsumingService selectDefault(List<AttributeConsumingService> candidates) { log.debug("Selecting default AttributeConsumingService"); AttributeConsumingService firstNoDefault = null; for (AttributeConsumingService attribCS : candidates) { if (attribCS.isDefault()) { log.debug("Selected AttributeConsumingService with explicit isDefault of true"); return attribCS; } // This records the first element whose isDefault is not explicitly false if (firstNoDefault == null && attribCS.isDefaultXSBoolean() == null) { firstNoDefault = attribCS; } } if (firstNoDefault != null) { log.debug("Selected first AttributeConsumingService with no explicit isDefault"); return firstNoDefault; } else { log.debug("Selected first AttributeConsumingService with explicit isDefault of false"); return candidates.get(0); } } }