You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by gi...@apache.org on 2014/01/13 15:40:07 UTC

svn commit: r1557733 - /santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/XMLSecurityStreamReader.java

Author: giger
Date: Mon Jan 13 14:40:07 2014
New Revision: 1557733

URL: http://svn.apache.org/r1557733
Log:
use parent (start) element to query for namespaces when current event is endElement.

Modified:
    santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/XMLSecurityStreamReader.java

Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/XMLSecurityStreamReader.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/XMLSecurityStreamReader.java?rev=1557733&r1=1557732&r2=1557733&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/XMLSecurityStreamReader.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/XMLSecurityStreamReader.java Mon Jan 13 14:40:07 2014
@@ -38,6 +38,7 @@ import org.apache.xml.security.exception
 import org.apache.xml.security.stax.ext.InputProcessorChain;
 import org.apache.xml.security.stax.ext.XMLSecurityProperties;
 import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
+import org.apache.xml.security.stax.ext.stax.XMLSecStartElement;
 
 /**
  * A custom implementation of a XMLStreamReader to get back from the XMLEventReader world
@@ -206,13 +207,12 @@ public class XMLSecurityStreamReader imp
             case START_ELEMENT:
                 return xmlSecEvent.asStartElement().getNamespaceURI(prefix);
             case END_ELEMENT:
-                @SuppressWarnings("unchecked")
-                Iterator<Namespace> namespaceIterator = xmlSecEvent.asEndElement().getNamespaces();
-                while (namespaceIterator.hasNext()) {
-                    Namespace namespace = namespaceIterator.next();
-                    if (prefix.equals(namespace.getPrefix())) {
-                        return namespace.getNamespaceURI();
-                    }
+                //the documentation states that getNamespaces on an end element should return ns'es that
+                //go out of scope (currently not unsupported)
+                //so that means we have to query the parent element
+                XMLSecStartElement xmlSecStartElement = xmlSecEvent.asEndElement().getParentXMLSecStartElement();
+                if (xmlSecStartElement != null) {
+                    return xmlSecStartElement.getNamespaceURI(prefix);
                 }
                 return null;
             default: