Seeking advice on serialization of empty string value for SAMLObjects attributes
Broeder, drs. H.R. den (Hans)
H.DenBroeder at dictu.nl
Wed Mar 25 07:22:18 EDT 2020
Hi,
I understand that not setting attribute values on SAMLObjects object instances result in not being serialized. But, what about attributes that take a String and then specifically specifying an empty string value?
Consider the following lines when using OpenSAML 3.4.5 where an AssertionConsumerService object instance is created and an empty string is specified for a (according to the saml specs a required) Location attribute:
InitializationService.initialize();
XMLObjectBuilderFactory builderFactory = XMLObjectProviderRegistrySupport.getBuilderFactory();
XMLObjectBuilder<? extends XMLObject> builder = builderFactory.getBuilder(AssertionConsumerService.DEFAULT_ELEMENT_NAME);
Object o = builder.buildObject(AssertionConsumerService.DEFAULT_ELEMENT_NAME);
AssertionConsumerService acs = AssertionConsumerService.class.cast(o);
acs.setLocation("");
acs.setBinding(SAMLConstants.SAML2_ARTIFACT_BINDING_URI);
acs.setIndex(0);
Marshaller m = XMLObjectProviderRegistrySupport.getMarshallerFactory().getMarshaller(acs);
Element dom = m.marshall(acs);
String s = SerializeSupport.nodeToString(dom);
System.out.println(s);
This results in my case in the following output:
<?xml version="1.0" encoding="UTF-8"?><md:AssertionConsumerService xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata" Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact" index="0"/>
At first I thought that it might have anything to do with the LS serializer and I have looked at directing the LS serializer with options like "discard-default-content", as in the next few lines. But it does not have an effect in this case.
Map<String, Object> options = new HashMap<>();
options.put("discard-default-content", Boolean.FALSE);
String s = SerializeSupport.nodeToString(dom, options);
Is this intended behaviour? Is there anyting I can do to achieve the desired result, which is serialization of attributes with empty string values?
Thanks,
Hans
Dit bericht kan informatie bevatten die niet voor u is bestemd. Indien u
niet de geadresseerde bent of dit bericht abusievelijk aan u is gezonden,
wordt u verzocht dat aan de afzender te melden en het bericht te
verwijderen.
De Staat aanvaardt geen aansprakelijkheid voor schade, van welke aard
ook, die verband houdt met risico's verbonden aan het elektronisch
verzenden van berichten.
This message may contain information that is not intended for you. If you
are not the addressee or if this message was sent to you by mistake, you
are requested to inform the sender and delete the message.
The State accepts no liability for damage of any kind resulting from the
risks inherent in the electronic transmission of messages.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://shibboleth.net/pipermail/dev/attachments/20200325/1de6e9b4/attachment.html>
More information about the dev
mailing list