<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:10pt"><div>Hi List,</div><div><br></div><div style="background-color: transparent;">I need to unmarshall a SAML assertion which I get from a web-service.</div><div style="background-color: transparent;">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 <span style="background-color: transparent;">opensaml::saml2::Assertion :</span></div><div style="background-color: transparent;"><br></div><div style="background-color: transparent;">/* Converting XMLObject to SAML2::Asserion */</div><div style="background-color: transparent;">opensaml::saml2::Assertion* assertion =
dynamic_cast<opensaml::saml2::Assertion*>(xo);</div><div style="background-color: transparent;"><br></div><div style="background-color: transparent;">this returns NULL (showing XMLObject I retrieved cannot be casted to saml::saml2::Assertion).</div><div style="background-color: transparent;"><span style="background-color: transparent;">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?</span><br></div><div style="background-color: transparent;"><span style="background-color: transparent;">I have checked the retrieved XMLObject object and it seems to function well.</span></div><div style="background-color: transparent;"><br></div><div style="background-color: transparent;">For reference, the class hierarchy is something like this : </div><div style="background-color:
transparent;"><br></div><div style="background-color: transparent;">xmlTooling::XMLObject -> saml::signature::SignableObject -> saml::RootObject ->saml::saml2::RootObject -> saml::saml2::Assertion</div><div style="background-color: transparent;">xmlTooling::XMLObject -> saml::signature::SignableObject -> saml::RootObject ->saml::Assertion -> saml::saml2::Assertion<br></div><div style="background-color: transparent;"><br></div><div style="background-color: transparent;">Posting my sample code on pastebin :</div><div style="background-color: transparent;"><br></div><div style="background-color: transparent;">1) <a rel="nofollow" target="_blank" href="http://snipt.org/Bzjb5" style="color: rgb(25, 106, 212); font-size: 10pt;">http://snipt.org/Bzjb5</a> <span style="background-color: transparent;">- CPP program trying to unmarshal SAML assertion</span></div><div style="background-color: transparent;">2) <a
rel="nofollow" target="_blank" href="http://snipt.org/Bzjc9" style="color: rgb(25, 106, 212); font-size: 10pt;">http://snipt.org/Bzjc9</a> <span style="background-color: transparent;">- Retrieved SAML assertion (this surely is well-formed, but in case.. )</span></div><div style="background-color: transparent;"><br></div><div style="background-color: transparent;">Thanks,</div><div style="background-color: transparent;">Akshay</div></div></body></html>