/** * Get the map of requested attributes from the profile request context. * * @param prc the profile request context * @return the map of requested attributes or <code>null</code> */ @Nullable protected Multimap<String, IdPRequestedAttribute> getRequestedAttributes(@Nullable final ProfileRequestContext prc) { if (prc != null) { final SAMLMetadataContext metadataContext = metadataContextLookupStrategy.apply(prc); if (metadataContext != null) { final AttributeConsumingService acs = acsLookupStrategy.apply(metadataContext); if (acs != null) { final List<AttributesMapContainer> maps = acs.getObjectMetadata().get(AttributesMapContainer.class); if (maps != null && !maps.isEmpty()) { if (maps.size() > 1) { log.warn("More than one set of mapped attributes found, using the first."); } return maps.get(0).get(); } } } } return null; }
/** * 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); } }