/** {@inheritDoc} */ @Override protected void marshallElementContent(@Nonnull final XMLObject xmlObject, @Nonnull final Element domElement) throws MarshallingException { XSBase64Binary xsBase64Binary = (XSBase64Binary) xmlObject; ElementSupport.appendTextContent(domElement, xsBase64Binary.getValue()); } }
/** Get the Pool configuration <ConnectionPool> element contents, warning if there is more than one. * @return the <ConnectionPool> or null if there isn't one. */ @Nullable Element getConnectionPoolElement() { final List<Element> poolConfigElements = ElementSupport.getChildElements(configElement, new QName(DataConnectorNamespaceHandler.NAMESPACE, "ConnectionPool")); poolConfigElements.addAll(ElementSupport.getChildElements(configElement, new QName(AttributeResolverNamespaceHandler.NAMESPACE, "ConnectionPool"))); if (poolConfigElements.isEmpty()) { return null; } if (poolConfigElements.size() > 1) { log.warn("{} Only one <ConnectionPool> should be specified; only the first has been consulted.", getLogPrefix()); } return poolConfigElements.get(0); }
/** * Get the list of audiences from the <Audience> sub-elements. * * @param element the element under discussion * @return the list of elements (which are subject to property replacement) */ protected List<String> getAudiences(final Element element) { final List<Element> audienceElems = ElementSupport.getChildElementsByTagNameNS(element, RelyingPartySAMLNamespaceHandler.NAMESPACE, "Audience"); return SpringSupport.getElementTextContentAsManagedList(audienceElems); }
/** * Is this inside a <PolicyRequirementRule> or an permit or deny rule?. <br/> * This is used when parsing the various rules (<MatchFunctorType>) since the bean we summon up depends on * where we find ourselves. * * @param element the element under question * @return true if it is inside a policy requirement rule, false otherwise. */ protected boolean isPolicyRule(@Nonnull final Element element) { Element elem = element; do { if (ElementSupport.isElementNamed(elem, BaseFilterParser.POLICY_REQUIREMENT_RULE)) { return true; } else if (ElementSupport.isElementNamed(elem, BaseFilterParser.DENY_VALUE_RULE) || ElementSupport.isElementNamed(elem, BaseFilterParser.PERMIT_VALUE_RULE)) { return false; } elem = ElementSupport.getElementAncestor(elem); } while (elem != null); log.warn("Element '{}' : could not find schema defined parent"); return false; } }
final List<Element> beanManagedElements = ElementSupport.getChildElements(config, BEAN_MANAGED_CONNECTION_DC); beanManagedElements.addAll(ElementSupport.getChildElements(config, BEAN_MANAGED_CONNECTION_RESOLVER)); final List<Element> managedElements = ElementSupport.getChildElements(config, CONTAINER_MANAGED_CONNECTION_DC); managedElements.addAll(ElementSupport.getChildElements(config, CONTAINER_MANAGED_CONNECTION_RESOLVER)); managedElements.addAll(ElementSupport.getChildElements(config, APPLICATION_MANAGED_CONNECTION_DC)); managedElements.addAll(ElementSupport.getChildElements(config, APPLICATION_MANAGED_CONNECTION_RESOLVER)); managedElements.addAll(ElementSupport.getChildElements(config, SIMPLE_MANAGED_CONNECTION_RESOLVER)); return StringSupport.trimOrNull(ElementSupport.getElementContentAsString(beanManagedElements.get(0)));
/** * Filter an <code>EntityAttributes</code> extension element. * * @param entityAttributes the <code>EntityAttributes</code> extension element * @param registrationAuthority the registration authority associated with the entity */ private void filterEntityAttributes(@Nonnull final Element entityAttributes, @Nullable final String registrationAuthority) { // Locate the Attribute elements to filter final List<Element> attributes = ElementSupport.getChildElements(entityAttributes, SAMLSupport.ATTRIBUTE_NAME); // Filter each Attribute in turn for (final Element attribute : attributes) { filterAttribute(attribute, registrationAuthority); // remove the Attribute container if it is now empty if (ElementSupport.getFirstChildElement(attribute) == null) { log.debug("removing empty Attribute"); entityAttributes.removeChild(attribute); } } }
Map<QName, List<Element>> descriptorChildren = ElementSupport.getIndexedChildElements(descriptor); List<Element> extensionsElements = descriptorChildren.get(EXTENSIONS_NAME); if (extensionsElements.isEmpty()) { extensionsElement = ElementSupport.constructElement(descriptor.getOwnerDocument(), EXTENSIONS_NAME); if (!signatureElements.isEmpty()) { Element lastSignatureElement = signatureElements.get(signatureElements.size() - 1); insertExtensionsElementBefore = ElementSupport.getNextSiblingElement(lastSignatureElement); } else { insertExtensionsElementBefore = ElementSupport.getFirstChildElement(descriptor); ElementSupport.appendChildElement(extensionsElement, extension);
Element child = ElementSupport.getFirstChildElement(element); if (ElementSupport.isElementNamed(child, AbstractMetadataProviderParser.METADATA_NAMESPACE, "AttributeFilterRef")) { builder.addPropertyReference("attributeFilter", ElementSupport.getElementContentAsString(child)); child = ElementSupport.getNextSiblingElement(child); } else if (ElementSupport.isElementNamed(child, AbstractMetadataProviderParser.METADATA_NAMESPACE, "AttributeFilterScript")) { builder.addPropertyValue("attributeFilter", if (ElementSupport.isElementNamed(child, Attribute.DEFAULT_ELEMENT_NAME)) { try { final XMLObject attribute = unmarshaller.unmarshall(child); .isElementNamed(child, AbstractMetadataProviderParser.METADATA_NAMESPACE, "Entity")) { final BeanDefinitionBuilder entityIdBuilder = BeanDefinitionBuilder.genericBeanDefinition(EntityIdPredicate.class); entityIdBuilder.addConstructorArgValue(ElementSupport.getElementContentAsString(child)); final ManagedList<Attribute> forRule = new ManagedList(accumulator.size()); forRule.addAll(accumulator); ruleMap.put(entityIdBuilder.getBeanDefinition(), forRule); } else if (ElementSupport.isElementNamed(child, AbstractMetadataProviderParser.METADATA_NAMESPACE, "ConditionRef")) { final ManagedList<Attribute> forRule = new ManagedList(accumulator.size()); forRule.addAll(accumulator); ruleMap.put(new RuntimeBeanReference(ElementSupport.getElementContentAsString(child)), forRule); } else if (ElementSupport.isElementNamed(child, AbstractMetadataProviderParser.METADATA_NAMESPACE, "ConditionScript")) { final ManagedList<Attribute> forRule = new ManagedList(accumulator.size());
/** {@inheritDoc} */ @Override protected void doParse(@Nonnull final Element config, @Nonnull final ParserContext parserContext, @Nonnull final BeanDefinitionBuilder builder) { super.doParse(config, parserContext, builder); DeprecationSupport.warnOnce(ObjectType.XSITYPE, DOMTypeSupport.getXSIType(config).toString(), parserContext.getReaderContext().getResource().getDescription(), "via NameID Generation Service configuration"); if (config.hasAttributeNS(null, "activationConditionRef")) { builder.addPropertyReference("activationCondition", StringSupport.trimOrNull(config.getAttributeNS(null, "activationConditionRef"))); } else { final Element child = ElementSupport.getFirstChildElement(config); if (child != null && ElementSupport.isElementNamed(child, AttributeResolverNamespaceHandler.NAMESPACE, "ActivationConditionScript")) { builder.addPropertyValue("activationCondition", ScriptTypeBeanParser.parseScriptType(ScriptedPredicate.class, child).getBeanDefinition()); } } if (config.hasAttributeNS(null, FORMAT_ATTRIBUTE_NAME)) { final String namespace = StringSupport.trimOrNull(config.getAttributeNS(null, FORMAT_ATTRIBUTE_NAME)); builder.addPropertyValue("nameFormat", namespace); } builder.setInitMethodName(null); builder.addPropertyValue("nameQualifier", StringSupport.trimOrNull(config.getAttributeNS(null, NAMEQUALIFIER_ATTRIBUTE_NAME))); }
builder.addPropertyReference("customObject", customRef); final Element scriptChild = ElementSupport.getFirstChildElement(element); builder.addConstructorArgValue(ElementSupport.getElementContentAsString(scriptChild)); if (ElementSupport.isElementNamed(scriptChild, element.getNamespaceURI(), "Script")) { builder.setFactoryMethod("inlineScript"); } else if (ElementSupport.isElementNamed(scriptChild, element.getNamespaceURI(), "ScriptFile")) { builder.setFactoryMethod("resourceScript");
@Nonnull final BeanDefinitionBuilder builder) { if (!ElementSupport.getChildElements(config, FAILOVER_DATA_CONNECTOR_ELEMENT_NAME).isEmpty()) { DeprecationSupport.warnOnce(ObjectType.ELEMENT, FAILOVER_DATA_CONNECTOR_ELEMENT_NAME.getLocalPart(), TYPE_NAME_RESOLVER.toString(), null); final List<Element> children = ElementSupport.getChildElements(config, ATTRIBUTE_ELEMENT_NAME_DC); children.addAll(ElementSupport.getChildElements(config, ATTRIBUTE_ELEMENT_NAME_RESOLVER)); final List<BeanDefinition> attributes = new ManagedList<>(children.size()); ElementSupport.getChildElementsByTagNameNS(child, DataConnectorNamespaceHandler.NAMESPACE, "Value"); values.addAll(ElementSupport.getChildElementsByTagNameNS(child, AttributeResolverNamespaceHandler.NAMESPACE, "Value")); final ManagedList<BeanDefinition> inValues = new ManagedList<>(values.size());
ElementSupport.constructElement(entitiesDescriptorDocument, SAMLMetadataSupport.ENTITIES_DESCRIPTOR_NAME); NamespaceSupport.appendNamespaceDeclaration(entitiesDescriptor, ElementSupport.appendTextContent(entitiesDescriptor, "\n"); ElementSupport.appendTextContent(entitiesDescriptor, "\n");
/** {@inheritDoc} */ @Override protected void doParse(final Element element, final ParserContext parserContext, final BeanDefinitionBuilder builder) { final List<QName> retainedRoles = new ArrayList<>(); final List<Element> retainedRoleElems = ElementSupport.getChildElementsByTagNameNS(element, AbstractMetadataProviderParser.METADATA_NAMESPACE, "RetainedRole"); if (retainedRoleElems != null) { for (final Element retainedRoleElem : retainedRoleElems) { retainedRoles.add(ElementSupport.getElementContentAsQName(retainedRoleElem)); } } builder.addConstructorArgValue(retainedRoles); if (element.hasAttributeNS(null, "removeRolelessEntityDescriptors")) { builder.addPropertyValue("removeRolelessEntityDescriptors", StringSupport.trimOrNull(element.getAttributeNS(null, "removeRolelessEntityDescriptors"))); } if (element.hasAttributeNS(null, "removeEmptyEntitiesDescriptors")) { builder.addPropertyValue("removeEmptyEntitiesDescriptors", StringSupport.trimOrNull(element.getAttributeNS(null, "removeEmptyEntitiesDescriptors"))); } }
/** * Checks if the given element is an EntitiesDescriptor. * * @param e element to check * * @return true if the element is an EntitiesDescriptor, false otherwise */ public static boolean isEntitiesDescriptor(@Nullable final Element e) { return ElementSupport.isElementNamed(e, ENTITIES_DESCRIPTOR_NAME); }
ElementSupport.appendChildElement(parentElement, domElement); .getElementQName()); final Document owningDocument = parentElement.getOwnerDocument(); domElement = ElementSupport.constructElement(owningDocument, xmlObject.getElementQName()); ElementSupport.appendChildElement(parentElement, domElement); domElement = marshallInto(xmlObject, domElement);
ElementSupport.adoptElement(document, domElement); domElement = ElementSupport.constructElement(document, xmlObject.getElementQName());
final Map<QName, List<Element>> childrenMap = ElementSupport.getIndexedChildElements(config);
/** * Determines whether a given DOM element has any element children. * * @param element Element to check for child elements. * @return true if and only if the Element has child elements. */ private boolean hasChildElements(@Nonnull final Element element) { Node firstChild = ElementSupport.getFirstChildElement(Constraint.isNotNull(element, "Element can not be null")); return firstChild != null; }
final Element template = ElementSupport.getFirstChildElement(element, TEMPLATE); if (template != null) { final String templateString = StringSupport.trimOrNull(ElementSupport.getElementContentAsString(template)); final String encodingStyle = parseTemplateEncodingStyle(template); String velocityEngineRef = final Element regex = ElementSupport.getFirstChildElement(element, REGEX); if (regex != null) { final String replacement = StringSupport.trimOrNull(ElementSupport.getElementContentAsString(regex)); final String match = StringSupport.trimOrNull(StringSupport.trimOrNull(regex.getAttributeNS(null, "match"))); final Element mdq = ElementSupport.getFirstChildElement(element, METADATA_QUERY_PROTOCOL); if (mdq != null) { final String baseURL = ElementSupport.getElementContentAsString(mdq); final String transformRef = StringSupport.trimOrNull(StringSupport.trimOrNull(mdq.getAttributeNS(null, "transformRef")));
/** {@inheritDoc} */ protected void unmarshallTextContent(XMLObject xmlObject, Text content) throws UnmarshallingException { String textContent = StringSupport.trimOrNull(content.getWholeText()); if (textContent != null) { XSQName qname = (XSQName) xmlObject; qname.setValue(QNameSupport.constructQName(ElementSupport.getElementAncestor(content), textContent)); } } }