Author: sanka
Date: Thu Mar 2 21:49:54 2006
New Revision: 382674
URL: http://svn.apache.org/viewcvs?rev=382674&view=rev
Log:
adding more javadoc comments
Modified:
webservices/commons/modules/policy/src/org/apache/ws/policy/AbstractAssertion.java
webservices/commons/modules/policy/src/org/apache/ws/policy/AndCompositeAssertion.java
webservices/commons/modules/policy/src/org/apache/ws/policy/Assertion.java
webservices/commons/modules/policy/src/org/apache/ws/policy/Policy.java
webservices/commons/modules/policy/src/org/apache/ws/policy/PolicyConstants.java
webservices/commons/modules/policy/src/org/apache/ws/policy/PolicyReference.java
webservices/commons/modules/policy/src/org/apache/ws/policy/util/PolicyFactory.java
Modified:
webservices/commons/modules/policy/src/org/apache/ws/policy/AbstractAssertion.java
URL:
http://svn.apache.org/viewcvs/webservices/commons/modules/policy/src/org/apache/ws/policy/AbstractAssertion.java?rev=382674&r1=382673&r2=382674&view=diff
==============================================================================
---
webservices/commons/modules/policy/src/org/apache/ws/policy/AbstractAssertion.java
(original)
+++
webservices/commons/modules/policy/src/org/apache/ws/policy/AbstractAssertion.java
Thu Mar 2 21:49:54 2006
@@ -121,7 +121,7 @@
}
/**
- * Adds a terms to this assertion.
+ * Adds an assertion as a term of this assertion.
*
* @param assertion the term to add
*/
@@ -130,7 +130,7 @@
}
/**
- * Adds a list of terms to this assertion.
+ * Adds a list of assertions as terms of this assertion.
*
* @param assertions list of terms to add
*/
Modified:
webservices/commons/modules/policy/src/org/apache/ws/policy/AndCompositeAssertion.java
URL:
http://svn.apache.org/viewcvs/webservices/commons/modules/policy/src/org/apache/ws/policy/AndCompositeAssertion.java?rev=382674&r1=382673&r2=382674&view=diff
==============================================================================
---
webservices/commons/modules/policy/src/org/apache/ws/policy/AndCompositeAssertion.java
(original)
+++
webservices/commons/modules/policy/src/org/apache/ws/policy/AndCompositeAssertion.java
Thu Mar 2 21:49:54 2006
@@ -26,8 +26,6 @@
import org.apache.commons.logging.LogFactory;
import org.apache.ws.policy.util.PolicyRegistry;
-import sun.awt.print.resources.printcontrol;
-
/**
* AndCompositeAssertion represents either policy or a single policy
* alternative. It requires that all its terms are satisfied.
@@ -78,111 +76,113 @@
short type = target.getType();
switch (type) {
-
- case Assertion.COMPOSITE_POLICY_TYPE: {
- Policy nPOLICY = new Policy();
- nPOLICY
- .addTerm(normalizedMe
-
.intersect((XorCompositeAssertion) target
-
.getTerms().get(0)));
- return nPOLICY;
- }
-
- case Assertion.COMPOSITE_XOR_TYPE: {
- XorCompositeAssertion nXOR = new
XorCompositeAssertion();
-
- for (Iterator iterator =
target.getTerms().iterator(); iterator
- .hasNext();) {
- Assertion asser = normalizedMe
-
.intersect((AndCompositeAssertion) iterator.next());
-
- //
Assertion asser = ((AndCompositeAssertion)
- //
iterator.next()).intersect(normalizedMe);
-
- if (Assertion.COMPOSITE_AND_TYPE ==
asser.getType()) {
- nXOR.addTerm(asser);
- }
- }
- return nXOR;
- }
-
- case Assertion.COMPOSITE_AND_TYPE: {
- List PRIMITIVES_A = ((normalizedMe.size() >
target.size()) ? normalizedMe
- .getTerms() :
target.getTerms());
- List PRIMTIVES_B = ((normalizedMe.size() >
target.size()) ? target.getTerms()
- : normalizedMe.getTerms());
-
- boolean isMatch = true;
- PrimitiveAssertion PRIMITIVE_A, PRIMTIVE_B =
null;
-// QName name_A, name_B;
-
- for (int i = 0; i < PRIMITIVES_A.size(); i++) {
- PRIMITIVE_A = (PrimitiveAssertion)
PRIMITIVES_A.get(i);
-// name_A = PRIMITIVE_A.getName();
-
- boolean flag = false;
-
- for (int j = 0; j < PRIMTIVES_B.size();
j++) {
- PRIMTIVE_B =
(PrimitiveAssertion) PRIMTIVES_B.get(j);
-// name_B = PRIMTIVE_B.getName();
-
- if
(PRIMITIVE_A.getName().equals(PRIMTIVE_B.getName())) {
- flag = true;
- break;
- }
-
-// if
(name_A.getNamespaceURI().equals(
-//
name_B.getNamespaceURI())) {
-// flag = true;
-// break;
-// }
- }
-
- if (!flag) {
- return new
XorCompositeAssertion();
- }
-
- Assertion a =
PRIMITIVE_A.intersect(PRIMTIVE_B) ;
-
- if (a instanceof XorCompositeAssertion)
{
- return new
XorCompositeAssertion();
- }
+
+ case Assertion.COMPOSITE_POLICY_TYPE: {
+ Policy nPOLICY = new Policy();
+ nPOLICY
+ .addTerm(normalizedMe
+
.intersect((XorCompositeAssertion) target
+
.getTerms().get(0)));
+ return nPOLICY;
+ }
+
+ case Assertion.COMPOSITE_XOR_TYPE: {
+ XorCompositeAssertion nXOR = new
XorCompositeAssertion();
+
+ for (Iterator iterator = target.getTerms().iterator();
iterator
+ .hasNext();) {
+ Assertion asser = normalizedMe
+
.intersect((AndCompositeAssertion) iterator.next());
+
+ //
Assertion asser = ((AndCompositeAssertion)
+ // iterator.next()).intersect(normalizedMe);
+
+ if (Assertion.COMPOSITE_AND_TYPE ==
asser.getType()) {
+ nXOR.addTerm(asser);
}
- AndCompositeAssertion result = new
AndCompositeAssertion();
- result.addTerms(PRIMITIVES_A);
- result.addTerms(PRIMTIVES_B);
- return result;
}
-
- case Assertion.PRIMITIVE_TYPE: {
- QName name = ((PrimitiveAssertion)
target).getName();
- boolean isMatch = false;
-
- QName targetName;
- for (Iterator iterator =
normalizedMe.getTerms().iterator(); iterator
- .hasNext();) {
- targetName = ((PrimitiveAssertion)
iterator.next()).getName();
-
- if
(name.getNamespaceURI().equals(targetName.getNamespaceURI())) {
- isMatch = true;
+ return nXOR;
+ }
+
+ case Assertion.COMPOSITE_AND_TYPE: {
+ List PRIMITIVES_A = ((normalizedMe.size() >
target.size()) ? normalizedMe
+ .getTerms()
+ : target.getTerms());
+ List PRIMTIVES_B = ((normalizedMe.size() >
target.size()) ? target
+ .getTerms() : normalizedMe.getTerms());
+
+ boolean isMatch = true;
+ PrimitiveAssertion PRIMITIVE_A, PRIMTIVE_B = null;
+ // QName name_A, name_B;
+
+ for (int i = 0; i < PRIMITIVES_A.size(); i++) {
+ PRIMITIVE_A = (PrimitiveAssertion)
PRIMITIVES_A.get(i);
+ // name_A
= PRIMITIVE_A.getName();
+
+ boolean flag = false;
+
+ for (int j = 0; j < PRIMTIVES_B.size(); j++) {
+ PRIMTIVE_B = (PrimitiveAssertion)
PRIMTIVES_B.get(j);
+ //
name_B = PRIMTIVE_B.getName();
+
+ if
(PRIMITIVE_A.getName().equals(PRIMTIVE_B.getName())) {
+ flag = true;
break;
}
+
+ //
if (name_A.getNamespaceURI().equals(
+ //
name_B.getNamespaceURI())) {
+ //
flag = true;
+ //
break;
+ //
}
}
-
- if (isMatch) {
- AndCompositeAssertion nAND = new
AndCompositeAssertion();
- nAND.addTerms(normalizedMe.getTerms());
- nAND.addTerm(target);
- return nAND;
+
+ if (!flag) {
+ return new XorCompositeAssertion();
+ }
+
+ Assertion a = PRIMITIVE_A.intersect(PRIMTIVE_B);
+
+ if (a instanceof XorCompositeAssertion) {
+ return new XorCompositeAssertion();
+ }
+ }
+ AndCompositeAssertion result = new
AndCompositeAssertion();
+ result.addTerms(PRIMITIVES_A);
+ result.addTerms(PRIMTIVES_B);
+ return result;
+ }
+
+ case Assertion.PRIMITIVE_TYPE: {
+ QName name = ((PrimitiveAssertion) target).getName();
+ boolean isMatch = false;
+
+ QName targetName;
+ for (Iterator iterator =
normalizedMe.getTerms().iterator(); iterator
+ .hasNext();) {
+ targetName = ((PrimitiveAssertion)
iterator.next()).getName();
+
+ if
(name.getNamespaceURI().equals(targetName.getNamespaceURI())) {
+ isMatch = true;
+ break;
}
-
- return new XorCompositeAssertion();
}
-
- default: {
- throw new IllegalArgumentException("intersect
is not defined for " + target.getClass().getName() + "type assertions");
+
+ if (isMatch) {
+ AndCompositeAssertion nAND = new
AndCompositeAssertion();
+ nAND.addTerms(normalizedMe.getTerms());
+ nAND.addTerm(target);
+ return nAND;
}
+ return new XorCompositeAssertion();
+ }
+
+ default: {
+ throw new IllegalArgumentException("intersect is not
defined for "
+ + target.getClass().getName() + "type
assertions");
+ }
+
}
//
@@ -206,69 +206,69 @@
// target = (CompositeAssertion)
((target.isNormalized()) ? target
// : target.normalize(reg));
-// if (target instanceof Policy) {
-// XorCompositeAssertion alters = (XorCompositeAssertion)
target
-// .getTerms().get(0);
-// return normalizedMe.intersect(alters);
-//
-// } else if (target instanceof XorCompositeAssertion) {
-// XorCompositeAssertion result = new
XorCompositeAssertion();
-// Iterator iterator = target.getTerms().iterator();
-//
-// while (iterator.hasNext()) {
-// AndCompositeAssertion andTerm =
(AndCompositeAssertion) iterator
-// .next();
-// Assertion value =
normalizedMe.intersect(andTerm);
-// if (value instanceof AndCompositeAssertion) {
-// result.addTerm(value);
-// }
-// }
-// return result;
-// }
-//
-// if (normalizedMe.isEmpty()) {
-// return target;
-// }
-// if (target.isEmpty()) {
-// return normalizedMe;
-// }
-//
-// List primTermsA = ((size() > target.size()) ?
normalizedMe.getTerms()
-// : target.getTerms());
-// List primTermsB = ((size() > target.size()) ? target.getTerms()
-// : normalizedMe.getTerms());
-//
-// boolean isMatch = true;
-// PrimitiveAssertion primTermA, primTermB;
-// QName qnameA, qnameB;
-//
-// for (int i = 0; i < primTermsA.size(); i++) {
-// primTermA = (PrimitiveAssertion) primTermsA.get(i);
-// qnameA = primTermA.getName();
-// boolean flag = false;
-//
-// for (int j = 0; j < primTermsB.size(); j++) {
-// primTermB = (PrimitiveAssertion)
primTermsB.get(j);
-// qnameB = primTermB.getName();
-// if (qnameA.equals(qnameB)) {
-// flag = true;
-// break;
-// }
-// }
-// if (!flag) {
-// isMatch = false;
-// break;
-// }
-// }
-//
-// if (isMatch) { // vocabulary matches
-// AndCompositeAssertion result = new
AndCompositeAssertion();
-// result.addTerms(primTermsA);
-// result.addTerms(primTermsB);
-// return result;
-// }
-//
-// return new XorCompositeAssertion(); // no behaviour is admisible
+ // if (target instanceof Policy) {
+ // XorCompositeAssertion alters =
(XorCompositeAssertion) target
+ // .getTerms().get(0);
+ // return normalizedMe.intersect(alters);
+ //
+ // } else if (target instanceof
XorCompositeAssertion) {
+ // XorCompositeAssertion result = new
XorCompositeAssertion();
+ // Iterator iterator =
target.getTerms().iterator();
+ //
+ // while (iterator.hasNext()) {
+ // AndCompositeAssertion andTerm =
(AndCompositeAssertion) iterator
+ // .next();
+ // Assertion value =
normalizedMe.intersect(andTerm);
+ // if (value instanceof
AndCompositeAssertion) {
+ // result.addTerm(value);
+ // }
+ // }
+ // return result;
+ // }
+ //
+ // if (normalizedMe.isEmpty()) {
+ // return target;
+ // }
+ // if (target.isEmpty()) {
+ // return normalizedMe;
+ // }
+ //
+ // List primTermsA = ((size() > target.size()) ?
normalizedMe.getTerms()
+ // : target.getTerms());
+ // List primTermsB = ((size() > target.size()) ?
target.getTerms()
+ // : normalizedMe.getTerms());
+ //
+ // boolean isMatch = true;
+ // PrimitiveAssertion primTermA, primTermB;
+ // QName qnameA, qnameB;
+ //
+ // for (int i = 0; i < primTermsA.size(); i++) {
+ // primTermA = (PrimitiveAssertion)
primTermsA.get(i);
+ // qnameA = primTermA.getName();
+ // boolean flag = false;
+ //
+ // for (int j = 0; j < primTermsB.size();
j++) {
+ // primTermB =
(PrimitiveAssertion) primTermsB.get(j);
+ // qnameB = primTermB.getName();
+ // if (qnameA.equals(qnameB)) {
+ // flag = true;
+ // break;
+ // }
+ // }
+ // if (!flag) {
+ // isMatch = false;
+ // break;
+ // }
+ // }
+ //
+ // if (isMatch) { // vocabulary matches
+ // AndCompositeAssertion result = new
AndCompositeAssertion();
+ // result.addTerms(primTermsA);
+ // result.addTerms(primTermsB);
+ // return result;
+ // }
+ //
+ // return new XorCompositeAssertion(); // no
behaviour is admisible
}
/**
Modified:
webservices/commons/modules/policy/src/org/apache/ws/policy/Assertion.java
URL:
http://svn.apache.org/viewcvs/webservices/commons/modules/policy/src/org/apache/ws/policy/Assertion.java?rev=382674&r1=382673&r2=382674&view=diff
==============================================================================
--- webservices/commons/modules/policy/src/org/apache/ws/policy/Assertion.java
(original)
+++ webservices/commons/modules/policy/src/org/apache/ws/policy/Assertion.java
Thu Mar 2 21:49:54 2006
@@ -20,160 +20,194 @@
import org.apache.ws.policy.util.PolicyRegistry;
/**
- * Assertion is an interface which all constructs of policy must implements. It
- * defines few policy operations that all policy constructs must support.
+ * Assertion is an interface which all constructs of policy must implement. It
+ * defines three policy operations that all policy constructs must support.
*/
public interface Assertion {
- /** Defines the short value for Primitive Assertions */
- public static final short PRIMITIVE_TYPE = 0x1;
-
- /** Defines the short value for ANDCompositeAssertion */
- public static final short COMPOSITE_AND_TYPE = 0x2;
-
- /** Defines the short value for XORCompositeAssertion */
- public static final short COMPOSITE_XOR_TYPE = 0x3;
-
- /** Defines the short value for Policy Assertion */
- public static final short COMPOSITE_POLICY_TYPE = 0x4;
-
- /** Defines the short value for PolicyReferece Assertion */
- public static final short POLIY_REFERCE_TYPE = 0x5;
-
- /**
- *
- * @return
- */
- public Assertion normalize() throws UnsupportedOperationException;
-
- /**
- *
- * @param reg
- * @return
- * @throws UnsupportedOperationException
- */
- public Assertion normalize(PolicyRegistry reg)
- throws UnsupportedOperationException;
-
- /**
- * Returns an assertion which is the equivalent of intersect of
- * self and argument. The rules to construct the equivalent assertion are
- * specified in WS Policy 1.0 specification.
- *
- * @param assertion the assertion to intersect with
- * @return the equivalent of intersect of self and the argument
- */
- public Assertion intersect(Assertion assertion)
- throws UnsupportedOperationException;
-
- /**
- * Returns an assertion which is equivalent of intersect of self and
- * argument. Here the external policy are resolved via a policy registry
- * that is supplied as an argument.
- *
- * @param assertion the assertion to intersect with
- * @param cache the policy registry which is used to resolve external
- * policy references
- * @return the equivalent of intersection of self and argument
- * @throws UnsupportedOperationException if the operation is not meaningful
- */
- public Assertion intersect(Assertion assertion, PolicyRegistry reg)
- throws UnsupportedOperationException;
-
- /**
- * Returns the equivalent of merge of self and argument. The rules to
- * construct the equivalent of merge are defined in WS Policy specification
- * 1.0
- *
- * @param assertion the argument to merge with
- * @return the equivalent of the merge of self and argument
- */
- public Assertion merge(Assertion assertion)
- throws UnsupportedOperationException;
-
- /**
- * Returns the equivalent of merge of self and argument. The rules to
- * construct argument are specified in WS Policy specification 1.0 Here the
- * external policy references are resolved via a policy registry that is
- * supplied as an argument
- *
- * @param assertion the assertion to merge with
- * @param reg the policy registry that should be used to resolve external
- * policy references
- * @return the equivalent of merge of self and argument
- * @throws UnsupportedOperationException if the merge is not meaningful
- */
- public Assertion merge(Assertion assertion, PolicyRegistry reg) throws
UnsupportedOperationException;
-
- /**
- *
- * @return
- */
- public boolean isNormalized();
-
- /**
- *
- * @param flag
- */
- public void setNormalized(boolean flag);
-
- /**
- * Returns ture if the assertion has a parent
- *
- * @return true if a parent exists , false otherwise
- */
- public boolean hasParent();
-
- /**
- * Returns the parent of self or null if a parent non-exists
- *
- * @return the parent of self
- */
- public Assertion getParent();
-
- /**
- * Set the parent to argument
- * @param parent the parent that should be parent of self
- */
- public void setParent(Assertion parent);
-
- /**
- *
- * @param assertion
- */
- public void addTerm(Assertion assertion);
-
- /**
- *
- * @param assertions
- */
- public void addTerms(List assertions);
-
- /**
- *
- * @return
- */
- public List getTerms();
-
- /**
- *
- * @return
- */
- public boolean isEmpty();
-
- /**
- *
- * @param assertion
- * @return
- */
- public boolean remove(Assertion assertion) ;
-
- /**
- *
- * @return
- */
- public int size();
-
- public short getType();
-
-}
+ /** Defines the short value for Primitive Assertions */
+ public static final short PRIMITIVE_TYPE = 0x1;
+
+ /** Defines the short value for ANDCompositeAssertion */
+ public static final short COMPOSITE_AND_TYPE = 0x2;
+
+ /** Defines the short value for XORCompositeAssertion */
+ public static final short COMPOSITE_XOR_TYPE = 0x3;
+
+ /** Defines the short value for Policy Assertion */
+ public static final short COMPOSITE_POLICY_TYPE = 0x4;
+
+ /** Defines the short value for PolicyReferece Assertion */
+ public static final short POLIY_REFERCE_TYPE = 0x5;
+
+ /**
+ * Returns a new assertion which is the normalized form of this
assertion.
+ *
+ * @return an assertion which is normalized form of this.
+ */
+ public Assertion normalize() throws UnsupportedOperationException;
+
+ /**
+ * Returns a new assertion which is the normalized form of this
assertion.
+ *
+ * @param reg
+ * the registry which is used to resolve any policy
references in
+ * the process of normalization.
+ * @return
+ * @throws UnsupportedOperationException
+ * if an assertion does not support this operation.
+ */
+ public Assertion normalize(PolicyRegistry reg)
+ throws UnsupportedOperationException;
+
+ /**
+ * Returns an assertion which is the equivalent of intersect of self and
+ * argument. The rules to construct the equivalent assertion are
specified
+ * in WS Policy 1.0 specification.
+ *
+ * @param assertion
+ * the assertion to intersect with
+ * @return the equivalent of intersect of self and the argument
+ */
+ public Assertion intersect(Assertion assertion)
+ throws UnsupportedOperationException;
+
+ /**
+ * Returns an assertion which is equivalent of intersect of self and
+ * argument. Here the external policy are resolved via a policy registry
+ * that is supplied as an argument.
+ *
+ * @param assertion
+ * the assertion to intersect with
+ * @param cache
+ * the policy registry which is used to resolve external
policy
+ * references
+ * @return the equivalent of intersection of self and argument
+ * @throws UnsupportedOperationException
+ * if the operation is not meaningful
+ */
+ public Assertion intersect(Assertion assertion, PolicyRegistry reg)
+ throws UnsupportedOperationException;
+
+ /**
+ * Returns the equivalent of merge of self and argument. The rules to
+ * construct the equivalent of merge are defined in WS Policy
specification
+ * 1.0
+ *
+ * @param assertion
+ * the argument to merge with
+ * @return the equivalent of the merge of self and argument
+ */
+ public Assertion merge(Assertion assertion)
+ throws UnsupportedOperationException;
+
+ /**
+ * Returns the equivalent of merge of self and argument. The rules to
+ * construct argument are specified in WS Policy specification 1.0 Here
the
+ * external policy references are resolved via a policy registry that is
+ * supplied as an argument
+ *
+ * @param assertion
+ * the assertion to merge with
+ * @param reg
+ * the policy registry that should be used to resolve
external
+ * policy references
+ * @return the equivalent of merge of self and argument
+ * @throws UnsupportedOperationException
+ * if the merge is not meaningful
+ */
+ public Assertion merge(Assertion assertion, PolicyRegistry reg)
+ throws UnsupportedOperationException;
+
+ /**
+ * Returns true if the assertion is in normalized form.
+ *
+ * @return true if the assertion is in normalized form.
+ */
+ public boolean isNormalized();
+
+ /**
+ * Marks this assertion as in normalized form.
+ * @param flag
+ */
+ public void setNormalized(boolean flag);
+
+ /**
+ * Returns ture if the assertion has a parent
+ *
+ * @return true if a parent exists , false otherwise
+ */
+ public boolean hasParent();
+
+ /**
+ * Returns the parent of self or null if a parent non-exists
+ *
+ * @return the parent of self
+ */
+ public Assertion getParent();
+
+ /**
+ * Sets the parent to argument
+ *
+ * @param parent
+ * the parent that should be parent of self
+ */
+ public void setParent(Assertion parent);
+
+ /**
+ * Adds an assertion as a term of this assertion.
+ *
+ * @param assertion the assertion to add as a term
+ */
+ public void addTerm(Assertion assertion);
+
+ /**
+ * Adds a list of assertions as terms of this assertion.
+ *
+ * @param assertions the list of assertions to add as terms
+ */
+ public void addTerms(List assertions);
+
+ /**
+ * Returns the list of terms of this assertion.
+ *
+ * @return list of terms
+ */
+ public List getTerms();
+
+ /**
+ * Returns true if there are no terms in this assertion.
+ *
+ * @return true if there are no terms.
+ */
+ public boolean isEmpty();
+
+ /**
+ * Removes the specified assertion from the terms list.
+ *
+ * @param assertion the assertion to remove from the terms list.
+ * @return true if it is removed from the child list.
+ */
+ public boolean remove(Assertion assertion);
+
+ /**
+ * Returns the number of terms of this assertion.
+ *
+ * @return the no of terms of this assertion.
+ */
+ public int size();
+
+ /**
+ * Returns a short type which describes the type of the assertion.
+ *
+ * @return a short value of one of following values:
+ *
+ * PRIMITIVE_TYPE : if the assertion is a
PrimitiveAssertion
+ * COMPOSITE_AND_TYPE : if the assertion is a
AndCompositeAssertion
+ * COMPOSITE_XOR_TYPE : if the assertion is a
XorCompositeAssertion
+ * COMPOSITE_POLICY_TYPE : if the assertion is a
Policy
+ * POLICY_REFERENCE_TYPE : if the assertion is a
PolicyReferece
+ */
+ public short getType();
+
+}
\ No newline at end of file
Modified:
webservices/commons/modules/policy/src/org/apache/ws/policy/Policy.java
URL:
http://svn.apache.org/viewcvs/webservices/commons/modules/policy/src/org/apache/ws/policy/Policy.java?rev=382674&r1=382673&r2=382674&view=diff
==============================================================================
--- webservices/commons/modules/policy/src/org/apache/ws/policy/Policy.java
(original)
+++ webservices/commons/modules/policy/src/org/apache/ws/policy/Policy.java Thu
Mar 2 21:49:54 2006
@@ -20,54 +20,96 @@
import java.util.Iterator;
import java.util.List;
-import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.ws.policy.util.PolicyRegistry;
-import sun.java2d.loops.XORComposite;
-
/**
- * Policy is the access point for policy framework. It the object model that
- * represents a policy at runtime.
- *
+ * Policy class is the runtime representation of a policy. It provides a
+ * convenient model to store process any policy. Policy object requires that
all
+ * its terms are met.
*/
public class Policy extends AbstractAssertion implements CompositeAssertion {
private Log log = LogFactory.getLog(this.getClass().getName());
private String xmlBase = null;
+ /** Stores the Id of the policy */
private String id = null;
+ /**
+ * Creates a policy object
+ */
public Policy() {
}
-
+
+
+ /**
+ * Creates a policy object with the specified Id
+ *
+ * @param id a string as the id
+ */
public Policy(String id) {
this(null, id);
setNormalized(false);
}
+ /**
+ * Creates a policy object with the specified xml-base and id.
+ *
+ * @param xmlBase the xml-base
+ * @param id a string as the id
+ */
public Policy(String xmlBase, String id) {
this.xmlBase = xmlBase;
this.id = id;
setNormalized(false);
}
+ /**
+ * Set the xml-base of the policy object
+ *
+ * @param xmlBase the xml base of the policy object
+ */
public void setBase(String xmlBase) {
this.xmlBase = xmlBase;
}
+ /**
+ * Returns the xml-base of the policy object. Returns null if
+ * no xml-base is set.
+ *
+ * @return xml base of the policy object
+ */
public String getBase() {
return xmlBase;
}
+ /**
+ * Sets the id of the Policy object
+ *
+ * @param id
+ */
public void setId(String id) {
this.id = id;
}
+ /**
+ * Returns the Id of the Policy object. Returns null if no Id is set.
+ *
+ * @return the Id of the policy object.
+ */
public String getId() {
return id;
}
+ /**
+ * Returns a String which uniquely identify the policy object. It has
the format of
+ * {$xmlBase}#{$id}. If the xmlBase is null it will return #{$id} as
the URI String.
+ * If the Id is null, this will return.
+ *
+ * @return a String which uniquely identify the policy object.
+ */
public String getPolicyURI() {
if (id != null) {
if (xmlBase != null) {
@@ -232,52 +274,29 @@
}
case Assertion.COMPOSITE_XOR_TYPE: {
Policy nPOLICY = new Policy();
- nPOLICY.addTerm(((XorCompositeAssertion)
normalizedMe.getTerms().get(0)).intersect(target));
+ nPOLICY.addTerm(((XorCompositeAssertion)
normalizedMe.getTerms()
+ .get(0)).intersect(target));
return nPOLICY;
}
case Assertion.COMPOSITE_AND_TYPE: {
Policy nPOLICY = new Policy();
- nPOLICY.addTerm(((XorCompositeAssertion)
normalizedMe.getTerms().get(0)).intersect(target));
+ nPOLICY.addTerm(((XorCompositeAssertion)
normalizedMe.getTerms()
+ .get(0)).intersect(target));
return nPOLICY;
}
case Assertion.PRIMITIVE_TYPE: {
Policy nPOLICY = new Policy();
- nPOLICY.addTerm(((XorCompositeAssertion)
normalizedMe.getTerms().get(0)).intersect(target));
+ nPOLICY.addTerm(((XorCompositeAssertion)
normalizedMe.getTerms()
+ .get(0)).intersect(target));
return nPOLICY;
}
-
+
default: {
- throw new IllegalArgumentException("intersect is not
defined for " + target.getClass().getName() +" type") ;
+ throw new IllegalArgumentException("intersect is not
defined for "
+ + target.getClass().getName() + "
type");
}
}
-
-// Policy result = new Policy(getBase(), getId());
-// Policy normalizedMe = (Policy) ((isNormalized()) ? this
-// : normalize(reg));
-//
-// XorCompositeAssertion alters = (XorCompositeAssertion)
normalizedMe
-// .getTerms().get(0);
-//
-// if (assertion instanceof PrimitiveAssertion) {
-// result.addTerm(alters.intersect(assertion, reg));
-// return result;
-//
-// } else {
-// Assertion target = (assertion.isNormalized()) ?
assertion
-// : assertion.normalize(reg);
-// ;
-//
-// if (target instanceof Policy) {
-// XorCompositeAssertion alters2 =
(XorCompositeAssertion) target
-// .getTerms().get(0);
-// result.addTerm(alters.intersect(alters2));
-// return result;
-// } else {
-// result.addTerm(alters.intersect(target));
-// return result;
-// }
-// }
}
public Assertion merge(Assertion assertion, PolicyRegistry reg) {
@@ -330,6 +349,9 @@
}
}
+ /**
+ * Returns a short value which indicates this is a Policy.
+ */
public final short getType() {
return Assertion.COMPOSITE_POLICY_TYPE;
}
Modified:
webservices/commons/modules/policy/src/org/apache/ws/policy/PolicyConstants.java
URL:
http://svn.apache.org/viewcvs/webservices/commons/modules/policy/src/org/apache/ws/policy/PolicyConstants.java?rev=382674&r1=382673&r2=382674&view=diff
==============================================================================
---
webservices/commons/modules/policy/src/org/apache/ws/policy/PolicyConstants.java
(original)
+++
webservices/commons/modules/policy/src/org/apache/ws/policy/PolicyConstants.java
Thu Mar 2 21:49:54 2006
@@ -16,37 +16,36 @@
*/
/**
- * WSPConstants interfaces defines some CONST VALUES that are used in the
+ * PolicyConstants interfaces defines some CONST VALUES that are used in the
* entier framework.
- *
*/
public interface PolicyConstants {
- /** */
+ /** Tag name of AndComposteAssertion */
public static final String AND_COMPOSITE_ASSERTION = "All";
- /** */
+ /** Tag name of XorCompositeAssertion */
public static final String XOR_COMPOSITE_ASSERTION = "ExactlyOne";
- /** */
+ /** Tag name of Policy */
public static final String WS_POLICY = "Policy";
- /** */
+ /** Prefix of WS-Policy namespace*/
public static final String WS_POLICY_PREFIX = "wsp";
- /** */
+ /** Prefix of WSU namespace*/
public static final String WSU_NAMESPACE_PREFIX = "wsu";
- /** */
+ /** Tag name of PolicyReference*/
public static final String WS_POLICY_REFERENCE = "PolicyReference";
- /** */
+ /** Namespace of WS-Policy */
public static final String WS_POLICY_NAMESPACE_URI =
"http://schemas.xmlsoap.org/ws/2004/09/policy";
- /** */
+ /** Namespace of WSU*/
public static final String WSU_NAMESPACE_URI =
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
- /** */
+ /** XML namespace */
public static final String XML_NAMESPACE_URI =
"http://www.w3.org/XML/1998/namespace";
}
Modified:
webservices/commons/modules/policy/src/org/apache/ws/policy/PolicyReference.java
URL:
http://svn.apache.org/viewcvs/webservices/commons/modules/policy/src/org/apache/ws/policy/PolicyReference.java?rev=382674&r1=382673&r2=382674&view=diff
==============================================================================
---
webservices/commons/modules/policy/src/org/apache/ws/policy/PolicyReference.java
(original)
+++
webservices/commons/modules/policy/src/org/apache/ws/policy/PolicyReference.java
Thu Mar 2 21:49:54 2006
@@ -21,105 +21,127 @@
import org.apache.ws.policy.util.PolicyRegistry;
/**
- * PolicyReference class has implicit reference to a external policy. It acts
as
- * wrapper to external policies in the standard policy framework.
- *
+ * PolicyReference class has implicit reference to a external policy. It is
used
+ * as a way to include an extenal policy object within another policy object.
+ * These objects are replaced with the actual policies when a Policy object is
+ * being normalized.
+ *
+ * Sanka Samaranayake ([EMAIL PROTECTED])
*/
public class PolicyReference implements Assertion {
- private String PolicyURIString = null;
+ /** A string which uniquely identify the referring Policy object */
+ private String PolicyURIString = null;
- private Assertion parent = null;
+ private Assertion parent = null;
+
+ /**
+ * Constructs a PolicyReferece object which refers to the Policy which
is
+ * uniquely identified by policyURIString.
+ *
+ * @param policyURIString
+ */
+ public PolicyReference(String policyURIString) {
+ this.PolicyURIString = policyURIString;
+ }
+
+ /**
+ * Returns a string which uniquely identified the referring Policy. For
+ * instance the referring policy object p, p.getPolicyURI() should
return
+ * the same string
+ *
+ * @return a String which uniquely identifies the referring Policy
object.
+ */
+ public String getPolicyURIString() {
+ return PolicyURIString;
+ }
+
+ public Assertion normalize() {
+ throw new UnsupportedOperationException();
+ }
+
+ public Assertion normalize(PolicyRegistry reg) {
+ if (reg == null) {
+ throw new RuntimeException("Cannot resolve : "
+ + getPolicyURIString() + " ..
PolicyRegistry is null");
+ }
+ Policy targetPolicy = reg.lookup(getPolicyURIString());
+ if (targetPolicy == null) {
+ throw new RuntimeException("error : " +
getPolicyURIString()
+ + " doesn't resolve to any known
policy");
+ }
+
+ return targetPolicy.normalize(reg);
+ }
+
+ public Assertion intersect(Assertion assertion) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Assertion intersect(Assertion assertion, PolicyRegistry reg)
+ throws UnsupportedOperationException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Assertion merge(Assertion assertion, PolicyRegistry reg)
+ throws UnsupportedOperationException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Assertion merge(Assertion assertion) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean hasParent() {
+ return parent != null;
+ }
+
+ public Assertion getParent() {
+ return parent;
+ }
+
+ public void setParent(Assertion parent) {
+ this.parent = parent;
+ }
+
+ public boolean isNormalized() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setNormalized(boolean flag) {
+ throw new UnsupportedOperationException();
+ }
- public PolicyReference(String policyURIString) {
- this.PolicyURIString = policyURIString;
- }
-
- public String getPolicyURIString() {
- return PolicyURIString;
- }
-
- public Assertion normalize() {
- throw new UnsupportedOperationException();
- }
-
- public Assertion normalize(PolicyRegistry reg) {
- if (reg == null) {
- throw new RuntimeException("Cannot resolve : "
- + getPolicyURIString() + " .. PolicyRegistry is null");
- }
- Policy targetPolicy = reg.lookup(getPolicyURIString());
- if (targetPolicy == null) {
- throw new RuntimeException("error : " + getPolicyURIString()
- + " doesn't resolve to any known policy");
- }
-
- return targetPolicy.normalize(reg);
- }
-
- public Assertion intersect(Assertion assertion) {
- throw new UnsupportedOperationException();
- }
-
- public Assertion intersect(Assertion assertion, PolicyRegistry reg)
- throws UnsupportedOperationException {
- throw new UnsupportedOperationException();
- }
-
- public Assertion merge(Assertion assertion, PolicyRegistry reg)
- throws UnsupportedOperationException {
- throw new UnsupportedOperationException();
- }
-
- public Assertion merge(Assertion assertion) {
- throw new UnsupportedOperationException();
- }
-
- public boolean hasParent() {
- return parent != null;
- }
-
- public Assertion getParent() {
- return parent;
- }
-
- public void setParent(Assertion parent) {
- this.parent = parent;
- }
-
- public boolean isNormalized() {
- throw new UnsupportedOperationException();
- }
-
- public void setNormalized(boolean flag) {
- throw new UnsupportedOperationException();
- }
-
public void addTerm(Assertion assertion) {
throw new UnsupportedOperationException();
}
-
+
public void addTerms(List assertions) {
throw new UnsupportedOperationException();
}
-
+
public List getTerms() {
throw new UnsupportedOperationException();
}
-
+
public boolean isEmpty() {
throw new UnsupportedOperationException();
}
-
+
public boolean remove(Assertion assertion) {
throw new UnsupportedOperationException();
}
-
+
public int size() {
throw new UnsupportedOperationException();
}
-
+
+ /**
+ * Returns a short value which indicate this is a PolicyReference.
+ *
+ * @return a short value to indicate that this is a PolicyReference.
+ */
public final short getType() {
return Assertion.POLIY_REFERCE_TYPE;
}
-}
+}
\ No newline at end of file
Modified:
webservices/commons/modules/policy/src/org/apache/ws/policy/util/PolicyFactory.java
URL:
http://svn.apache.org/viewcvs/webservices/commons/modules/policy/src/org/apache/ws/policy/util/PolicyFactory.java?rev=382674&r1=382673&r2=382674&view=diff
==============================================================================
---
webservices/commons/modules/policy/src/org/apache/ws/policy/util/PolicyFactory.java
(original)
+++
webservices/commons/modules/policy/src/org/apache/ws/policy/util/PolicyFactory.java
Thu Mar 2 21:49:54 2006
@@ -17,6 +17,8 @@
package org.apache.ws.policy.util;
/**
+ * PolicyFactory is used to create PolicyReader / PolicyWriter objects of
different types.
+ *
* @author Sanka Samaranayake ([EMAIL PROTECTED])
*/
public class PolicyFactory {
@@ -25,7 +27,16 @@
public static final int DOM_POLICY_READER = 3;
-
+ /**
+ * Creates a specified type of PolicyReader object
+ *
+ * DOM_POLICY_READER : Uses DOM as its underlying mechanism to process XML.
+ *
+ * OM_POLICY_READER : Uses AXIOM as its underlying mechanism to process
XML.
+ *
+ * @param type of the PolicyReader to create
+ * @return an instance of a PolicyReader
+ */
public static PolicyReader getPolicyReader(int type) {
String name = null;
switch (type) {
@@ -49,6 +60,14 @@
}
}
+ /**
+ * Create a specified type of PolicyWriter object
+ *
+ * STAX_POLICY_WRITER: Uses StAX as its underlying mechanism to create XML
elements.
+ *
+ * @param type of the RolicyWriter to create
+ * @return an instance of PolicyWriter
+ */
public static PolicyWriter getPolicyWriter(int type) {
String name = null;
switch (type) {