Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/attr
In directory sc8-pr-cvs1:/tmp/cvs-serv11479/com/sun/xacml/attr
Modified Files:
AttributeSelector.java
Log Message:
added support for enforcing XPathVersion and updated SelectorModule to
correctly handle nodes of different types
Index: AttributeSelector.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/attr/AttributeSelector.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** AttributeSelector.java 25 Aug 2003 16:53:10 -0000 1.4
--- AttributeSelector.java 29 Aug 2003 18:58:33 -0000 1.5
***************
*** 60,66 ****
/**
! * Supports the standard selector functionality in XACML. This class uses
! * XPath to search for a value or a set of values in the request document.
! * It does not search outside the request document for attribute values.
*
* @author Seth Proctor
--- 60,69 ----
/**
! * Supports the standard selector functionality in XACML, which uses XPath
! * expressions to resolve values from the Request or elsewhere. Unlike
! * the designator class, which does the Request search and then passes off
! * control to the <code>AttributeFinder</code>, all selector queries are
! * done by <code>AttributeFinderModule</code>s so that it's easy to plugin
! * different XPath implementations.
*
* @author Seth Proctor
***************
*** 78,81 ****
--- 81,87 ----
private boolean mustBePresent;
+ // the xpath version we've been told to use
+ private String xpathVersion;
+
/**
* Creates a new <code>AttributeSelector</code>.
***************
*** 85,102 ****
* @param contextPath the XPath to query
* @param mustBePresent must resolution find a match
*/
public AttributeSelector(URI type, String contextPath,
! boolean mustBePresent) {
this.type = type;
this.contextPath = contextPath;
this.mustBePresent = mustBePresent;
}
/**
* Creates a new <code>AttributeSelector</code> based on the DOM root
! * of the XML type.
*
* @param root the root of the DOM tree for the XML AttributeSelectorType
* XML type
*
* @return an <code>AttributeSelector</code>
--- 91,119 ----
* @param contextPath the XPath to query
* @param mustBePresent must resolution find a match
+ * @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,
! boolean mustBePresent, String xpathVersion) {
this.type = type;
this.contextPath = contextPath;
this.mustBePresent = mustBePresent;
+ this.xpathVersion = 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 xpathVersion the XPath version to use, or null if this is
+ * unspecified (ie, not supplied in the defaults
+ * section of the policy)
*
* @return an <code>AttributeSelector</code>
***************
*** 104,108 ****
* @throws ParsingException if the AttributeSelectorType was invalid
*/
! public static AttributeSelector getInstance(Node root)
throws ParsingException
{
--- 121,125 ----
* @throws ParsingException if the AttributeSelectorType was invalid
*/
! public static AttributeSelector getInstance(Node root, String xpathVersion)
throws ParsingException
{
***************
*** 111,114 ****
--- 128,136 ----
boolean mustBePresent = false;
+ // make sure we were given an xpath version
+ if (xpathVersion == null)
+ throw new ParsingException("An XPathVersion is required for "+
+ "any policies that use selectors");
+
NamedNodeMap attrs = root.getAttributes();
***************
*** 143,147 ****
}
! return new AttributeSelector(type, contextPath, mustBePresent);
}
--- 165,170 ----
}
! return new AttributeSelector(type, contextPath, mustBePresent,
! xpathVersion);
}
***************
*** 186,189 ****
--- 209,223 ----
/**
+ * Returns the XPath version this selector is supposed to use. This is
+ * typically provided by the defaults section of the policy containing
+ * this selector.
+ *
+ * @return the XPath version
+ */
+ public String getXPathVersion() {
+ return xpathVersion;
+ }
+
+ /**
* Invokes the <code>AttributeFinder</code> used by the given
* <code>EvaluationCtx</code> to try to resolve an attribute value. If
***************
*** 211,215 ****
// call the finder
EvaluationResult result = finder.findAttribute(contextPath, type,
! context);
// see if we got anything
--- 245,249 ----
// call the finder
EvaluationResult result = finder.findAttribute(contextPath, type,
! context, xpathVersion);
// see if we got anything
|