Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/cond
In directory sc8-pr-cvs1:/tmp/cvs-serv11479/com/sun/xacml/cond
Modified Files:
Apply.java FunctionFactory.java FunctionProxy.java
Log Message:
added support for enforcing XPathVersion and updated SelectorModule to
correctly handle nodes of different types
Index: Apply.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/cond/Apply.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Apply.java 25 Aug 2003 16:53:10 -0000 1.4
--- Apply.java 29 Aug 2003 18:58:33 -0000 1.5
***************
*** 143,153 ****
*
* @param root the DOM root of a ConditionType XML type
*
* @throws ParsingException if this is not a valid ConditionType
*/
! public static Apply getConditionInstance(Node root)
throws ParsingException
{
! return getInstance(root, FunctionFactory.getConditionInstance(), true);
}
--- 143,157 ----
*
* @param root the DOM root of a ConditionType XML type
+ * @param xpathVersion the XPath version to use in any selectors or XPath
+ * functions, or null if this is unspecified (ie, not
+ * supplied in the defaults section of the policy)
*
* @throws ParsingException if this is not a valid ConditionType
*/
! public static Apply getConditionInstance(Node root, String xpathVersion)
throws ParsingException
{
! return getInstance(root, FunctionFactory.getConditionInstance(), true,
! xpathVersion);
}
***************
*** 156,166 ****
*
* @param root the DOM root of an ApplyType XML type
*
* @throws ParsingException if this is not a valid ApplyType
*/
! public static Apply getInstance(Node root)
throws ParsingException
{
! return getInstance(root, FunctionFactory.getGeneralInstance(), false);
}
--- 160,174 ----
*
* @param root the DOM root of an ApplyType XML type
+ * @param xpathVersion the XPath version to use in any selectors or XPath
+ * functions, or null if this is unspecified (ie, not
+ * supplied in the defaults section of the policy)
*
* @throws ParsingException if this is not a valid ApplyType
*/
! public static Apply getInstance(Node root, String xpathVersion)
throws ParsingException
{
! return getInstance(root, FunctionFactory.getGeneralInstance(), false,
! xpathVersion);
}
***************
*** 171,178 ****
*/
private static Apply getInstance(Node root, FunctionFactory factory,
! boolean isCondition)
throws ParsingException
{
! Function function = getFunction(root, factory);
Function bagFunction = null;
List evals = new ArrayList();
--- 179,186 ----
*/
private static Apply getInstance(Node root, FunctionFactory factory,
! boolean isCondition, String xpathVersion)
throws ParsingException
{
! Function function = getFunction(root, xpathVersion, factory);
Function bagFunction = null;
List evals = new ArrayList();
***************
*** 184,188 ****
if (name.equals("Apply")) {
! evals.add(Apply.getInstance(node));
} else if (name.equals("AttributeValue")) {
try {
--- 192,196 ----
if (name.equals("Apply")) {
! evals.add(Apply.getInstance(node, xpathVersion));
} else if (name.equals("AttributeValue")) {
try {
***************
*** 208,212 ****
AttributeDesignator.ENVIRONMENT_TARGET));
} else if (name.equals("AttributeSelector")) {
! evals.add(AttributeSelector.getInstance(node));
} else if (name.equals("Function")) {
// while the schema doesn't enforce this, it's illegal to
--- 216,220 ----
AttributeDesignator.ENVIRONMENT_TARGET));
} else if (name.equals("AttributeSelector")) {
! evals.add(AttributeSelector.getInstance(node, xpathVersion));
} else if (name.equals("Function")) {
// while the schema doesn't enforce this, it's illegal to
***************
*** 216,220 ****
bagFunction =
! getFunction(node,
FunctionFactory.getGeneralInstance());
}
--- 224,228 ----
bagFunction =
! getFunction(node, xpathVersion,
FunctionFactory.getGeneralInstance());
}
***************
*** 227,231 ****
* Helper method that tries to get a function instance
*/
! private static Function getFunction(Node root, FunctionFactory factory)
throws ParsingException
{
--- 235,240 ----
* Helper method that tries to get a function instance
*/
! private static Function getFunction(Node root, String version,
! FunctionFactory factory)
throws ParsingException
{
***************
*** 242,246 ****
try {
FunctionFactory ff = FunctionFactory.getGeneralInstance();
! return ff.createAbstractFunction(functionName, root);
} catch (Exception e) {
// any exception at this point is a failure
--- 251,255 ----
try {
FunctionFactory ff = FunctionFactory.getGeneralInstance();
! return ff.createAbstractFunction(functionName, root, version);
} catch (Exception e) {
// any exception at this point is a failure
***************
*** 279,282 ****
--- 288,300 ----
public Function getHigherOrderFunction() {
return bagFunction;
+ }
+
+ /**
+ * Returns whether or not this ApplyType is actually a ConditionType.
+ *
+ * @return whether or not this represents a ConditionType
+ */
+ public boolean isCondition() {
+ return isCondition;
}
Index: FunctionFactory.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/cond/FunctionFactory.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** FunctionFactory.java 13 Feb 2003 22:19:10 -0000 1.1.1.1
--- FunctionFactory.java 29 Aug 2003 18:58:33 -0000 1.2
***************
*** 172,176 ****
// add the map function
generalFunctionMap.put(MapFunction.NAME, new FunctionProxy() {
! public Function getInstance(Node root) throws Exception {
return MapFunction.getInstance(root);
}
--- 172,177 ----
// add the map function
generalFunctionMap.put(MapFunction.NAME, new FunctionProxy() {
! public Function getInstance(Node root, String xpathVersion)
! throws Exception {
return MapFunction.getInstance(root);
}
***************
*** 427,430 ****
--- 428,433 ----
* concrete function, and should therefore
* be created through createFunction
+ * @throws ParsingException if the function can't be created with the
+ * given inputs
*/
public Function createAbstractFunction(URI identity, Node root)
***************
*** 432,436 ****
FunctionTypeException
{
! return createAbstractFunction(identity.toString(), root);
}
--- 435,462 ----
FunctionTypeException
{
! return createAbstractFunction(identity.toString(), root, null);
! }
!
! /**
! * Tries to get an instance of the specified abstract function.
! *
! * @param identity the name of the function
! * @param root the DOM root containing info used to create the function
! * @param xpathVersion the version specified in the contianing policy, or
! * null if no version was specified
! *
! * @throws UnknownIdentifierException if the name isn't known
! * @throws FunctionTypeException if the name is known to map to a
! * concrete function, and should therefore
! * be created through createFunction
! * @throws ParsingException if the function can't be created with the
! * given inputs
! */
! public Function createAbstractFunction(URI identity, Node root,
! String xpathVersion)
! throws UnknownIdentifierException, ParsingException,
! FunctionTypeException
! {
! return createAbstractFunction(identity.toString(), root, xpathVersion);
}
***************
*** 445,448 ****
--- 471,476 ----
* concrete function, and should therefore
* be created through createFunction
+ * @throws ParsingException if the function can't be created with the
+ * given inputs
*/
public Function createAbstractFunction(String identity, Node root)
***************
*** 450,453 ****
--- 478,504 ----
FunctionTypeException
{
+ return createAbstractFunction(identity, root, null);
+ }
+
+ /**
+ * Tries to get an instance of the specified abstract function.
+ *
+ * @param identity the name of the function
+ * @param root the DOM root containing info used to create the function
+ * @param xpathVersion the version specified in the contianing policy, or
+ * null if no version was specified
+ *
+ * @throws UnknownIdentifierException if the name isn't known
+ * @throws FunctionTypeException if the name is known to map to a
+ * concrete function, and should therefore
+ * be created through createFunction
+ * @throws ParsingException if the function can't be created with the
+ * given inputs
+ */
+ public Function createAbstractFunction(String identity, Node root,
+ String xpathVersion)
+ throws UnknownIdentifierException, ParsingException,
+ FunctionTypeException
+ {
Object entry = createFunctionHelper(identity);
***************
*** 455,459 ****
if (entry instanceof FunctionProxy) {
try {
! return ((FunctionProxy)entry).getInstance(root);
} catch (Exception e) {
throw new ParsingException("couldn't create abstract" +
--- 506,511 ----
if (entry instanceof FunctionProxy) {
try {
! return ((FunctionProxy)entry).getInstance(root,
! xpathVersion);
} catch (Exception e) {
throw new ParsingException("couldn't create abstract" +
Index: FunctionProxy.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/cond/FunctionProxy.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** FunctionProxy.java 13 Feb 2003 22:19:10 -0000 1.1.1.1
--- FunctionProxy.java 29 Aug 2003 18:58:33 -0000 1.2
***************
*** 42,46 ****
/**
* Used by abstract functions to define how new functions are created by
! * the factory.
*
* @author Seth Proctor
--- 42,47 ----
/**
* Used by abstract functions to define how new functions are created by
! * the factory. Note that all functions using XPath are defined to be
! * abstract functions, so they must be created using this interface.
*
* @author Seth Proctor
***************
*** 50,56 ****
/**
! * Creates an instance of some abstract function.
*
* @param root the DOM root of the apply statement containing the function
*
* @return the function
--- 51,62 ----
/**
! * Creates an instance of some abstract function. If the function
! * being created is not using XPath, then the version parameter can be
! * ignored, otherwise a value must be present and the version must
! * be acceptable.
*
* @param root the DOM root of the apply statement containing the function
+ * @param xpathVersion the version specified in the contianing policy, or
+ * null if no version was specified
*
* @return the function
***************
*** 58,62 ****
* @throws Exception if the underlying code experienced any error
*/
! public Function getInstance(Node root) throws Exception;
}
--- 64,69 ----
* @throws Exception if the underlying code experienced any error
*/
! public Function getInstance(Node root, String xpathVersion)
! throws Exception;
}
|