/** {@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); } }
protected List<Attribute> getRequestAttributes(SPSSODescriptor desc) { List<Attribute> result = new LinkedList<>(); if (desc.getDefaultAttributeConsumingService() != null) { result.addAll(getRequestedAttributes(desc.getDefaultAttributeConsumingService() .getRequestAttributes())); } else { for (AttributeConsumingService s : ofNullable(desc.getAttributeConsumingServices()).orElse(emptyList())) { if (s != null) { //take the first one result.addAll(getRequestedAttributes(s.getRequestAttributes())); break; } } } return result; }
for (final RequestedAttribute requestedAttribute : attributeConsumingService.getRequestAttributes()) { if (Objects.equals(LibertyConstants.SERVICE_TYPE_SSOS, StringSupport.trimOrNull(requestedAttribute.getName()))) {
@Override protected Map<String, Object> getAttributesForSamlRegisteredService(final Map<String, Object> attributes, final SamlRegisteredService service, final ApplicationContext applicationContext, final SamlRegisteredServiceCachingMetadataResolver resolver, final SamlRegisteredServiceServiceProviderMetadataFacade facade, final EntityDescriptor entityDescriptor) { val releaseAttributes = new HashMap<String, Object>(); val sso = facade.getSsoDescriptor(); if (sso != null) { sso.getAttributeConsumingServices().forEach(svc -> svc.getRequestAttributes().stream().filter(attr -> { val name = this.useFriendlyName ? attr.getFriendlyName() : attr.getName(); LOGGER.debug("Checking for requested attribute [{}] in metadata for [{}]", name, service.getName()); return attributes.containsKey(name); }).forEach(attr -> { val name = this.useFriendlyName ? attr.getFriendlyName() : attr.getName(); LOGGER.debug("Found requested attribute [{}] in metadata for [{}]", name, service.getName()); releaseAttributes.put(name, attributes.get(name)); })); } return releaseAttributes; } }
/** * Look inside the {@link AttributeConsumingService} for any {@link RequestedAttribute}s and map them. * * @param acs the {@link AttributeConsumingService} to look at */ //CheckStyle: ReturnCount OFF private void handleAttributeConsumingService(final AttributeConsumingService acs) { final List<RequestedAttribute> requestedAttributes = acs.getRequestAttributes(); final RequestedAttributesMapper mapper = getRequestedAttributesMapper(); if (null == requestedAttributes || requestedAttributes.isEmpty() || null == mapper) { return; } final Multimap<String, IdPRequestedAttribute> maps = mapper.mapAttributes(requestedAttributes); if (null == maps || maps.isEmpty()) { return; } acs.getObjectMetadata().put(new AttributesMapContainer<>(maps)); } //CheckStyle: ReturnCount ON
/** {@inheritDoc}*/ protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext) { if (acsContext == null) { log.trace("{} AttributeConsumingServiceContext not found", getLogPrefix()); return; } final AttributeConsumingService acs = acsContext.getAttributeConsumingService(); if (acs == null) { log.trace("{} no AttributeConsumingService to map", getLogPrefix()); return; } if (acs.getRequestAttributes().isEmpty() || acs.getObjectMetadata().containsKey(AttributesMapContainer.class) || acs.getParent() != null) { log.trace("{} skipping mapping for AttributeConsumingService", getLogPrefix()); // Nothing to map, already mapped, or attached to metadata (and hence already scanned) return; } try { final AttributeMappingNodeProcessor processor = new AttributeMappingNodeProcessor(attributeResolverService); log.debug("{} mapping requested Attributes for generated AttributeConsumingService", getLogPrefix()); processor.process(acs); } catch (final FilterException e) { log.error("{} Error mapping Attributesresponding to request", getLogPrefix(), e); ActionSupport.buildEvent(profileRequestContext, EventIds.RUNTIME_EXCEPTION); } }
protected AttributeConsumingService getAttributeConsumingService(List<Attribute> attributes) { AttributeConsumingService service = buildSAMLObject(AttributeConsumingService.class); service.setIsDefault(true); service.setIndex(0); List<RequestedAttribute> attrs = new LinkedList<>(); for (Attribute a : attributes) { RequestedAttribute ra = buildSAMLObject(RequestedAttribute.class); ra.setIsRequired(a.isRequired()); ra.setFriendlyName(a.getFriendlyName()); ra.setName(a.getName()); ra.setNameFormat(a.getNameFormat().toString()); attrs.add(ra); } service.getRequestAttributes().addAll(attrs); return service; }
requestAttribute.setNameFormat(attr.getNameFormat()); attributeService.getRequestAttributes().add(requestAttribute);