Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/attr
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21866/com/sun/xacml/attr
Modified Files:
AttributeDesignator.java AttributeSelector.java
AttributeValue.java
Log Message:
substantial update to align 2.0 features (Target and Condition) and code
re-factoring to better handle Expression/Evaluatable, versions, Target, etc.
Index: AttributeDesignator.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/attr/AttributeDesignator.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** AttributeDesignator.java 7 Jan 2005 23:49:31 -0000 1.8
--- AttributeDesignator.java 5 Dec 2005 23:34:51 -0000 1.9
***************
*** 41,44 ****
--- 41,45 ----
import com.sun.xacml.MatchResult;
import com.sun.xacml.ParsingException;
+ import com.sun.xacml.PolicyMetaData;
import com.sun.xacml.TargetMatch;
***************
*** 184,188 ****
if (target == SUBJECT_TARGET)
subjectCategory = category;
! }
/**
--- 185,189 ----
if (target == SUBJECT_TARGET)
subjectCategory = category;
! }
/**
***************
*** 190,193 ****
--- 191,199 ----
* root of the XML data.
*
+ * @deprecated As of 2.0 you should avoid using this method and should
+ * instead use the version that takes a
+ * <code>PolicyMetaData</code> instance. This method will
+ * only work for XACML 1.x policies.
+ *
* @param root the DOM root of the AttributeDesignatorType XML type
* @param target the type of designator to create as specified in the
***************
*** 201,204 ****
--- 207,233 ----
throws ParsingException
{
+ return getInstance(root, target,
+ new PolicyMetaData(
+ PolicyMetaData.XACML_VERSION_1_0,
+ PolicyMetaData.XPATH_VERSION_UNSPECIFIED));
+ }
+
+ /**
+ * Creates a new <code>AttributeDesignator</code> based on the DOM
+ * root of the XML data.
+ *
+ * @param root the DOM root of the AttributeDesignatorType XML type
+ * @param target the type of designator to create as specified in the
+ * four member *_TARGET fields
+ * @param metaData the meta-data associated with the containing policy
+ *
+ * @return the designator
+ *
+ * @throws ParsingException if the AttributeDesignatorType was invalid
+ */
+ public static AttributeDesignator getInstance(Node root, int target,
+ PolicyMetaData metaData)
+ throws ParsingException
+ {
URI type = null;
URI id = null;
***************
*** 260,272 ****
/**
- * Returns true since this expression is evaluatable.
- *
- * @return true
- */
- public boolean isEvaluatable() {
- return true;
- }
-
- /**
* Returns the type of this designator as specified by the *_TARGET
* fields.
--- 289,292 ----
***************
*** 335,338 ****
--- 355,371 ----
* @return true
*/
+ public boolean returnsBag() {
+ return true;
+ }
+
+ /**
+ * Always returns true, since a designator always returns a bag of
+ * attribute values.
+ *
+ * @deprecated As of 2.0, you should use the <code>returnsBag</code>
+ * method from the super-interface <code>Expression</code>.
+ *
+ * @return true
+ */
public boolean evaluatesToBag() {
return true;
Index: AttributeValue.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/attr/AttributeValue.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** AttributeValue.java 7 Jan 2005 23:49:31 -0000 1.7
--- AttributeValue.java 5 Dec 2005 23:34:51 -0000 1.8
***************
*** 80,92 ****
/**
- * Returns true since this expression is evaluatable.
- *
- * @return true
- */
- public boolean isEvaluatable() {
- return true;
- }
-
- /**
* Returns the type of this attribute value. By default this always
* returns the type passed to the constructor.
--- 80,83 ----
***************
*** 100,103 ****
--- 91,107 ----
/**
* Returns whether or not this value is actually a bag of values. This
+ * is a required interface from <code>Expression</code>, but the
+ * more meaningful <code>isBag</code> method is used by
+ * <code>AttributeValue</code>s, so this method is declared as final
+ * and calls the <code>isBag</code> method for this value.
+ *
+ * @return true if this is a bag of values, false otherwise
+ */
+ public final boolean returnsBag() {
+ return isBag();
+ }
+
+ /**
+ * Returns whether or not this value is actually a bag of values. This
* is a required interface from <code>Evaluatable</code>, but the
* more meaningful <code>isBag</code> method is used by
***************
*** 105,108 ****
--- 109,116 ----
* and calls the <code>isBag</code> method for this value.
*
+ *
+ * @deprecated As of 2.0, you should use the <code>returnsBag</code>
+ * method from the super-interface <code>Expression</code>.
+ *
* @return true if this is a bag of values, false otherwise
*/
Index: AttributeSelector.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/attr/AttributeSelector.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** AttributeSelector.java 7 Jan 2005 23:49:31 -0000 1.11
--- AttributeSelector.java 5 Dec 2005 23:34:51 -0000 1.12
***************
*** 40,43 ****
--- 40,44 ----
import com.sun.xacml.Indenter;
import com.sun.xacml.ParsingException;
+ import com.sun.xacml.PolicyMetaData;
import com.sun.xacml.cond.Evaluatable;
***************
*** 102,106 ****
* @param xpathVersion the XPath version to use, which must be a valid
* XPath version string (the identifier for XPath 1.0
! * is provided in <code>AbstractPolicy</code>)
*/
public AttributeSelector(URI type, String contextPath,
--- 103,107 ----
* @param xpathVersion the XPath version to use, which must be a valid
* XPath version string (the identifier for XPath 1.0
! * is provided in <code>PolicyMetaData</code>)
*/
public AttributeSelector(URI type, String contextPath,
***************
*** 120,124 ****
* @param xpathVersion the XPath version to use, which must be a valid
* XPath version string (the identifier for XPath 1.0
! * is provided in <code>AbstractPolicy</code>)
*/
public AttributeSelector(URI type, String contextPath, Node policyRoot,
--- 121,125 ----
* @param xpathVersion the XPath version to use, which must be a valid
* XPath version string (the identifier for XPath 1.0
! * is provided in <code>PolicyMetaData</code>)
*/
public AttributeSelector(URI type, String contextPath, Node policyRoot,
***************
*** 138,141 ****
--- 139,147 ----
* an exception.
*
+ * @deprecated As of 2.0 you should avoid using this method and should
+ * instead use the version that takes a
+ * <code>PolicyMetaData</code> instance. This method will
+ * only work for XACML 1.x policies.
+ *
* @param root the root of the DOM tree for the XML AttributeSelectorType
* XML type
***************
*** 151,157 ****
--- 157,189 ----
throws ParsingException
{
+ return getInstance(root,
+ new PolicyMetaData(
+ PolicyMetaData.XACML_1_0_IDENTIFIER,
+ xpathVersion));
+ }
+
+ /**
+ * Creates a new <code>AttributeSelector</code> based on the DOM root
+ * of the XML type. Note that as of XACML 1.1 the XPathVersion element
+ * is required in any policy that uses a selector, so if the
+ * <code>xpathVersion</code> string is null, then this will throw
+ * an exception.
+ *
+ * @param root the root of the DOM tree for the XML AttributeSelectorType
+ * XML type
+ * @param metaData the meta-data associated with the containing policy
+ *
+ * @return an <code>AttributeSelector</code>
+ *
+ * @throws ParsingException if the AttributeSelectorType was invalid
+ */
+ public static AttributeSelector getInstance(Node root,
+ PolicyMetaData metaData)
+ throws ParsingException
+ {
URI type = null;
String contextPath = null;
boolean mustBePresent = false;
+ String xpathVersion = metaData.getXPathIdentifier();
// make sure we were given an xpath version
***************
*** 210,222 ****
/**
- * Returns true since this expression is evaluatable.
- *
- * @return true
- */
- public boolean isEvaluatable() {
- return true;
- }
-
- /**
* Returns the data type of the attribute values that this selector
* will resolve
--- 242,245 ----
***************
*** 253,256 ****
--- 276,292 ----
* @return true
*/
+ public boolean returnsBag() {
+ return true;
+ }
+
+ /**
+ * Always returns true, since a selector always returns a bag of
+ * attribute values.
+ *
+ * @deprecated As of 2.0, you should use the <code>returnsBag</code>
+ * method from the super-interface <code>Expression</code>.
+ *
+ * @return true
+ */
public boolean evaluatesToBag() {
return true;
|