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.common.Extensions;
28 import org.opensaml.saml2.core.Issuer;
29 import org.opensaml.saml2.core.Status;
30 import org.opensaml.saml2.core.StatusResponseType;
31 import org.opensaml.xml.XMLObject;
32 import org.opensaml.xml.io.UnmarshallingException;
33 import org.opensaml.xml.signature.Signature;
34 import org.opensaml.xml.util.DatatypeHelper;
35 import org.w3c.dom.Attr;
36
37
38
39
40 public abstract class StatusResponseTypeUnmarshaller extends AbstractSAMLObjectUnmarshaller {
41
42
43 protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
44 StatusResponseType sr = (StatusResponseType) samlObject;
45
46 if (attribute.getLocalName().equals(StatusResponseType.VERSION_ATTRIB_NAME)) {
47 sr.setVersion(SAMLVersion.valueOf(attribute.getValue()));
48 } else if (attribute.getLocalName().equals(StatusResponseType.ID_ATTRIB_NAME)) {
49 sr.setID(attribute.getValue());
50 attribute.getOwnerElement().setIdAttributeNode(attribute, true);
51 } else if (attribute.getLocalName().equals(StatusResponseType.IN_RESPONSE_TO_ATTRIB_NAME)) {
52 sr.setInResponseTo(attribute.getValue());
53 } else if (attribute.getLocalName().equals(StatusResponseType.ISSUE_INSTANT_ATTRIB_NAME)
54 && !DatatypeHelper.isEmpty(attribute.getValue())) {
55 sr.setIssueInstant(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC()));
56 } else if (attribute.getLocalName().equals(StatusResponseType.DESTINATION_ATTRIB_NAME)) {
57 sr.setDestination(attribute.getValue());
58 } else if (attribute.getLocalName().equals(StatusResponseType.CONSENT_ATTRIB_NAME)) {
59 sr.setConsent(attribute.getValue());
60 } else {
61 super.processAttribute(samlObject, attribute);
62 }
63 }
64
65
66 protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject)
67 throws UnmarshallingException {
68 StatusResponseType sr = (StatusResponseType) parentSAMLObject;
69
70 if (childSAMLObject instanceof Issuer) {
71 sr.setIssuer((Issuer) childSAMLObject);
72 } else if (childSAMLObject instanceof Signature) {
73 sr.setSignature((Signature) childSAMLObject);
74 } else if (childSAMLObject instanceof Extensions) {
75 sr.setExtensions((Extensions) childSAMLObject);
76 } else if (childSAMLObject instanceof Status) {
77 sr.setStatus((Status) childSAMLObject);
78 } else {
79 super.processChildElement(parentSAMLObject, childSAMLObject);
80 }
81 }
82 }