Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml
In directory sc8-pr-cvs1:/tmp/cvs-serv11479/com/sun/xacml
Modified Files:
AbstractPolicy.java Policy.java Rule.java Target.java
TargetMatch.java
Log Message:
added support for enforcing XPathVersion and updated SelectorModule to
correctly handle nodes of different types
Index: AbstractPolicy.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/AbstractPolicy.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** AbstractPolicy.java 25 Aug 2003 16:53:10 -0000 1.5
--- AbstractPolicy.java 29 Aug 2003 18:58:32 -0000 1.6
***************
*** 209,213 ****
description = child.getFirstChild().getNodeValue();
} else if (cname.equals("Target")) {
! target = Target.getInstance(child);
} else if (cname.equals("Obligations")) {
parseObligations(child);
--- 209,213 ----
description = child.getFirstChild().getNodeValue();
} else if (cname.equals("Target")) {
! target = Target.getInstance(child, defaultVersion);
} else if (cname.equals("Obligations")) {
parseObligations(child);
***************
*** 402,416 ****
* @param indenter an object that creates indentation strings
*/
! protected void encodeCommonElements(OutputStream out, Indenter indenter) {
! target.encode(out, indenter);
Iterator it = children.iterator();
while (it.hasNext()) {
! ((PolicyTreeElement)(it.next())).encode(out, indenter);
}
it = obligations.iterator();
while (it.hasNext()) {
! ((Obligation)(it.next())).encode(out, indenter);
}
}
--- 402,417 ----
* @param indenter an object that creates indentation strings
*/
! protected void encodeCommonElements(OutputStream output,
! Indenter indenter) {
! target.encode(output, indenter);
Iterator it = children.iterator();
while (it.hasNext()) {
! ((PolicyTreeElement)(it.next())).encode(output, indenter);
}
it = obligations.iterator();
while (it.hasNext()) {
! ((Obligation)(it.next())).encode(output, indenter);
}
}
Index: Policy.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/Policy.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Policy.java 25 Aug 2003 16:53:10 -0000 1.4
--- Policy.java 29 Aug 2003 18:58:32 -0000 1.5
***************
*** 206,209 ****
--- 206,210 ----
List rules = new ArrayList();
+ String xpathVersion = getDefaultVersion();
NodeList children = root.getChildNodes();
***************
*** 211,215 ****
Node child = children.item(i);
if (child.getNodeName().equals("Rule"))
! rules.add(Rule.getInstance(child));
}
--- 212,216 ----
Node child = children.item(i);
if (child.getNodeName().equals("Rule"))
! rules.add(Rule.getInstance(child, xpathVersion));
}
Index: Rule.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/Rule.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Rule.java 25 Aug 2003 16:53:10 -0000 1.3
--- Rule.java 29 Aug 2003 18:58:32 -0000 1.4
***************
*** 104,111 ****
*
* @param root the DOM root of a RuleType XML type
*
* @throws ParsingException if the RuleType is invalid
*/
! public static Rule getInstance(Node root) throws ParsingException {
URI id = null;
String name = null;
--- 104,116 ----
*
* @param root the DOM root of a RuleType 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 the RuleType is invalid
*/
! public static Rule getInstance(Node root, String xpathVersion)
! throws ParsingException
! {
URI id = null;
String name = null;
***************
*** 144,150 ****
description = child.getFirstChild().getNodeValue();
} else if (cname.equals("Target")) {
! target = Target.getInstance(child);
} else if (cname.equals("Condition")) {
! condition = Apply.getConditionInstance(child);
}
}
--- 149,155 ----
description = child.getFirstChild().getNodeValue();
} else if (cname.equals("Target")) {
! target = Target.getInstance(child, xpathVersion);
} else if (cname.equals("Condition")) {
! condition = Apply.getConditionInstance(child, xpathVersion);
}
}
Index: Target.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/Target.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Target.java 25 Aug 2003 16:53:10 -0000 1.3
--- Target.java 29 Aug 2003 18:58:32 -0000 1.4
***************
*** 98,101 ****
--- 98,104 ----
*
* @param root the node to parse for the <code>Target</code>
+ * @param xpathVersion the XPath version to use in any selectors, or
+ * null if this is unspecified (ie, not supplied in
+ * the defaults section of the policy)
*
* @return a new <code>Target</code> constructed by parsing
***************
*** 103,107 ****
* @throws ParsingException if the DOM node is invalid
*/
! public static Target getInstance(Node root) throws ParsingException {
List subjects = null;
List resources = null;
--- 106,112 ----
* @throws ParsingException if the DOM node is invalid
*/
! public static Target getInstance(Node root, String xpathVersion)
! throws ParsingException
! {
List subjects = null;
List resources = null;
***************
*** 114,122 ****
if (name.equals("Subjects")) {
! subjects = getAttributes(child, "Subject");
} else if (name.equals("Resources")) {
! resources = getAttributes(child, "Resource");
} else if (name.equals("Actions")) {
! actions = getAttributes(child, "Action");
}
}
--- 119,127 ----
if (name.equals("Subjects")) {
! subjects = getAttributes(child, "Subject", xpathVersion);
} else if (name.equals("Resources")) {
! resources = getAttributes(child, "Resource", xpathVersion);
} else if (name.equals("Actions")) {
! actions = getAttributes(child, "Action", xpathVersion);
}
}
***************
*** 132,136 ****
* it represents AnySubject, AnyResource, or AnyAction.
*/
! private static List getAttributes(Node root, String prefix)
throws ParsingException
{
--- 137,142 ----
* it represents AnySubject, AnyResource, or AnyAction.
*/
! private static List getAttributes(Node root, String prefix,
! String xpathVersion)
throws ParsingException
{
***************
*** 143,147 ****
if (name.equals(prefix)) {
! matches.add(getMatches(child, prefix));
} else if (name.equals("Any" + prefix)) {
return null;
--- 149,153 ----
if (name.equals(prefix)) {
! matches.add(getMatches(child, prefix, xpathVersion));
} else if (name.equals("Any" + prefix)) {
return null;
***************
*** 157,161 ****
* prefix, which must be either "Subject", "Resource" or "Action"
*/
! private static List getMatches(Node root, String prefix)
throws ParsingException
{
--- 163,168 ----
* prefix, which must be either "Subject", "Resource" or "Action"
*/
! private static List getMatches(Node root, String prefix,
! String xpathVersion)
throws ParsingException
{
***************
*** 168,172 ****
if (name.equals(prefix + "Match"))
! list.add(TargetMatch.getInstance(child, prefix));
}
--- 175,179 ----
if (name.equals(prefix + "Match"))
! list.add(TargetMatch.getInstance(child, prefix, xpathVersion));
}
Index: TargetMatch.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/TargetMatch.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** TargetMatch.java 25 Aug 2003 16:53:10 -0000 1.3
--- TargetMatch.java 29 Aug 2003 18:58:32 -0000 1.4
***************
*** 111,115 ****
* attributes from the request context
* @param attrValue the <code>AttributeValue</code> to compare against
! *
* @throws IllegalArgumentException if the input type isn't a valid value
*/
--- 111,115 ----
* attributes from the request context
* @param attrValue the <code>AttributeValue</code> to compare against
! *
* @throws IllegalArgumentException if the input type isn't a valid value
*/
***************
*** 138,141 ****
--- 138,144 ----
* @param prefix a String indicating what type of <code>TargetMatch</code>
* to instantiate (Subject, Resource, or Action)
+ * @param xpathVersion the XPath version to use in any selectors, or
+ * null if this is unspecified (ie, not supplied in
+ * the defaults section of the policy)
*
* @return a new <code>TargetMatch</code> constructed by parsing
***************
*** 144,148 ****
* @throws IllegalArgumentException if the input prefix isn't a valid value
*/
! public static TargetMatch getInstance(Node root, String prefix)
throws ParsingException, IllegalArgumentException
{
--- 147,152 ----
* @throws IllegalArgumentException if the input prefix isn't a valid value
*/
! public static TargetMatch getInstance(Node root, String prefix,
! String xpathVersion)
throws ParsingException, IllegalArgumentException
{
***************
*** 196,200 ****
eval = AttributeDesignator.getInstance(node, type);
} else if (name.equals("AttributeSelector")) {
! eval = AttributeSelector.getInstance(node);
} else if (name.equals("AttributeValue")) {
try {
--- 200,204 ----
eval = AttributeDesignator.getInstance(node, type);
} else if (name.equals("AttributeSelector")) {
! eval = AttributeSelector.getInstance(node, xpathVersion);
} else if (name.equals("AttributeValue")) {
try {
|