1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.opensaml.saml2.core.impl;
22
23 import org.joda.time.DateTime;
24 import org.joda.time.chrono.ISOChronology;
25 import org.opensaml.common.SAMLVersion;
26 import org.opensaml.common.impl.AbstractSAMLObjectUnmarshaller;
27 import org.opensaml.saml2.core.Advice;
28 import org.opensaml.saml2.core.Assertion;
29 import org.opensaml.saml2.core.Conditions;
30 import org.opensaml.saml2.core.Issuer;
31 import org.opensaml.saml2.core.Statement;
32 import org.opensaml.saml2.core.Subject;
33 import org.opensaml.xml.XMLObject;
34 import org.opensaml.xml.io.UnmarshallingException;
35 import org.opensaml.xml.signature.Signature;
36 import org.opensaml.xml.util.DatatypeHelper;
37 import org.w3c.dom.Attr;
38
39
40
41
42 public class AssertionUnmarshaller extends AbstractSAMLObjectUnmarshaller {
43
44
45 protected void processChildElement(XMLObject parentObject, XMLObject childObject) throws UnmarshallingException {
46 Assertion assertion = (Assertion) parentObject;
47
48 if (childObject instanceof Issuer) {
49 assertion.setIssuer((Issuer) childObject);
50 } else if (childObject instanceof Signature) {
51 assertion.setSignature((Signature) childObject);
52 } else if (childObject instanceof Subject) {
53 assertion.setSubject((Subject) childObject);
54 } else if (childObject instanceof Conditions) {
55 assertion.setConditions((Conditions) childObject);
56 } else if (childObject instanceof Advice) {
57 assertion.setAdvice((Advice) childObject);
58 } else if (childObject instanceof Statement) {
59 assertion.getStatements().add((Statement) childObject);
60 } else {
61 super.processChildElement(parentObject, childObject);
62 }
63 }
64
65
66 protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
67 Assertion assertion = (Assertion) samlObject;
68
69 if (attribute.getLocalName().equals(Assertion.VERSION_ATTRIB_NAME)) {
70 assertion.setVersion(SAMLVersion.valueOf(attribute.getValue()));
71 } else if (attribute.getLocalName().equals(Assertion.ISSUE_INSTANT_ATTRIB_NAME)
72 && !DatatypeHelper.isEmpty(attribute.getValue())) {
73 assertion.setIssueInstant(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC()));
74 } else if (attribute.getLocalName().equals(Assertion.ID_ATTRIB_NAME)) {
75 assertion.setID(attribute.getValue());
76 attribute.getOwnerElement().setIdAttributeNode(attribute, true);
77 } else {
78 super.processAttribute(samlObject, attribute);
79 }
80 }
81 }