/** * Checks that Index is positive. * * @param attributeConsumingService * @throws ValidationException */ protected void validateIndex(AttributeConsumingService attributeConsumingService) throws ValidationException { if (attributeConsumingService.getIndex() < 0) { throw new ValidationException("Index must be positive integer"); } }
/** * Select the service based on the index value. * * @param candidates the list of candiate services * @return the selected candidate or null */ private AttributeConsumingService selectByIndex(List<AttributeConsumingService> candidates) { log.debug("Selecting AttributeConsumingService by index"); for (AttributeConsumingService attribCS : candidates) { // Check for null b/c don't ever want to fail with an NPE due to autoboxing. // Note: metadata index property is an int, not an Integer. if (index != null) { if (index == attribCS.getIndex()) { log.debug("Selected AttributeConsumingService with index: {}", index); return attribCS; } } } log.debug("A service index of '{}' was specified, but was not found in metadata", index); return null; }
/** {@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()); } } }
private void setAttributeConsumingServiceIndex(SPSSODescriptor spssoDescriptor, SAMLSSOServiceProviderDO samlssoServiceProviderDO) throws InvalidMetadataException { List<AttributeConsumingService> attributeConsumingServices = spssoDescriptor.getAttributeConsumingServices(); if (attributeConsumingServices != null && attributeConsumingServices.size() > 0) { for (AttributeConsumingService attributeConsumingService : attributeConsumingServices) { if (attributeConsumingService != null) { int index = attributeConsumingService.getIndex(); samlssoServiceProviderDO.setAttributeConsumingServiceIndex(index + ""); samlssoServiceProviderDO.setEnableAttributesByDefault(true); } } } }