Legacy config parsers and boolean attribute/predicates

Brent Putman putmanb at georgetown.edu
Fri Oct 16 19:29:03 EDT 2015


Rod, or anyone,

I was looking at deprecating the boolean SAML 2 SSO profile config
'allowingDelegation' and implementing a Predicate, which will be
'allowDelegation'.

Was wondering how we handle auto-conversion of Strings to Predicates in
the config parsers, if at all.  I know for native Spring we have the
StringBooleanToPredicateConverter, but doesn't seem to work for the
legacy parsers. 

What I came up with is below.  Is this horribly wrong?  Is there a
better simpler way?

Basically, leave the old schema attribute 'allowDelegation' in place,
undeprecated, but convert to a Predicate and set the new property.  For
'allowDelegationPredicateRef', just set the ref directly.

        if (element.hasAttributeNS(null, "allowDelegation")) {
            if (element.hasAttributeNS(null,
"allowDelegationPredicateRef")) {
                log.warn("Attribute 'allowDelegation' is being ignored
in favor of 'allowDelegationPredicateRef'");
            } else {
                Boolean value =
AttributeSupport.getAttributeValueAsBoolean(
                        element.getAttributeNodeNS(null,
"allowDelegation"));
                if (value != null) {
                    if (value) {
                        builder.addPropertyValue("allowDelegation",
Predicates.alwaysTrue());
                    } else {
                        builder.addPropertyValue("allowDelegation",
Predicates.alwaysFalse());
                    }
                } else {
                    log.error("Attribute 'allowDelegation' is being
ignored because it's not a legal xs:boolean value");
                    throw new BeanDefinitionParsingException(new Problem(
                            "Attribute 'allowDelegation' is being
ignored because it's not a legal xs:boolean value",
                            new
Location(parserContext.getReaderContext().getResource())));
                }
            }
        }
       
        if (element.hasAttributeNS(null, "allowDelegationPredicateRef")) {
            builder.addPropertyReference("allowDelegation",
                   
StringSupport.trimOrNull(element.getAttributeNS(null,
"allowDelegationPredicateRef")));
        }


Rather than add the new 'allowDelegationPredicateRef' attribute to the
schema, would it be more appropriate to overload 'allowDelegation' to
handle both (String) boolean value and bean ref?

Have we done anything similar as precedent?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://shibboleth.net/pipermail/dev/attachments/20151016/e98f19f3/attachment.html>


More information about the dev mailing list