I went through the apache neethi implementation and interested to involve in development.
And I developed a new policy normalizing algorithum ( see the attached patch).
All the testcassed passed in test3/NormalizeTest. I think it is less complex algorithum
than the existing one.
regards,
And I developed a new policy normalizing algorithum ( see the attached patch).
All the testcassed passed in test3/NormalizeTest. I think it is less complex algorithum
than the existing one.
regards,
Amila.
Index: org/apache/neethi/AbstractPolicyOperator.java
===================================================================
--- org/apache/neethi/AbstractPolicyOperator.java (revision 424964)
+++ org/apache/neethi/AbstractPolicyOperator.java (working copy)
@@ -48,8 +48,12 @@
return policyComponents.isEmpty();
}
+ public PolicyComponent normalize() {
+ return normalize(false);
+ }
+
protected List crossProduct(ArrayList allTerms, int index,
- boolean matchVacabulary) {
+ boolean matchVacabulary) {
ArrayList result = new ArrayList();
ExactlyOne firstTerm = (ExactlyOne) allTerms.get(index);
@@ -67,7 +71,7 @@
Iterator firstTermIter = firstTerm.getPolicyComponents().iterator();
while (firstTermIter.hasNext()) {
-
+
All assertion = (All) firstTermIter.next();
Iterator restTermsItr = restTerms.iterator();
@@ -121,7 +125,7 @@
for (; S.hasNext();) {
Sq = ((Assertion) S.next()).getName();
-
+
if (Lq.equals(Sq)) {
found = true;
break;
@@ -134,4 +138,150 @@
}
return true;
}
+
+ /**
+ * normalized form of the the assertion, all and Exactly one define as
+ * <ExactlyOne>
+ * <All>
+ * <Assertion/>
+ * </All>
+ * <ExactlyOne>
+ *
+ * @param isDeep - normalize the assertions or not - currently assertion
normalization is not implemented
+ * @return the normalize form of this policy commponent
+ */
+
+ public PolicyComponent normalize(boolean isDeep) {
+
+ // first we chack whether this is an empty element or not
+ // if an empty element then we can define the normalized form directly
+ PolicyComponent normalizedComponent = null;
+ // get the type this can either be POLICY, EXACTLYONE, ALL or ASSERTION
+ short type = getType();
+ if (policyComponents.isEmpty()) {
+ // i.e. this is an empty elemnnt
+ if (type == PolicyComponent.EXACTLYONE) {
+ // this is already normalized commponent
+ normalizedComponent = this;
+ } else if ((type == PolicyComponent.ALL) || (type ==
PolicyComponent.POLICY)) {
+ ExactlyOne exactlyOne = new ExactlyOne();
+ exactlyOne.addPolicyComponent(new All());
+ normalizedComponent = exactlyOne;
+ }
+ } else {
+ // first we get the normal form of all the child componets
+ // then simplyfy them according to the type of the component
+
+ List normalizedInnerComponets = new ArrayList();
+ PolicyComponent policyComponent;
+
+ for (Iterator iter = policyComponents.iterator(); iter.hasNext();)
{
+ policyComponent = (PolicyComponent) iter.next();
+ if (policyComponent.getType() == PolicyComponent.POLICY) {
+ // if the type is policy we have to replace it with All
+ All all = new All();
+ all.addPolicyComponents(((Policy)
policyComponent).getPolicyComponents());
+ // recursively call normalize method
+ normalizedInnerComponets.add(all.normalize(isDeep));
+ } else {
+
normalizedInnerComponets.add(policyComponent.normalize(isDeep));
+ }
+ }
+
+ normalizedComponent =
getNormalizedComponent(normalizedInnerComponets, type);
+ }
+ return normalizedComponent;
+
+ }
+
+ /**
+ * assume that the normalizedInnerComponets list is not empty
+ * and all exactly one components are normalized
+ *
+ * @param normalizedInnerComponets
+ * @param componentType
+ * @return prossesed elemnt of the inner exactly ones
+ */
+
+ private PolicyComponent getNormalizedComponent(List
normalizedInnerComponets, short componentType) {
+ ExactlyOne exactlyOne = new ExactlyOne();
+ if (componentType == PolicyComponent.EXACTLYONE) {
+ //if the parent type is ExactlyOne then we have to get all the All
Components
+ //into one ExactlyOne
+ ExactlyOne innerExactlyOne;
+
+ // being empty is not a problem sinsce we are inside an Exactly
one elemnt
+ for (Iterator iter = normalizedInnerComponets.iterator();
iter.hasNext();) {
+ innerExactlyOne = (ExactlyOne) iter.next();
+
exactlyOne.addPolicyComponents(innerExactlyOne.getPolicyComponents());
+ }
+
+ } else if ((componentType == PolicyComponent.ALL) || (componentType ==
PolicyComponent.POLICY)) {
+ // if the parent type is All then we have to get the cross product
+ if (normalizedInnerComponets.size() > 1) {
+ // then we have to get the cross product with each other to
process all elements
+ Iterator iter = normalizedInnerComponets.iterator();
+ // first get the first element
+ exactlyOne = (ExactlyOne) iter.next();
+ // if this is empty, this is an not admissible policy and
total result is equalent to that
+ if (!exactlyOne.isEmpty()) {
+ ExactlyOne currentExactlyOne;
+
+ for (; iter.hasNext();) {
+ currentExactlyOne = (ExactlyOne) iter.next();
+ if (currentExactlyOne.isEmpty()) {
+ // if this is empty, this is an not admissible
policy and total result is equalent to that
+ exactlyOne = currentExactlyOne;
+ break;
+ } else {
+ exactlyOne = getCrossProduct(exactlyOne,
currentExactlyOne);
+ }
+ }
+
+ }
+
+
+ } else {
+ // i.e only one element exists in the list then we can safely
+ // return that element this is ok even if it is an empty
element
+ exactlyOne = (ExactlyOne)
normalizedInnerComponets.iterator().next();
+ }
+
+ }
+ return exactlyOne;
+ }
+
+
+ /**
+ * here it is assumed that the two arguments passed to the method are not
empty arguments
+ * and exactlyOne1 and exactlyOne2 in normal form
+ *
+ * @param exactlyOne1
+ * @param exactlyOne2
+ * @return cross product of the two exactlyones
+ */
+ protected ExactlyOne getCrossProduct(ExactlyOne exactlyOne1, ExactlyOne
exactlyOne2) {
+ ExactlyOne crossProduct = new ExactlyOne();
+ All crossProductAll;
+
+ All currentAll1;
+ All currentAll2;
+
+ for (Iterator iter1 = exactlyOne1.getPolicyComponents().iterator();
iter1.hasNext();) {
+ currentAll1 = (All) iter1.next();
+
+ for (Iterator iter2 =
exactlyOne2.getPolicyComponents().iterator(); iter2.hasNext();) {
+ currentAll2 = (All) iter2.next();
+ crossProductAll = new All();
+
crossProductAll.addPolicyComponents(currentAll1.getPolicyComponents());
+
crossProductAll.addPolicyComponents(currentAll2.getPolicyComponents());
+ crossProduct.addPolicyComponent(crossProductAll);
+ }
+
+ }
+
+ return crossProduct;
+
+ }
+
}
Index: org/apache/neethi/Policy.java
===================================================================
--- org/apache/neethi/Policy.java (revision 424964)
+++ org/apache/neethi/Policy.java (working copy)
@@ -23,131 +23,137 @@
public class Policy extends AbstractPolicyOperator {
- public PolicyComponent normalize(boolean deep) {
-
- All all = new All();
- ExactlyOne exactlyOne = new ExactlyOne();
+// public PolicyComponent normalize(boolean deep) {
+//
+// All all = new All();
+// ExactlyOne exactlyOne = new ExactlyOne();
+//
+// ArrayList exactlyOnes = new ArrayList();
+//
+// if (isEmpty()) {
+// Policy policy = new Policy();
+// policy.addPolicyComponent(exactlyOne);
+// exactlyOne.addPolicyComponent(all);
+// return policy;
+// }
+//
+// PolicyComponent component;
+//
+// for (Iterator iterator = getPolicyComponents().iterator(); iterator
+// .hasNext();) {
+// component = (PolicyComponent) iterator.next();
+// short type = component.getType();
+//
+// if (type == PolicyComponent.ASSERTION && deep) {
+// component = ((Assertion) component).normalize();
+// type = component.getType();
+// }
+//
+// if (type == PolicyComponent.POLICY) {
+// All wrapper = new All();
+// wrapper.addPolicyComponents(((Policy) component)
+// .getPolicyComponents());
+// component = wrapper.normalize(deep);
+// type = component.getType();
+//
+// } else if (type != PolicyComponent.ASSERTION) {
+// component = ((PolicyOperator) component).normalize(deep);
+// type = component.getType();
+// }
+//
+// if (type == PolicyComponent.EXACTLYONE) {
+//
+// if (((ExactlyOne) component).isEmpty()) {
+// Policy policy = new Policy();
+// ExactlyOne anExactlyOne = new ExactlyOne();
+//
+// policy.addPolicyComponent(anExactlyOne);
+// return policy;
+//
+// } else {
+// exactlyOnes.add(component);
+// }
+//
+// } else if (type == PolicyComponent.ALL) {
+// all
+// .addPolicyComponents(((All) component)
+// .getPolicyComponents());
+//
+// } else {
+// all.addPolicyComponent(component);
+// }
+// }
+//
+// // processing child ExactlyOne operators
+// if (exactlyOnes.size() > 1) {
+// exactlyOne.addPolicyComponents(crossProduct(exactlyOnes, 0,
false));
+//
+// } else if (exactlyOnes.size() == 1) {
+// ExactlyOne anExactlyOne = (ExactlyOne) exactlyOnes.get(0);
+//
exactlyOne.addPolicyComponents(anExactlyOne.getPolicyComponents());
+// }
+//
+// if (exactlyOne.isEmpty()) {
+// Policy policy = new Policy();
+// ExactlyOne anExactlyOne = new ExactlyOne();
+//
+// policy.addPolicyComponent(anExactlyOne);
+// anExactlyOne.addPolicyComponent(all);
+// return policy;
+//
+// } else if (all.isEmpty()) {
+// Policy policy = new Policy();
+// policy.addPolicyComponent(exactlyOne);
+//
+// return policy;
+//
+// } else {
+// Policy policy = new Policy();
+//
+// All anAll;
+//
+// for (Iterator iterator = exactlyOne.getPolicyComponents()
+// .iterator(); iterator.hasNext();) {
+// anAll = (All) iterator.next();
+// anAll.addPolicyComponents(all.getPolicyComponents());
+// }
+//
+// policy.addPolicyComponent(exactlyOne);
+// return policy;
+// }
+// }
- ArrayList exactlyOnes = new ArrayList();
+ public PolicyComponent normalize(boolean isDeep) {
+ Policy policy = new Policy();
+ policy.addPolicyComponent(super.normalize(isDeep));
+ return policy;
+ }
- if (isEmpty()) {
- Policy policy = new Policy();
- policy.addPolicyComponent(exactlyOne);
- exactlyOne.addPolicyComponent(all);
- return policy;
- }
+ public Policy merge(Policy policy) {
- PolicyComponent component;
-
- for (Iterator iterator = getPolicyComponents().iterator(); iterator
- .hasNext();) {
- component = (PolicyComponent) iterator.next();
- short type = component.getType();
-
- if (type == PolicyComponent.ASSERTION && deep) {
- component = ((Assertion) component).normalize();
- type = component.getType();
- }
-
- if (type == PolicyComponent.POLICY) {
- All wrapper = new All();
- wrapper.addPolicyComponents(((Policy) component)
- .getPolicyComponents());
- component = wrapper.normalize(deep);
- type = component.getType();
-
- } else if (type != PolicyComponent.ASSERTION) {
- component = ((PolicyOperator) component).normalize(deep);
- type = component.getType();
- }
-
- if (type == PolicyComponent.EXACTLYONE) {
-
- if (((ExactlyOne) component).isEmpty()) {
- Policy policy = new Policy();
- ExactlyOne anExactlyOne = new ExactlyOne();
-
- policy.addPolicyComponent(anExactlyOne);
- return policy;
-
- } else {
- exactlyOnes.add(component);
- }
-
- } else if (type == PolicyComponent.ALL) {
- all
- .addPolicyComponents(((All) component)
- .getPolicyComponents());
-
- } else {
- all.addPolicyComponent(component);
- }
- }
-
- // processing child ExactlyOne operators
- if (exactlyOnes.size() > 1) {
- exactlyOne.addPolicyComponents(crossProduct(exactlyOnes, 0,
false));
-
- } else if (exactlyOnes.size() == 1) {
- ExactlyOne anExactlyOne = (ExactlyOne) exactlyOnes.get(0);
- exactlyOne.addPolicyComponents(anExactlyOne.getPolicyComponents());
- }
-
- if (exactlyOne.isEmpty()) {
- Policy policy = new Policy();
- ExactlyOne anExactlyOne = new ExactlyOne();
-
- policy.addPolicyComponent(anExactlyOne);
- anExactlyOne.addPolicyComponent(all);
- return policy;
-
- } else if (all.isEmpty()) {
- Policy policy = new Policy();
- policy.addPolicyComponent(exactlyOne);
-
- return policy;
-
- } else {
- Policy policy = new Policy();
-
- All anAll;
-
- for (Iterator iterator = exactlyOne.getPolicyComponents()
- .iterator(); iterator.hasNext();) {
- anAll = (All) iterator.next();
- anAll.addPolicyComponents(all.getPolicyComponents());
- }
-
- policy.addPolicyComponent(exactlyOne);
- return policy;
- }
- }
-
- public Policy merge(Policy policy) {
-
Policy result = new Policy();
ExactlyOne alternative = new ExactlyOne();
result.addPolicyComponent(alternative);
-
+
ArrayList alternatives = new ArrayList();
-
+
policy = (Policy) policy.normalize(false);
alternatives.add(policy.getFirstPolicyComponent());
-
+
policy = (Policy) normalize(false);
alternatives.add(policy.getFirstPolicyComponent());
-
+
alternative.addPolicyComponents(crossProduct(alternatives, 0, false));
-
+
return result;
}
-
+
public Policy intersect(Policy policy) {
-
-
+
+
throw new UnsupportedOperationException("still not implemented");
}
-
+
public void serialize(XMLStreamWriter writer) throws XMLStreamException {
String prefix = writer.getPrefix(NAMESPACE);
@@ -155,33 +161,33 @@
writer.writeStartElement(PREFIX, POLICY, NAMESPACE);
writer.writeNamespace(PREFIX, NAMESPACE);
writer.setPrefix(PREFIX, NAMESPACE);
-
+
} else {
writer.writeStartElement(NAMESPACE, POLICY);
}
-
+
PolicyComponent policyComponent;
-
+
for (Iterator iterator = getPolicyComponents().iterator();
iterator.hasNext();) {
policyComponent = (PolicyComponent) iterator.next();
policyComponent.serialize(writer);
}
-
+
writer.writeEndElement();
}
-
+
public final short getType() {
return PolicyComponent.POLICY;
}
-
+
public Iterator getAlternatives() {
return new PolicyIterator(this);
}
-
+
private class PolicyIterator implements Iterator {
Iterator alternatives = null;
-
+
public PolicyIterator(Policy policy) {
policy = (Policy) policy.normalize(false);
ExactlyOne exactlyOne = (ExactlyOne)
policy.getFirstPolicyComponent();
@@ -199,7 +205,7 @@
public void remove() {
throw new
UnsupportedOperationException("policyAlternative.remove() is not supported");
}
-
+
}
-
+
}
Index: org/apache/neethi/PolicyComponent.java
===================================================================
--- org/apache/neethi/PolicyComponent.java (revision 424964)
+++ org/apache/neethi/PolicyComponent.java (working copy)
@@ -20,7 +20,6 @@
/**
* This is an interface which any component of the frame must implement.
- *
*/
public interface PolicyComponent {
@@ -34,24 +33,25 @@
/**
* Serializes the PolicyComponent using an XMLStreamWriter.
- *
- * @param writer
- * the writer that the component should write itself
- * @throws XMLStreamException
- * if an errors in the process of serialization of the
- * PolicyComponent.
+ *
+ * @param writer the writer that the component should write itself
+ * @throws XMLStreamException if an errors in the process of serialization
of the
+ * PolicyComponent.
*/
public void serialize(XMLStreamWriter writer) throws XMLStreamException;
/**
* Returns a short value which uniquely identify the type of the
* PolicyComponent.
- *
+ *
* @return PolicyComponent.POLICY for Policy type PolicyComponent
* PolicyComponent.EXACTLYONE for ExactlyOne type PolicyComponent
* PolicyComponent.All for All type PolicyComponent
* PolicyComponent.ASSERTION for Assertion type PolicyComponent
- *
*/
public short getType();
+
+ public PolicyComponent normalize();
+
+ public PolicyComponent normalize(boolean isDeep);
}
Index: org/apache/neethi/Assertion.java
===================================================================
--- org/apache/neethi/Assertion.java (revision 424964)
+++ org/apache/neethi/Assertion.java (working copy)
@@ -24,7 +24,7 @@
public boolean isOptional();
- public PolicyComponent normalize();
+// public PolicyComponent normalize();
public void serialize(XMLStreamWriter writer);
Index: org/apache/neethi/All.java
===================================================================
--- org/apache/neethi/All.java (revision 424964)
+++ org/apache/neethi/All.java (working copy)
@@ -27,84 +27,84 @@
*/
public class All extends AbstractPolicyOperator {
- public PolicyComponent normalize(boolean deep) {
+// public PolicyComponent normalize(boolean deep) {
+//
+// All all = new All();
+// ExactlyOne exactlyOne = new ExactlyOne();
+//
+// ArrayList exactlyOnes = new ArrayList();
+//
+// if (isEmpty()) {
+// return all;
+// }
+//
+// PolicyComponent component;
+//
+// for (Iterator iterator = getPolicyComponents().iterator(); iterator
+// .hasNext();) {
+// component = (PolicyComponent) iterator.next();
+// short type = component.getType();
+//
+// if (type == PolicyComponent.ASSERTION && deep) {
+// component = ((Assertion) component).normalize();
+// type = component.getType();
+// }
+//
+// if (type == PolicyComponent.POLICY) {
+// All wrapper = new All();
+// wrapper.addPolicyComponents(((Policy) component)
+// .getPolicyComponents());
+// component = wrapper.normalize(deep);
+// type = component.getType();
+//
+// } else if (!(type == PolicyComponent.ASSERTION)) {
+// component = ((PolicyOperator) component).normalize(deep);
+// }
+//
+// if (type == PolicyComponent.EXACTLYONE) {
+//
+// if (((ExactlyOne) component).isEmpty()) {
+// ExactlyOne anExactlyOne = new ExactlyOne();
+// return anExactlyOne;
+//
+// } else {
+// exactlyOnes.add(component);
+// }
+//
+// } else if (type == PolicyComponent.ALL) {
+// all
+// .addPolicyComponents(((All) component)
+// .getPolicyComponents());
+//
+// } else {
+// all.addPolicyComponent(component);
+// }
+// }
+//
+// // processing child ExactlyOne operators
+// if (exactlyOnes.size() > 1) {
+// exactlyOne.addPolicyComponents(crossProduct(exactlyOnes, 0,
false));
+//
+// } else if (exactlyOnes.size() == 1) {
+// ExactlyOne anExactlyOne = (ExactlyOne) exactlyOnes.get(0);
+//
exactlyOne.addPolicyComponents(anExactlyOne.getPolicyComponents());
+// }
+//
+// if (exactlyOne.isEmpty()) {
+// return all;
+// } else if (all.isEmpty()) {
+// return exactlyOne;
+// } else {
+// All anAll;
+// for (Iterator iterator = exactlyOne.getPolicyComponents()
+// .iterator(); iterator.hasNext();) {
+// anAll = (All) iterator.next();
+// anAll.addPolicyComponents(all.getPolicyComponents());
+// }
+// return exactlyOne;
+// }
+// }
- All all = new All();
- ExactlyOne exactlyOne = new ExactlyOne();
-
- ArrayList exactlyOnes = new ArrayList();
-
- if (isEmpty()) {
- return all;
- }
-
- PolicyComponent component;
-
- for (Iterator iterator = getPolicyComponents().iterator(); iterator
- .hasNext();) {
- component = (PolicyComponent) iterator.next();
- short type = component.getType();
-
- if (type == PolicyComponent.ASSERTION && deep) {
- component = ((Assertion) component).normalize();
- type = component.getType();
- }
-
- if (type == PolicyComponent.POLICY) {
- All wrapper = new All();
- wrapper.addPolicyComponents(((Policy) component)
- .getPolicyComponents());
- component = wrapper.normalize(deep);
- type = component.getType();
-
- } else if (!(type == PolicyComponent.ASSERTION)) {
- component = ((PolicyOperator) component).normalize(deep);
- }
-
- if (type == PolicyComponent.EXACTLYONE) {
-
- if (((ExactlyOne) component).isEmpty()) {
- ExactlyOne anExactlyOne = new ExactlyOne();
- return anExactlyOne;
-
- } else {
- exactlyOnes.add(component);
- }
-
- } else if (type == PolicyComponent.ALL) {
- all
- .addPolicyComponents(((All) component)
- .getPolicyComponents());
-
- } else {
- all.addPolicyComponent(component);
- }
- }
-
- // processing child ExactlyOne operators
- if (exactlyOnes.size() > 1) {
- exactlyOne.addPolicyComponents(crossProduct(exactlyOnes, 0,
false));
-
- } else if (exactlyOnes.size() == 1) {
- ExactlyOne anExactlyOne = (ExactlyOne) exactlyOnes.get(0);
- exactlyOne.addPolicyComponents(anExactlyOne.getPolicyComponents());
- }
-
- if (exactlyOne.isEmpty()) {
- return all;
- } else if (all.isEmpty()) {
- return exactlyOne;
- } else {
- All anAll;
- for (Iterator iterator = exactlyOne.getPolicyComponents()
- .iterator(); iterator.hasNext();) {
- anAll = (All) iterator.next();
- anAll.addPolicyComponents(all.getPolicyComponents());
- }
- return exactlyOne;
- }
- }
-
public void serialize(XMLStreamWriter writer) throws XMLStreamException {
String prefix = writer.getPrefix(NAMESPACE);
Index: org/apache/neethi/XmlPrimtiveAssertion.java
===================================================================
--- org/apache/neethi/XmlPrimtiveAssertion.java (revision 424964)
+++ org/apache/neethi/XmlPrimtiveAssertion.java (working copy)
@@ -51,24 +51,35 @@
}
public PolicyComponent normalize() throws IllegalArgumentException {
- return normalize(null);
+ return normalize(false);
}
+ public PolicyComponent normalize(boolean isDeep) {
+ ExactlyOne exactlyOne = new ExactlyOne();
+ All all = new All();
+ exactlyOne.addPolicyComponent(all);
+ all.addPolicyComponent(this);
+ if (isOptional){
+ exactlyOne.addPolicyComponent(new All());
+ }
+ return exactlyOne;
+ }
+
public PolicyComponent normalize(PolicyRegistry registry) {
-
+
if (isOptional) {
Policy policy = new Policy();
ExactlyOne alternatives = new ExactlyOne();
-
+
All alternative1 = new All();
OMElement element1 = element.cloneOMElement();
element1.removeAttribute(element1.getAttribute(optionalAttri));
alternative1.addPolicyComponent(new
XmlPrimtiveAssertion(element1));
alternatives.addPolicyComponent(alternative1);
-
+
All alternative2 = new All();
alternatives.addPolicyComponent(alternative2);
-
+
policy.addPolicyComponent(alternatives);
return policy;
}
Index: org/apache/neethi/ExactlyOne.java
===================================================================
--- org/apache/neethi/ExactlyOne.java (revision 424964)
+++ org/apache/neethi/ExactlyOne.java (working copy)
@@ -22,49 +22,49 @@
public class ExactlyOne extends AbstractPolicyOperator {
- public PolicyComponent normalize(boolean deep) {
- ExactlyOne exactlyOne = new ExactlyOne();
-
- if (isEmpty()) {
- return exactlyOne;
- }
-
- for (Iterator iterator = getPolicyComponents().iterator();
iterator.hasNext();) {
- PolicyComponent component = (PolicyComponent) iterator.next();
- short type = component.getType();
-
- if (type == PolicyComponent.ASSERTION && deep) {
- component = ((Assertion) component).normalize();
- type = component.getType();
- }
-
- if (type == PolicyComponent.POLICY) {
- All wrapper = new All();
- wrapper.addPolicyComponents(((Policy)
component).getPolicyComponents());
-
- component = wrapper.normalize(deep);
- type = component.getType();
-
- } else if (type != PolicyComponent.ASSERTION) {
- component = ((PolicyOperator) component).normalize(deep);
- type = component.getType();
- }
-
- if (type == PolicyComponent.EXACTLYONE) {
- exactlyOne.addPolicyComponents(((ExactlyOne)
component).getPolicyComponents());
-
- } else if (type == PolicyComponent.ALL) {
- exactlyOne.addPolicyComponent(component);
-
- } else {
- All wrapper = new All();
- wrapper.addPolicyComponent(component);
- exactlyOne.addPolicyComponent(wrapper);
- }
- }
-
- return exactlyOne;
- }
+// public PolicyComponent normalize(boolean deep) {
+// ExactlyOne exactlyOne = new ExactlyOne();
+//
+// if (isEmpty()) {
+// return exactlyOne;
+// }
+//
+// for (Iterator iterator = getPolicyComponents().iterator();
iterator.hasNext();) {
+// PolicyComponent component = (PolicyComponent) iterator.next();
+// short type = component.getType();
+//
+// if (type == PolicyComponent.ASSERTION && deep) {
+// component = ((Assertion) component).normalize();
+// type = component.getType();
+// }
+//
+// if (type == PolicyComponent.POLICY) {
+// All wrapper = new All();
+// wrapper.addPolicyComponents(((Policy)
component).getPolicyComponents());
+//
+// component = wrapper.normalize(deep);
+// type = component.getType();
+//
+// } else if (type != PolicyComponent.ASSERTION) {
+// component = ((PolicyOperator) component).normalize(deep);
+// type = component.getType();
+// }
+//
+// if (type == PolicyComponent.EXACTLYONE) {
+// exactlyOne.addPolicyComponents(((ExactlyOne)
component).getPolicyComponents());
+//
+// } else if (type == PolicyComponent.ALL) {
+// exactlyOne.addPolicyComponent(component);
+//
+// } else {
+// All wrapper = new All();
+// wrapper.addPolicyComponent(component);
+// exactlyOne.addPolicyComponent(wrapper);
+// }
+// }
+//
+// return exactlyOne;
+// }
public void serialize(XMLStreamWriter writer) throws XMLStreamException {
String prefix = writer.getPrefix(NAMESPACE);
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
