OpenSAML SOAP WSFed: Create AppliesTo Object

Mark Jonsen mark.jonsen.44 at outlook.de
Fri Mar 27 18:11:35 EDT 2020


Hi,

I would like to use OpenSAML to create a WSFed Response. Currently I am unable to create the AppliesTo Object which is part of the RequestSecurityTokenResponse.

Error:
ClassCastException: class org.opensaml.soap.wspolicy.impl.AppliesToImpl cannot be cast to class org.opensaml.soap.wsfed.AppliesTo

I use this method to create OpenSAML objects:
    public static <T> T buildSAMLObject(final Class<T> clazz) {
        QName defaultElementName;
        try {
            defaultElementName = (QName) clazz.getDeclaredField("DEFAULT_ELEMENT_NAME").get(null);
        } catch (IllegalAccessException | NoSuchFieldException ex) {
            throw new IllegalArgumentException("Could not create SAML object", ex);
        }

        XMLObjectBuilderFactory factory = XMLObjectProviderRegistrySupport.getBuilderFactory();
        if (factory == null) {
            throw new RuntimeException("Unable to get builderFactory.");
        }


        XMLObjectBuilder<?> builder = factory.getBuilder(defaultElementName);
        if (builder == null) {
            throw new RuntimeException("Unable to get builder.");
        }

        return (T) builder.buildObject(defaultElementName);
    }

I think the problem is that the AppliesTo from wspolicy and wsfed have the same name.

Is this in general the right way to create this objects?

Thanks i advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://shibboleth.net/pipermail/dev/attachments/20200327/d2aea4a9/attachment.html>


More information about the dev mailing list