/** {@inheritDoc} */ protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject) throws UnmarshallingException { AttributeConsumingService service = (AttributeConsumingService) parentSAMLObject; if (childSAMLObject instanceof ServiceName) { service.getNames().add((ServiceName) childSAMLObject); } else if (childSAMLObject instanceof ServiceDescription) { service.getDescriptions().add((ServiceDescription) childSAMLObject); } else if (childSAMLObject instanceof RequestedAttribute) { service.getRequestAttributes().add((RequestedAttribute) childSAMLObject); } else { super.processChildElement(parentSAMLObject, childSAMLObject); } }
/** * 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 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); } } }
/** {@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()); } } }
/** * Checks that one or more Requested Attributes are present. * * @param attributeConsumingService * @throws ValidationException */ protected void validateRequestedAttributes(AttributeConsumingService attributeConsumingService) throws ValidationException { if (attributeConsumingService.getRequestAttributes() == null || attributeConsumingService.getRequestAttributes().size() == 0) { throw new ValidationException("Must have one or more Requested Attributes."); } } }
/** {@inheritDoc} */ protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException { AttributeConsumingService service = (AttributeConsumingService) samlObject; if (attribute.getLocalName().equals(AttributeConsumingService.INDEX_ATTRIB_NAME)) { service.setIndex(Integer.valueOf(attribute.getValue())); } else if (attribute.getLocalName().equals(AttributeConsumingService.IS_DEFAULT_ATTRIB_NAME)) { service.setIsDefault(XSBooleanValue.valueOf(attribute.getValue())); } else { super.processAttribute(samlObject, attribute); } } }
/** * Checks that one or more Service Names are present. * * @param attributeConsumingService * @throws ValidationException */ protected void validateServiceNames(AttributeConsumingService attributeConsumingService) throws ValidationException { if (attributeConsumingService.getNames() == null || attributeConsumingService.getNames().size() == 0) { throw new ValidationException("Must have one or more Service Names."); } }
private void setClaims(SPSSODescriptor spssoDescriptor, SAMLSSOServiceProviderDO samlssoServiceProviderDO) { List<AttributeConsumingService> services; services = spssoDescriptor.getAttributeConsumingServices(); if (services != null && services.size() > 0) { //assuming that only one AttrbuteComsumingIndex exists AttributeConsumingService service = services.get(0); List<RequestedAttribute> attributes = service.getRequestAttributes(); for (RequestedAttribute attribute : attributes) { //set the values to claims } } else { } }
private void setClaims(SPSSODescriptor spssoDescriptor, SAMLSSOServiceProviderDO samlssoServiceProviderDO){ List<AttributeConsumingService> services = new ArrayList<>(); services = spssoDescriptor.getAttributeConsumingServices(); if (services!=null && services.size()>0) { //assuming that only one AttrbuteComsumingIndex exists AttributeConsumingService service = services.get(0); List<RequestedAttribute> attributes = service.getRequestAttributes(); for (RequestedAttribute attribute : attributes){ //set the values to claims } } else { } } private void setDoSignAssertions (SPSSODescriptor spssoDescriptor, SAMLSSOServiceProviderDO samlssoServiceProviderDO){
/** * 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; }
/** * Locates a RequestedAttribute object in metadata that matches a specific Attribute Name * and NameFormat. * * @param service the metadata descriptor to search * @param name Attribute Name to match * @param nameFormat Attribute NameFormat to match * @return a matching RequestedAttribute, or null */ private RequestedAttribute findInMetadata(final AttributeConsumingService service, final String name, final String nameFormat) { final List<RequestedAttribute> requested = service.getRequestAttributes(); for (final RequestedAttribute attr : requested) { if (attr.getName().equals(name)) { final String format = attr.getNameFormat(); if (nameFormat == null || format == null || format.equals(Attribute.UNSPECIFIED) || nameFormat.equals(format)) { return attr; } } } return null; }
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); } } } }