From: <se...@us...> - 2003-08-29 18:58:38
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/finder/impl In directory sc8-pr-cvs1:/tmp/cvs-serv11479/com/sun/xacml/finder/impl Modified Files: SelectorModule.java Log Message: added support for enforcing XPathVersion and updated SelectorModule to correctly handle nodes of different types Index: SelectorModule.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/finder/impl/SelectorModule.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SelectorModule.java 11 Aug 2003 20:48:45 -0000 1.2 --- SelectorModule.java 29 Aug 2003 18:58:33 -0000 1.3 *************** *** 37,40 **** --- 37,41 ---- package com.sun.xacml.finder.impl; + import com.sun.xacml.AbstractPolicy; import com.sun.xacml.EvaluationCtx; import com.sun.xacml.ParsingException; *************** *** 73,76 **** --- 74,80 ---- * deciding what to return to the policy based on the MustBePresent * attribute. + * <p> + * This module uses the Xalan XPath implementation, and supports only version + * 1.0 of XPath. * * @author Seth Proctor *************** *** 107,110 **** --- 111,115 ---- * @param type the datatype of the attributes to find * @param context the representation of the request data + * @param xpathVersion the XPath version to use * * @return the result of attribute retrieval, which will be a bag of *************** *** 112,116 **** */ public EvaluationResult findAttribute(String path, URI type, ! EvaluationCtx context) { // get the DOM root of the request document Node root = context.getRequestRoot(); --- 117,126 ---- */ public EvaluationResult findAttribute(String path, URI type, ! EvaluationCtx context, ! String xpathVersion) { ! // we only support 1.0 ! if (! xpathVersion.equals(AbstractPolicy.XPATH_1_0_VERSION)) ! return new EvaluationResult(BagAttribute.createEmptyBag(type)); ! // get the DOM root of the request document Node root = context.getRequestRoot(); *************** *** 130,140 **** } ! // there was at least one match, so try to generate the attributes try { ArrayList list = new ArrayList(); for (int i = 0; i < matches.getLength(); i++) { ! String str = matches.item(i).getFirstChild().getNodeValue(); ! list.add(AttributeFactory.createAttribute(type, str)); } --- 140,165 ---- } ! // there was at least one match, so try to generate the values try { ArrayList list = new ArrayList(); for (int i = 0; i < matches.getLength(); i++) { ! String text = null; ! Node node = matches.item(i); ! short nodeType = node.getNodeType(); ! ! // see if this is straight text, or a node with data under ! // it and then get the values accordingly ! if ((nodeType == Node.CDATA_SECTION_NODE) || ! (nodeType == Node.COMMENT_NODE) || ! (nodeType == Node.TEXT_NODE)) { ! // there is no child to this node ! text = node.getNodeValue(); ! } else { ! // the data is in a child node ! text = node.getFirstChild().getNodeValue(); ! } ! ! list.add(AttributeFactory.createAttribute(type, text)); } |