1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.opensaml.saml1.core.impl;
18
19 import org.joda.time.DateTime;
20 import org.joda.time.chrono.ISOChronology;
21 import org.opensaml.common.impl.AbstractSAMLObjectUnmarshaller;
22 import org.opensaml.saml1.core.Condition;
23 import org.opensaml.saml1.core.Conditions;
24 import org.opensaml.xml.XMLObject;
25 import org.opensaml.xml.io.UnmarshallingException;
26 import org.opensaml.xml.util.DatatypeHelper;
27 import org.w3c.dom.Attr;
28
29
30
31
32 public class ConditionsUnmarshaller extends AbstractSAMLObjectUnmarshaller {
33
34
35 protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject)
36 throws UnmarshallingException {
37 Conditions conditions = (Conditions) parentSAMLObject;
38
39 if (childSAMLObject instanceof Condition) {
40 conditions.getConditions().add((Condition) childSAMLObject);
41 } else {
42 super.processChildElement(parentSAMLObject, childSAMLObject);
43 }
44 }
45
46
47 protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
48
49 Conditions conditions = (Conditions) samlObject;
50
51 if (Conditions.NOTBEFORE_ATTRIB_NAME.equals(attribute.getLocalName())
52 && !DatatypeHelper.isEmpty(attribute.getValue())) {
53 conditions.setNotBefore(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC()));
54 } else if (Conditions.NOTONORAFTER_ATTRIB_NAME.equals(attribute.getLocalName())
55 && !DatatypeHelper.isEmpty(attribute.getValue())) {
56 conditions.setNotOnOrAfter(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC()));
57 } else {
58 processAttribute(samlObject, attribute);
59 }
60 }
61 }