OpenSAML - Trouble with XSAnyImpl
Brent Putman
putmanb at georgetown.edu
Tue Sep 6 22:32:51 BST 2011
On 9/6/11 11:27 AM, Nicolas Peifer wrote:
> Hello,
>
> I have to override the processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject) method in an unmarshaller. The unmarshaller is for a SAMLObject that is used in place of an anyType. So, the problem is that when OpenSAML calls the method the parentSAMLObject and childSAMLObject have the type XSAnyType. Consequently the following cast fails with a ClassCastException (XSAnyImpl cannot be cast to CustomOpenSAML.core.AuthnRequestExtension):
>
> public class AuthnRequestExtensionUnmarshaller extends AbstractSAMLObjectUnmarshaller {
> //... version with highlighted syntax: http://paste.kde.org/118837/
> @Override
> protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject) throws UnmarshallingException {
> //...
> AuthnRequestExtension authnRequestExtension = (AuthnRequestExtension) parentSAMLObject;
> //...
>
> Has anyone an idea why these (parameter) objects are of the type XSAnyType and how can I cast them to the right objects?
>
I think your basic issue is: why is the unmarshalled object, at runtime,
an XSAny? It's probably because you forgot to declare the custom
builder/marshaller/unmarshaller set for that custom element or xsi:type.
So when it gets unmarshalled, it is "unknown" to OpenSAML and winds up
getting handled as an XSAny (which has nothing to do with the schema
particle xs:anyType btw, our docs are very confusing on this point). So
just register your custom XMLObject providers with OpenSAML either
declaratively or programmatically, and that should take care of it.
--Brent
More information about the dev
mailing list