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 javax.xml.namespace.QName;
24
25 import org.joda.time.DateTime;
26 import org.joda.time.chrono.ISOChronology;
27 import org.opensaml.common.impl.AbstractSAMLObjectUnmarshaller;
28 import org.opensaml.saml2.core.SubjectConfirmationData;
29 import org.opensaml.xml.XMLObject;
30 import org.opensaml.xml.io.UnmarshallingException;
31 import org.opensaml.xml.util.DatatypeHelper;
32 import org.opensaml.xml.util.XMLHelper;
33 import org.w3c.dom.Attr;
34
35
36
37
38 public class SubjectConfirmationDataUnmarshaller extends AbstractSAMLObjectUnmarshaller {
39
40
41
42
43 protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject)
44 throws UnmarshallingException {
45 SubjectConfirmationData subjectCD = (SubjectConfirmationData) parentSAMLObject;
46
47 subjectCD.getUnknownXMLObjects().add(childSAMLObject);
48 }
49
50
51 protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
52 SubjectConfirmationData subjectCD = (SubjectConfirmationData) samlObject;
53
54 if (attribute.getLocalName().equals(SubjectConfirmationData.NOT_BEFORE_ATTRIB_NAME)
55 && !DatatypeHelper.isEmpty(attribute.getValue())) {
56 subjectCD.setNotBefore(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC()));
57 } else if (attribute.getLocalName().equals(SubjectConfirmationData.NOT_ON_OR_AFTER_ATTRIB_NAME)
58 && !DatatypeHelper.isEmpty(attribute.getValue())) {
59 subjectCD.setNotOnOrAfter(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC()));
60 } else if (attribute.getLocalName().equals(SubjectConfirmationData.RECIPIENT_ATTRIB_NAME)) {
61 subjectCD.setRecipient(attribute.getValue());
62 } else if (attribute.getLocalName().equals(SubjectConfirmationData.IN_RESPONSE_TO_ATTRIB_NAME)) {
63 subjectCD.setInResponseTo(attribute.getValue());
64 } else if (attribute.getLocalName().equals(SubjectConfirmationData.ADDRESS_ATTRIB_NAME)) {
65 subjectCD.setAddress(attribute.getValue());
66 } else {
67 QName attribQName = XMLHelper.getNodeQName(attribute);
68 if (attribute.isId()) {
69 subjectCD.getUnknownAttributes().registerID(attribQName);
70 }
71 subjectCD.getUnknownAttributes().put(attribQName, attribute.getValue());
72 }
73 }
74 }