1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.opensaml.xacml.policy.impl;
20
21 import org.opensaml.common.impl.AbstractSAMLObjectUnmarshaller;
22 import org.opensaml.xacml.policy.AttributeAssignmentType;
23 import org.opensaml.xacml.policy.EffectType;
24 import org.opensaml.xacml.policy.ObligationType;
25 import org.opensaml.xml.XMLObject;
26 import org.opensaml.xml.io.UnmarshallingException;
27 import org.w3c.dom.Attr;
28
29
30 public class ObligationTypeUnmarshaller extends AbstractSAMLObjectUnmarshaller {
31
32
33 protected void processChildElement(XMLObject parentObject, XMLObject childObject) throws UnmarshallingException {
34 ObligationType obligation = (ObligationType) parentObject;
35
36 if (childObject instanceof AttributeAssignmentType) {
37 obligation.getAttributeAssignments().add((AttributeAssignmentType) childObject);
38 }
39 }
40
41
42 protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
43
44 ObligationType obligation = (ObligationType) samlObject;
45
46 if (attribute.getLocalName().equals(ObligationType.OBLIGATION_ID_ATTRIB_NAME)) {
47 obligation.setObligationId(attribute.getValue());
48 }
49 if (attribute.getLocalName().equals(ObligationType.FULFILL_ON_ATTRIB_NAME)) {
50 if (attribute.getValue().equals(EffectType.Permit.toString())) {
51 obligation.setFulfillOn(EffectType.Permit);
52 } else {
53 obligation.setFulfillOn(EffectType.Deny);
54 }
55 }
56 }
57 }