Skip navigation links

Oracle Security Developer Tools XML Security Java API Reference
11g (11.1.1)

E10680-02


oracle.security.xmlsec.util
Class NodeReaderForNodeset

java.lang.Object
  extended by oracle.security.xmlsec.util.NodeReader
      extended by oracle.security.xmlsec.util.NodeReaderForNodeset


public class NodeReaderForNodeset
extends NodeReader

FOR INTERNAL USE ONLY


Nested Class Summary

 

Nested classes/interfaces inherited from class oracle.security.xmlsec.util.NodeReader
NodeReader.NodeListener

 

Field Summary

 

Fields inherited from class oracle.security.xmlsec.util.NodeReader
CHARACTERS, COMMENT, DTD, END_DOCUMENT, END_ELEMENT, PROCESSING_INSTRUCTION, START_DOCUMENT, START_ELEMENT

 

Constructor Summary
NodeReaderForNodeset(java.util.Collection sourceNodes, boolean areNamespacesMissing, boolean isSparse)
           

 

Method Summary
 java.util.Collection getAncestorXmlAttributes(boolean c14n11)
          Get a list of all the xml attributes in the ancestors of this element, whether the elements are in the nodeset or not.
 java.util.Iterator getAttributes()
          Returns all the namespaces and attributes on this START_ELEMENT.
 org.w3c.dom.Node getCurrentNode()
           
 int getEventType()
          Returns an integer code that indicates the type of the event the cursor is pointing to START_ELEMENT END_ELEMENT PROCESSING_INSTRUCTION CHARACTERS COMMENT START_DOCUMENT END_DOCUMENT
 java.lang.String getLocalName()
          Returns the (local) name of the current event.
 java.util.Map getNamespaces()
          Returns all the namespaces on this START_ELEMENT.
 java.util.Iterator getNamespacesForMissingAncestors()
          Returns those inherited namespace declaration, for which the ancestor element that declares the namespace is missing from the nodeset.
 java.lang.String getNamespaceURI()
          If the current event is a START_ELEMENT or END_ELEMENT this method returns the URI of the prefix or the default namespace
 org.w3c.dom.Node getNode()
          Returns the current node.
 java.lang.String getPIData()
          Get the data section of a processing instruction
 java.lang.String getPITarget()
          Get the target of a processing instruction
 java.lang.String getPrefix()
          Returns the prefix of the current event or null if the event does not have a prefix
 java.util.SortedMap getSortedAttributes()
          Returns all the attributes (not namespaces) on this START_ELEMENT.
 char[] getText()
          Returns the current value of the parse event as a character array, this returns the string value of a CHARACTERS event, returns the value of a COMMENT,
 int getTextLength()
           
 int getTextStart()
           
 boolean hasNext()
          Returns true if there are more parsing events and false if there are no more events.
 boolean isElementAnOrphan()
          Returns whether this element in an orphan (i.e the element is included but its parent is not included in the nodeset).
 boolean isElementIncluded()
          For special case when some of an element's attributes are in the node set but the element itself is not
 boolean isElementInheritingNamespaces()
          Whether the element inherits all the namespaces of its parents.
 int next()
          Get next parsing event.
 int nextNode()
           

 

Methods inherited from class oracle.security.xmlsec.util.NodeReader
addListener, fireConsumeNode, isUnnecessaryEmptyDefaultNsRequired, removeListener

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Constructor Detail

NodeReaderForNodeset

public NodeReaderForNodeset(java.util.Collection sourceNodes,
                            boolean areNamespacesMissing,
                            boolean isSparse)
