/** * @see org.apache.xml.security.signature.NodeFilter#isNodeInclude(org.w3c.dom.Node) */ public int isNodeInclude(Node n) { if (n == exclude || XMLUtils.isDescendantOrSelf(exclude, n)) { return -1; } return 1; //return !XMLUtils.isDescendantOrSelf(exclude, n); } }
/** * @param signatureElement * @param inputSet * @return nodes with the constrain */ public static Set<Node> excludeNodeFromSet(Node signatureElement, Set<Node> inputSet) { Set<Node> resultSet = new HashSet<>(); Iterator<Node> iterator = inputSet.iterator(); while (iterator.hasNext()) { Node inputNode = iterator.next(); if (!XMLUtils.isDescendantOrSelf(signatureElement, inputNode)) { resultSet.add(inputNode); } } return resultSet; }
/** * Method rooted * @param currentNode * @param nodeList * * @return if rooted bye the rootnodes */ static boolean rooted(Node currentNode, Set<Node> nodeList) { if (nodeList.isEmpty()) { return false; } if (nodeList.contains(currentNode)) { return true; } for (Node rootNode : nodeList) { if (XMLUtils.isDescendantOrSelf(rootNode, currentNode)) { return true; } } return false; }
/** * @param rootNode * @param result * @param exclude * @param com whether comments or not */ public static void getSet(Node rootNode, Set<Node> result, Node exclude, boolean com) { if (exclude != null && isDescendantOrSelf(exclude, rootNode)) { return; } getSetRec(rootNode, result, exclude, com); }