/** {@inheritDoc} */ protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject) throws UnmarshallingException { AttributeQuery attributeQuery = (AttributeQuery) parentSAMLObject; if (childSAMLObject instanceof AttributeDesignator) { attributeQuery.getAttributeDesignators().add((AttributeDesignator) childSAMLObject); } else { super.processChildElement(parentSAMLObject, childSAMLObject); } }
/** {@inheritDoc} */ protected void marshallAttributes(XMLObject samlElement, Element domElement) throws MarshallingException { AttributeQuery attributeQuery = (AttributeQuery) samlElement; if (attributeQuery.getResource() != null) { domElement.setAttributeNS(null, AttributeQuery.RESOURCE_ATTRIB_NAME, attributeQuery.getResource()); } } }
/** {@inheritDoc} */ protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException { AttributeQuery attributeQuery = (AttributeQuery) samlObject; if (attribute.getLocalName().equals(AttributeQuery.RESOURCE_ATTRIB_NAME)) { attributeQuery.setResource(attribute.getValue()); } else { super.processAttribute(samlObject, attribute); } } }
/** {@inheritDoc} */ @Override protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext) { final Collection<IdPAttribute> keepers = new ArrayList<>(query.getAttributeDesignators().size()); final Multimap<String,IdPAttribute> mapped = mapperService.mapAttributes(query.getAttributeDesignators()); log.debug("Query content mapped to attribute IDs: {}", mapped.keySet()); for (final IdPAttribute attribute : attributeContext.getIdPAttributes().values()) { if (mapped.containsKey(attribute.getId())) { log.debug("Retaining attribute '{}' requested by query", attribute.getId()); keepers.add(attribute); } else { log.debug("Removing attribute '{}' not requested by query", attribute.getId()); } } attributeContext.setIdPAttributes(keepers); }
/** * Resolve the SAML entity ID from a SAML 1 AttributeQuery. * * @param query the query * * @return the entity ID, or null if it could not be resolved */ @Nullable protected String processSaml1AttributeQuery(@Nonnull final AttributeQuery query) { if (getUseSAML1QueryResourceAsEntityId()) { log.debug("Attempting to extract entity ID from SAML 1 AttributeQuery Resource attribute"); final String resource = StringSupport.trimOrNull(query.getResource()); if (resource != null) { log.debug("Extracted entity ID from SAML 1.x AttributeQuery: {}", resource); return resource; } } return null; }
/** {@inheritDoc} */ @Override protected boolean doPreExecute(@Nonnull final ProfileRequestContext profileRequestContext) { if (!super.doPreExecute(profileRequestContext)) { return false; } final Request request = requestLookupStrategy.apply(profileRequestContext); if (request != null) { query = request.getAttributeQuery(); } if (query == null || query.getAttributeDesignators().isEmpty()) { log.debug("No AttributeDesignators found, nothing to do "); return false; } attributeContext = attributeContextLookupStrategy.apply(profileRequestContext); if (attributeContext == null) { log.debug("{} No attribute context, no attributes to filter", getLogPrefix()); return false; } if (attributeContext.getIdPAttributes().isEmpty()) { log.debug("{} No attributes to filter", getLogPrefix()); return false; } return true; }