Parameters:
sourceNodes - a collection of Nodes. The interpretation of NamespaceNodes in this list depends on the areNamespacesMissing parameter
areNamespacesMissing - see areNamespacesMissing Indicates whether any Namespace node have been explicitly filtered out (which is rare and never used in any real life situations).
  • areNamespacesMissing == false (usual case) then all nodes of node type NAMESPACE_NODE are ignored, the namespaces are expected to be present as ATTRIBUTE_NODEs. In this mode namespaces and attributes are returned through the getAttributes() call instead of the getNamespaces() and getSortedAttributes() which return null. Also isElementInheritingNamespaces() returns true indicating that namespaces are inherited.
  • areNamespacesMissing == true (rare), then ATTRIBUTE_NODEs that are namespaces are not considered at all. Only NAMESPACE_NODEs are considered. Note. With NAMESPACE_NODEs there is no inheritance i.e. every element must have a list of all NAMESPACE_NODEs that are in effect. This causes an explosion in the number of NAMESPACE_NODES - say there are 1000 elements in a nodeset, and the root element declares 10 namespaces. So now there will be 10x1000 = 10000 NAMESPACE_NODEs because each element inherits all these 10 namespaces This causes a serious performance problem. So this should be normally turned off, the only reason to turn it on is to support esoteric c14n tests, which use xpath filtering that specifically remove certain NAMESPACE_NODEs and prevent them from being inherited to the descendant elements.

    In the areNamespacesMissing=true mode, namespaces and attributes are returned separately through the getNamespaces() and getSortedAttributes() methods. The getAttributes() also works, and it returns both the namespaces and the attributes in a single list. isElementInheritingNamespaces() returns true.

    Also if areNamespaces==true, the NodeReaderForNodeset constructor goes through the sourceNodes collection, and for every element it creates a NodeObject, and populates that NodeObject with a list of attributes and a list of namespaces.
    Example: So suppose there are two elements with two namespace nodes each i.e. sourceNodes contains (e1, e2, e1_n1, e1_n2, e2_n1, e2_n2) (Note the nodes can be present in any order, but the constructor only uses a single pass) This constructor goes through all of sourceNodes and constructs two NodeObject object e1_no = (e1, (e1_n1, e1_n2)) and e2_no = (e2, (e2_n1, e2_n2)) and populates the elementToNodeObj map with e1->e1_no and e2->e2_no

isSparse - whether the sourceNodes should be considered as sparse
  • isSparse == false (usually) in this mode NodeReaderForNodeset walks through the entire document and checks the nodes is the document against the nodes of the sourceNodes collection. (it copies the sourceNodes to as Hashset nodeset so that it can do inclusion checks quickly). Note the sourceNodes collection can be disjoint, so while walking the tree, NodeReaderForNodeset CANNOT assume that if an element is missing from the sourceNodes collection, all its descandants are also missing, i.e. it cannot "prune" the search tree.
  • isSparse == true in this mode the NodeReaderForNodeset constructor creates a list of missingParents which are elements that are themselves absent from the sourceNodes collection, but have at least one descendant that is present in sourceNodes. Once it has constructed this list, it can safely prune elements that neither in the sourceNodes collection nor in the missingParents. However it is expensive to construct the missingParents list, and speed gains of pruning may not more than the delays cost by constructing the missingParent list. Only if the nodeset is "sufficiently" sparse will it be faster to use this mode.
    Note: you will get the exact same set of nodes with isSparse = true and isSparse = false the only difference is peformance. But the same thing cannot be said of areNamespacesMissing as that can return different nodes, if NAMESPACE_NODEs are filtered out. nor in

Method Detail

next

public final int next()
Description copied from class: NodeReader
Get next parsing event. one of
Specified by:
next in class NodeReader
Returns:

nextNode

public final int nextNode()

getCurrentNode

public final org.w3c.dom.Node getCurrentNode()

getEventType

public final int getEventType()
Description copied from class: NodeReader
Returns an integer code that indicates the type of the event the cursor is pointing to
Specified by:
getEventType in class NodeReader
Returns:

getLocalName

public final java.lang.String getLocalName()
Description copied from class: NodeReader
Returns the (local) name of the current event.
Specified by:
getLocalName in class NodeReader

getNamespaceURI

public final java.lang.String getNamespaceURI()
Description copied from class: NodeReader
If the current event is a START_ELEMENT or END_ELEMENT this method returns the URI of the prefix or the default namespace
Specified by:
getNamespaceURI in class NodeReader

getPrefix

public java.lang.String getPrefix()
Description copied from class: NodeReader
Returns the prefix of the current event or null if the event does not have a prefix
Specified by:
getPrefix in class NodeReader

getPIData

public final java.lang.String getPIData()
Description copied from class: NodeReader
Get the data section of a processing instruction
Specified by:
getPIData in class NodeReader

getPITarget

