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