<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif; ">
<div>Please post to the DEV list for programming questions.</div>
<div><br>
</div>
<div>Paul</div>
<div><br>
</div>
<span id="OLK_SRC_BODY_SECTION">
<div style="font-family:Calibri; font-size:11pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<span style="font-weight:bold">From: </span>Akshay Singh <<a href="mailto:akshay_iiit@yahoo.com">akshay_iiit@yahoo.com</a>><br>
<span style="font-weight:bold">Reply-To: </span>Shibboleth Users <<a href="mailto:users@shibboleth.net">users@shibboleth.net</a>><br>
<span style="font-weight:bold">Date: </span>Thursday, December 12, 2013 3:14 PM<br>
<span style="font-weight:bold">To: </span>Shibboleth Users <<a href="mailto:users@shibboleth.net">users@shibboleth.net</a>><br>
<span style="font-weight:bold">Subject: </span>Unmarshalling SAML assertion with openSAML 2 (C++)<br>
</div>
<div><br>
</div>
<div>
<div>
<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="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;">
I need to unmarshall a SAML assertion which I get from a web-service.</div>
<div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;">
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="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;">
<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="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;">
<br>
</div>
<div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;">
this returns NULL (showing XMLObject I retrieved cannot be casted to saml::saml2::Assertion).</div>
<div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;">
<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="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;">
<span style="background-color: transparent;">I have checked the retrieved XMLObject object and it seems to function well.</span></div>
<div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande',
sans-serif; background-color: transparent; font-style: normal;">
<br>
</div>
<div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;">
For reference, the class hierarchy is something like this : </div>
<div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;">
<br>
</div>
<div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;">
xmlTooling::XMLObject -> saml::signature::SignableObject -> saml::RootObject ->saml::saml2::RootObject -> saml::saml2::Assertion</div>
<div style="color: rgb(0, 0, 0); font-size: 13px; font-family:
HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;">
xmlTooling::XMLObject -> saml::signature::SignableObject -> saml::RootObject ->saml::Assertion -> saml::saml2::Assertion<br>
</div>
<div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;">
<br>
</div>
<div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;">
Posting my sample code on pastebin :</div>
<div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;">
<br>
</div>
<div style="color: rgb(0, 0, 0); font-size:
13px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;">
1) <a href="http://snipt.org/Bzjb5" style="font-size: 10pt;">http://snipt.org/Bzjb5</a> <span style="background-color: transparent;">- CPP program trying to unmarshal SAML assertion</span></div>
<div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;">
2) <a href="http://snipt.org/Bzjc9" style="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="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style:
normal;">
<br>
</div>
<div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;">
Thanks,</div>
<div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;">
Akshay</div>
</div>
</div>
</div>
</span>
</body>
</html>