Package org.apache.xml.security.utils

Examples of org.apache.xml.security.utils.CachedXPathFuncHereAPI


      try {
         Set inputSet = input.getNodeSet();
         if (log.isDebugEnabled())
           log.debug("perform xfilter2 on " + inputSet.size() + " nodes");

         CachedXPathFuncHereAPI xPathFuncHereAPI =
            new CachedXPathFuncHereAPI(input.getCachedXPathAPI().getCachedXPathAPI());
         CachedXPathAPI myXPathAPI =
            new CachedXPathAPI(input.getCachedXPathAPI().getCachedXPathAPI());

         if (inputSet.size() == 0) {
            Object exArgs[] = { "input node set contains no nodes" };

            throw new TransformationException("empty", exArgs);
         }

         Element xpathElement =XMLUtils.selectNode(
            this._transformObject.getElement().getFirstChild(),
               XPath2FilterContainer04.XPathFilter2NS,
               XPath2FilterContainer04._TAG_XPATH2,0);

         if (xpathElement == null) {
            Object exArgs[] = { "dsig-xpath:XPath", "Transform" };

            throw new TransformationException("xml.WrongContent", exArgs);
         }

         XPath2FilterContainer04 xpathContainer =
            XPath2FilterContainer04.newInstance(xpathElement,
                                              input.getSourceURI());
         Document doc = this._transformObject.getElement().getOwnerDocument();
         NodeList subtreeRoots = xPathFuncHereAPI.selectNodeList(doc,
                                    xpathContainer.getXPathFilterTextNode(),
                                    CachedXPathFuncHereAPI.getStrFromNode(xpathContainer.getXPathFilterTextNode()),
                                    xpathContainer.getElement());
         if (log.isDebugEnabled())
           log.debug("subtreeRoots contains " + subtreeRoots.getLength()
View Full Code Here


          * The evaluation of this expression includes all of the document's nodes
          * (including comments) in the node-set representing the octet stream.
          */

        
         CachedXPathFuncHereAPI xPathFuncHereAPI =
            new CachedXPathFuncHereAPI(input.getCachedXPathAPI().getCachedXPathAPI());
        

         Element xpathElement =XMLUtils.selectDsNode(
            this._transformObject.getElement().getFirstChild(),
               Constants._TAG_XPATH,0);

         if (xpathElement == null) {
            Object exArgs[] = { "ds:XPath", "Transform" };

            throw new TransformationException("xml.WrongContent", exArgs);
         }
         Node xpathnode = xpathElement.getChildNodes().item(0);
         String str=CachedXPathFuncHereAPI.getStrFromNode(xpathnode);
         boolean circumvent=needsCircunvent(str);
         Set inputSet = input.getNodeSet(circumvent);
         if (inputSet.size() == 0) {
            Object exArgs[] = { "input node set contains no nodes" };

            throw new TransformationException("empty", exArgs);
         }
        
         /**
          * The transform output is also an XPath node-set. The XPath expression
          * appearing in the XPath parameter is evaluated once for each node in
          * the input node-set. The result is converted to a boolean. If the
          * boolean is true, then the node is included in the output node-set.
          * If the boolean is false, then the node is omitted from the output
          * node-set.
          */
         Set resultNodes = new HashSet();

         /**
          * precompile XPath for evaluation; this is taken from {@link XPathAPI#eval}
          */
         PrefixResolverDefault prefixResolver =
            new PrefixResolverDefault(xpathElement);
        
        
         if (xpathnode == null) {
            throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR,
                                   "Text must be in ds:Xpath");
         }

         Iterator iterator = inputSet.iterator();
        
         while (iterator.hasNext()) {
            Node currentNode = (Node) iterator.next();

            /* Same solution as in TransformBase64 ?
            if (currentNode.getClass().getName().equals(
               "org.apache.xml.dtm.ref.dom2dtm.DOM2DTM$defaultNamespaceDeclarationNode")) {
               continue;
            }
            */           
            XObject includeInResult = xPathFuncHereAPI.eval(currentNode,
                                         xpathnode, str,prefixResolver);
          
            if (includeInResult.bool()) {
               resultNodes.add(currentNode);
               // log.debug("    Added " + org.apache.xml.security.c14n.implementations.Canonicalizer20010315.getXPath(currentNode));
View Full Code Here

      try {
         Set inputSet = input.getNodeSet(true);
         if (log.isDebugEnabled())
           log.debug("perform xfilter2 on " + inputSet.size() + " nodes");

         CachedXPathFuncHereAPI xPathFuncHereAPI =
            new CachedXPathFuncHereAPI(CachedXPathAPIHolder.getCachedXPathAPI());
         CachedXPathAPI myXPathAPI =
            new CachedXPathAPI(CachedXPathAPIHolder.getCachedXPathAPI());

         if (inputSet.size() == 0) {
            Object exArgs[] = { "input node set contains no nodes" };

            throw new TransformationException("empty", exArgs);
         }

         Element xpathElement =XMLUtils.selectNode(
            this._transformObject.getElement().getFirstChild(),
               XPath2FilterContainer04.XPathFilter2NS,
               XPath2FilterContainer04._TAG_XPATH2,0);

         if (xpathElement == null) {
            Object exArgs[] = { "dsig-xpath:XPath", "Transform" };

            throw new TransformationException("xml.WrongContent", exArgs);
         }

         XPath2FilterContainer04 xpathContainer =
            XPath2FilterContainer04.newInstance(xpathElement,
                                              input.getSourceURI());
         Document doc = this._transformObject.getElement().getOwnerDocument();
         NodeList subtreeRoots = xPathFuncHereAPI.selectNodeList(doc,
                                    xpathContainer.getXPathFilterTextNode(),
                                    CachedXPathFuncHereAPI.getStrFromNode(xpathContainer.getXPathFilterTextNode()),
                                    xpathContainer.getElement());
         if (log.isDebugEnabled())
           log.debug("subtreeRoots contains " + subtreeRoots.getLength()
View Full Code Here

          * The evaluation of this expression includes all of the document's nodes
          * (including comments) in the node-set representing the octet stream.
          */

        
         CachedXPathFuncHereAPI xPathFuncHereAPI =
            new CachedXPathFuncHereAPI(CachedXPathAPIHolder.getCachedXPathAPI());
        

         Element xpathElement =XMLUtils.selectDsNode(
            this._transformObject.getElement().getFirstChild(),
               Constants._TAG_XPATH,0);

         if (xpathElement == null) {
            Object exArgs[] = { "ds:XPath", "Transform" };

            throw new TransformationException("xml.WrongContent", exArgs);
         }
         Node xpathnode = xpathElement.getChildNodes().item(0);
         String str=CachedXPathFuncHereAPI.getStrFromNode(xpathnode);
         boolean circumvent=needsCircunvent(str);
         Set inputSet = input.getNodeSet(circumvent);
         if (inputSet.size() == 0) {
            Object exArgs[] = { "input node set contains no nodes" };

            throw new TransformationException("empty", exArgs);
         }
        
         /**
          * The transform output is also an XPath node-set. The XPath expression
          * appearing in the XPath parameter is evaluated once for each node in
          * the input node-set. The result is converted to a boolean. If the
          * boolean is true, then the node is included in the output node-set.
          * If the boolean is false, then the node is omitted from the output
          * node-set.
          */
         Set resultNodes = new HashSet();

         /**
          * precompile XPath for evaluation; this is taken from {@link XPathAPI#eval}
          */
         PrefixResolverDefault prefixResolver =
            new PrefixResolverDefault(xpathElement);
        
        
         if (xpathnode == null) {
            throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR,
                                   "Text must be in ds:Xpath");
         }

         Iterator iterator = inputSet.iterator();
        
         while (iterator.hasNext()) {
            Node currentNode = (Node) iterator.next();

            /* Same solution as in TransformBase64 ?
            if (currentNode.getClass().getName().equals(
               "org.apache.xml.dtm.ref.dom2dtm.DOM2DTM$defaultNamespaceDeclarationNode")) {
               continue;
            }
            */           
            XObject includeInResult = xPathFuncHereAPI.eval(currentNode,
                                         xpathnode, str,prefixResolver);
          
            if (includeInResult.bool()) {
               resultNodes.add(currentNode);
               // log.debug("    Added " + org.apache.xml.security.c14n.implementations.Canonicalizer20010315.getXPath(currentNode));
View Full Code Here

           throws TransformationException {

      try {
         this.inputSet = input.getNodeSet(true);

         CachedXPathFuncHereAPI xPathFuncHereAPI =
            new CachedXPathFuncHereAPI(CachedXPathAPIHolder.getCachedXPathAPI());        

         if (this.inputSet.size() == 0) {
            Object exArgs[] = { "input node set contains no nodes" };

            throw new TransformationException("empty", exArgs);
         }

         Element transformElement = this._transformObject.getElement();
         Document doc = transformElement.getOwnerDocument();

         // create the XPathFilterCHGPContainer so that we easily can read it out
         Element xpathElement = XMLUtils.selectNode(transformElement.getFirstChild(),
                Transforms.TRANSFORM_XPATHFILTERCHGP,
                XPathFilterCHGPContainer._TAG_XPATHCHGP,0);
           
         if (xpathElement == null) {
            Object exArgs[] = { "{" + TransformXPathFilterCHGP.implementedTransformURI + "}XPath",
                                "Transform" };

            throw new TransformationException("xml.WrongContent", exArgs);
         }

         XPathFilterCHGPContainer xpathContainer =
            XPathFilterCHGPContainer.getInstance(xpathElement,
                                                 input.getSourceURI());

         // get the document (root node) for the traversal
         Document inputDoc = null;

         {
            Iterator it = this.inputSet.iterator();

            if (it.hasNext()) {
               inputDoc = XMLUtils.getOwnerDocument((Node) it.next());
            }
         }

         {

            // 'tag' the include-but-search nodes
            Node includeButSearchCtxNode =
               xpathContainer.getHereContextNodeIncludeButSearch();
            NodeList includeButSearchNodes = null;

            if (includeButSearchCtxNode != null) {
               includeButSearchNodes = xPathFuncHereAPI.selectNodeList(doc,
                       includeButSearchCtxNode,CachedXPathFuncHereAPI.getStrFromNode(includeButSearchCtxNode),
                       xpathContainer.getElement());
            }

            this.includeSearchSet = nodeListToSet(includeButSearchNodes);
         }

         {

            // 'tag' the exclude-but-search nodes
            Node excludeButSearchCtxNode =
               xpathContainer.getHereContextNodeExcludeButSearch();
            NodeList excludeButSearchNodes = null;

            if (excludeButSearchCtxNode != null) {
               excludeButSearchNodes = xPathFuncHereAPI.selectNodeList(doc,
                       excludeButSearchCtxNode,
                       CachedXPathFuncHereAPI.getStrFromNode(excludeButSearchCtxNode),xpathContainer.getElement());
            }

            this.excludeSearchSet = nodeListToSet(excludeButSearchNodes);
         }

         {

            // 'tag' the exclude nodes
            Node excludeCtxNode = xpathContainer.getHereContextNodeExclude();
            NodeList excludeNodes = null;

            if (excludeCtxNode != null) {
               excludeNodes = xPathFuncHereAPI.selectNodeList(doc,
                       excludeCtxNode,
                       CachedXPathFuncHereAPI.getStrFromNode(excludeCtxNode),
                       xpathContainer.getElement());
            }
View Full Code Here

            // input node set contains no nodes
            return input;
         }

         CachedXPathFuncHereAPI xPathFuncHereAPI =
            new CachedXPathFuncHereAPI(CachedXPathAPIHolder.getCachedXPathAPI());
         Document inputDoc = XMLUtils.getOwnerDocument(_inputSet);
        
         Element []xpathElements =XMLUtils.selectNodes(
                this._transformObject.getElement().getFirstChild(),
                   XPath2FilterContainer.XPathFilter2NS,
                   XPath2FilterContainer._TAG_XPATH2);
         int noOfSteps = xpathElements.length;


         if (noOfSteps == 0) {
            Object exArgs[] = { Transforms.TRANSFORM_XPATH2FILTER, "XPath" };

            throw new TransformationException("xml.WrongContent", exArgs);
         }

         if (true) {
            _filterTypes.add(FUnion);

            // Set root = new HashSet(); root.add(inputDoc);
            HelperNodeList root = new HelperNodeList();

            root.appendChild(inputDoc);
            _filterNodes.add(root);
         }

         for (int i = 0; i < noOfSteps; i++) {
            Element xpathElement =XMLUtils.selectNode(
               this._transformObject.getElement().getFirstChild(),
                  XPath2FilterContainer.XPathFilter2NS,
                  XPath2FilterContainer._TAG_XPATH2,i);
            XPath2FilterContainer xpathContainer =
               XPath2FilterContainer.newInstance(xpathElement,
                                                   input.getSourceURI());

            if (xpathContainer.isIntersect()) {
               _filterTypes.add(FIntersect);
            } else if (xpathContainer.isSubtract()) {
               _filterTypes.add(FSubtract);
            } else if (xpathContainer.isUnion()) {
               _filterTypes.add(FUnion);
            } else {
               _filterTypes.add(null);
            }

            NodeList subtreeRoots = xPathFuncHereAPI.selectNodeList(inputDoc,
                                       xpathContainer.getXPathFilterTextNode(),
                                       CachedXPathFuncHereAPI.getStrFromNode(xpathContainer.getXPathFilterTextNode()),
                                       xpathContainer.getElement());

            // _filterNodes.add(XMLUtils.convertNodelistToSet(subtreeRoots));
View Full Code Here

TOP

Related Classes of org.apache.xml.security.utils.CachedXPathFuncHereAPI

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.