I have been beating my head against this for a while, and am starting to make progress. However, I ran into some trouble converting a string representation of a SAML 2 Assertion (in XML) to an Assertion object.
It looks like I am getting a valid org.w3c.dom.Document
with appropriate data, and I seem to be getting a valid SAMLObjectBuilder<Assertion>
from the builder factory, but when I try to put them together all I get is a blank Assertion; subject, issuer, issue time and so on are all null
, despite them clearly being set in the XML.
Does anyone see what I am doing wrong, and can suggest a solution?
Document doc = loadXMLFromString(saml);
XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
SAMLObjectBuilder<Assertion> assertionBuilder =
(SAMLObjectBuilder<Assertion>)
builderFactory.getBuilder(Assertion.DEFAULT_ELEMENT_NAME);
Assertion assertion = assertionBuilder.buildObject(doc.getDocumentElement());
String nameID = assertion.getSubject().getNameID().getValue();
At the nameID assignment, assertion.getSubject()
returns null
, failing the remainder of the expression.
The example I am using is the full XML from sstc-saml-tech-overview-2.0-draft-03, page 10.
The function loadXMLFromString()
above is mostly borrowed from In Java, how do I parse XML as a String instead of a file?
[SOLVED]
here. If you've got your answer, please mark it with the green tick to the left of it - your question will only then be marked as "solved". – moinudin