Seeking advice on serialization of empty string value for SAMLObjects attributes

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Seeking advice on serialization of empty string value for SAMLObjects attributes

Broeder, drs. H.R. den (Hans)

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.
--
To unsubscribe from this list send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Seeking advice on serialization of empty string value for SAMLObjects attributes

Cantor, Scott E.
On 3/25/20, 7:22 AM, "dev on behalf of Broeder, drs. H.R. den (Hans)" <[hidden email] on behalf of [hidden email]> wrote:

> Is this intended behaviour? Is there anyting I can do to achieve the desired result, which is serialization of attributes with
> empty string values?

No, because SAML disallows them almost universally.

-- Scott


--
To unsubscribe from this list send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

RE: Seeking advice on serialization of empty string value for SAMLObjects attributes

Broeder, drs. H.R. den (Hans)
Thanks Scott,

So, I read your answer as:
> Is this intended behaviour?
        >> Yes
> Is there anyting I can do to achieve the  desired result, which is serialization of attributes with empty string values?
        >> No, because SAML disallows them almost universally.

Thanks,
Hans

-----Oorspronkelijk bericht-----
Van: dev <[hidden email]> Namens Cantor, Scott
Verzonden: woensdag 25 maart 2020 13:23
Aan: Shib Dev <[hidden email]>
Onderwerp: Re: Seeking advice on serialization of empty string value for SAMLObjects attributes

On 3/25/20, 7:22 AM, "dev on behalf of Broeder, drs. H.R. den (Hans)" <[hidden email] on behalf of [hidden email]> wrote:

> Is this intended behaviour? Is there anyting I can do to achieve the
> desired result, which is serialization of attributes with empty string values?

No, because SAML disallows them almost universally.

-- Scott


--
To unsubscribe from this list send an email to [hidden email]
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.

--
To unsubscribe from this list send an email to [hidden email]