Unmarshalling SAML assertion with openSAML 2 (C++)

Akshay Singh akshay_iiit at yahoo.com
Thu Dec 12 15:14:48 EST 2013


HI List,

I need to unmarshall a SAML assertion which I get from a web-service.
Since there is not much documentation on the internet for the C++ version of openSAML, I looked in to the samltest (in source code) to find out how to unmarshall/parse a SAML response. Everything seems to work fine, until I try to typecast the retrieved XMLObject to opensaml::saml2::Assertion :

/* Converting XMLObject to SAML2::Asserion */
opensaml::saml2::Assertion* assertion = dynamic_cast<opensaml::saml2::Assertion*>(xo);

this returns NULL (showing XMLObject I retrieved cannot be casted to saml::saml2::Assertion).
I understand I am trying to downcast an object pointer, which is not guaranteed to work. But then this is the way it is being done in samltest tests (samltest/saml2/core/impl/Assertion20Test.h). Am I missing something?

I have checked the retrieved XMLObject object and it seems to function well.

For reference,  the class hierarchy is something like this : 

xmlTooling::XMLObject -> saml::signature::SignableObject -> saml::RootObject ->saml::saml2::RootObject -> saml::saml2::Assertion
xmlTooling::XMLObject -> saml::signature::SignableObject -> saml::RootObject ->saml::Assertion -> saml::saml2::Assertion


Posting my sample code on pastebin :

1)  http://snipt.org/Bzjb5 - CPP program trying to unmarshal SAML assertion
2)  http://snipt.org/Bzjc9 - Retrieved SAML assertion (this surely is well-formed, but in case.. )

Thanks,
Akshay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://shibboleth.net/pipermail/users/attachments/20131213/f5efa11c/attachment.html 


More information about the users mailing list