1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.opensaml.xacml.policy.impl;
19
20 import org.opensaml.xacml.XACMLConstants;
21 import org.opensaml.xacml.policy.CombinerParametersType;
22 import org.opensaml.xacml.policy.DefaultsType;
23 import org.opensaml.xacml.policy.DescriptionType;
24 import org.opensaml.xacml.policy.IdReferenceType;
25 import org.opensaml.xacml.policy.ObligationsType;
26 import org.opensaml.xacml.policy.PolicyCombinerParametersType;
27 import org.opensaml.xacml.policy.PolicySetCombinerParametersType;
28 import org.opensaml.xacml.policy.PolicySetType;
29 import org.opensaml.xacml.policy.PolicyType;
30 import org.opensaml.xacml.policy.TargetType;
31 import org.opensaml.xml.XMLObject;
32 import org.opensaml.xml.io.AbstractXMLObjectUnmarshaller;
33 import org.opensaml.xml.io.UnmarshallingException;
34 import org.w3c.dom.Attr;
35
36
37 public class PolicySetTypeUnmarshaller extends AbstractXMLObjectUnmarshaller {
38
39
40 public PolicySetTypeUnmarshaller() {
41 super(XACMLConstants.XACML20_NS, PolicySetType.DEFAULT_ELEMENT_LOCAL_NAME);
42 }
43
44
45 protected void processAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException {
46 PolicySetType policySet = (PolicySetType) xmlObject;
47
48 if (attribute.getLocalName().equals(PolicySetType.POLICY_SET_ID_ATTRIB_NAME)) {
49 policySet.setPolicySetId(attribute.getValue());
50 } else if (attribute.getLocalName().equals(PolicySetType.VERSION_ATTRIB_NAME)) {
51 policySet.setVersion(attribute.getValue());
52 } else if (attribute.getLocalName().equals(PolicySetType.POLICY_COMBINING_ALG_ID_ATTRIB_NAME)) {
53 policySet.setPolicyCombiningAlgoId(attribute.getValue());
54 }
55 }
56
57
58 protected void processChildElement(XMLObject parentXMLObject, XMLObject childXMLObject)
59 throws UnmarshallingException {
60 PolicySetType policySet = (PolicySetType) parentXMLObject;
61
62 if (childXMLObject instanceof DescriptionType) {
63 policySet.setDescription((DescriptionType) childXMLObject);
64 } else if (childXMLObject instanceof DefaultsType) {
65 policySet.setPolicySetDefaults((DefaultsType) childXMLObject);
66 } else if (childXMLObject instanceof TargetType){
67 policySet.setTarget((TargetType) childXMLObject);
68 } else if (childXMLObject instanceof PolicySetType) {
69 policySet.getPolicySets().add((PolicySetType) childXMLObject);
70 } else if (childXMLObject instanceof PolicyType) {
71 policySet.getPolicies().add((PolicyType) childXMLObject);
72 } else if (childXMLObject.getElementQName().equals(IdReferenceType.POLICY_SET_ID_REFERENCE_ELEMENT_NAME)) {
73 policySet.getPolicySetIdReferences().add((IdReferenceType) childXMLObject);
74 } else if (childXMLObject.getElementQName().equals(IdReferenceType.POLICY_ID_REFERENCE_ELEMENT_NAME)) {
75 policySet.getPolicyIdReferences().add((IdReferenceType) childXMLObject);
76 } else if (childXMLObject.getElementQName().equals(CombinerParametersType.DEFAULT_ELEMENT_NAME)) {
77 policySet.getCombinerParameters().add((CombinerParametersType) childXMLObject);
78 } else if (childXMLObject.getElementQName().equals(PolicyCombinerParametersType.DEFAULT_ELEMENT_NAME)) {
79 policySet.getPolicyCombinerParameters().add((PolicyCombinerParametersType) childXMLObject);
80 } else if (childXMLObject.getElementQName().equals(PolicySetCombinerParametersType.DEFAULT_ELEMENT_NAME)) {
81 policySet.getPolicySetCombinerParameters().add((PolicySetCombinerParametersType) childXMLObject);
82 } else if (childXMLObject instanceof ObligationsType) {
83 policySet.setObligations((ObligationsType) childXMLObject);
84 }
85 }
86
87
88 protected void processElementContent(XMLObject xmlObject, String elementContent) {
89
90 }
91 }