public final java.lang.String getPITarget()
Description copied from class: NodeReader
Get the target of a processing instruction
Specified by:
getPITarget in class NodeReader

getText

public final char[] getText()
Description copied from class: NodeReader
Returns the current value of the parse event as a character array, this returns the string value of a CHARACTERS event, returns the value of a COMMENT,
Specified by:
getText in class NodeReader
Returns:

getTextStart

public final int getTextStart()
Specified by:
getTextStart in class NodeReader

getTextLength

public final int getTextLength()
Specified by:
getTextLength in class NodeReader

hasNext

public final boolean hasNext()
Description copied from class: NodeReader
Returns true if there are more parsing events and false if there are no more events.
Specified by:
hasNext in class NodeReader
Returns:

isElementIncluded

public final boolean isElementIncluded()
Description copied from class: NodeReader
For special case when some of an element's attributes are in the node set but the element itself is not
Overrides:
isElementIncluded in class NodeReader

getNode

public final org.w3c.dom.Node getNode()
Description copied from class: NodeReader
Returns the current node. It is ok for this method to return null, it will do that for a non DOM implementation
Overrides:
getNode in class NodeReader

getAttributes

public final java.util.Iterator getAttributes()
Description copied from class: NodeReader
Returns all the namespaces and attributes on this START_ELEMENT.

All NodeReaders must implement this. Additionally a node reader may implement the NodeReader.getNamespaces() and NodeReader.getSortedAttributes() methods to return the namespaces and attributes separately.

Specified by:
getAttributes in class NodeReader

getSortedAttributes

public final java.util.SortedMap getSortedAttributes()
Description copied from class: NodeReader
Returns all the attributes (not namespaces) on this START_ELEMENT. This method only exists for performance. If this method returns null then the getAttributes() method is used, The map should contain Attr->DUMMY. the map should use StreamC14nImpl.AttrComparator as its comparator to sort the attributes
Overrides:
getSortedAttributes in class NodeReader

getNamespaces

public final java.util.Map getNamespaces()
Description copied from class: NodeReader
Returns all the namespaces on this START_ELEMENT. This method only exists for performance. If this method returns null then the getAttributes() method is used The map should contain Prefix->NamespaceNode
Overrides:
getNamespaces in class NodeReader

isElementAnOrphan

public boolean isElementAnOrphan()
Description copied from class: NodeReader
Returns whether this element in an orphan (i.e the element is included but its parent is not included in the nodeset). This is used in inclusiveC14N
Overrides:
isElementAnOrphan in class NodeReader

getAncestorXmlAttributes

public java.util.Collection getAncestorXmlAttributes(boolean c14n11)
                                              throws NodeReaderException
Description copied from class: NodeReader
Get a list of all the xml attributes in the ancestors of this element, whether the elements are in the nodeset or not. This is used in inclusive C14N.
Overrides:
getAncestorXmlAttributes in class NodeReader
Parameters:
c14n11 - follow C14n 1.1 rules, i.e. for simple inheritable attributes - xml:lang and xml:space, return the nearest ancestor, and for xml:base merge the values from missing ancestors
Throws:
NodeReaderException

isElementInheritingNamespaces

public boolean isElementInheritingNamespaces()
Description copied from class: NodeReader
Whether the element inherits all the namespaces of its parents. Normally it does, but only in case of an XPath nodeset, each element has its own list of namespace nodes and this is false
Overrides:
isElementInheritingNamespaces in class NodeReader

getNamespacesForMissingAncestors

public java.util.Iterator getNamespacesForMissingAncestors()
Description copied from class: NodeReader
Returns those inherited namespace declaration, for which the ancestor element that declares the namespace is missing from the nodeset. Note: these namespaces should also included in the namespaces returned by getAttributes and getNamespaces

E.gfor this xml <foo xmlns:n1="n1"> <bar xmlns:n2="n2"/> </foo> if foo is not included in the nodeset, but bar is included, bar inherits the n1 namespace declaration. So n1 should be returned by this function and both n1 and n2 should be returned by getAttributes

Overrides:
getNamespacesForMissingAncestors in class NodeReader
Returns:

Skip navigation links

Oracle Security Developer Tools XML Security Java API Reference
11g (11.1.1)

E10680-02


Copyright © 2005, 2009, Oracle. All rights reserved.