You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by mu...@apache.org on 2007/03/14 20:16:06 UTC

svn commit: r518269 - /xml/security/trunk/src/org/apache/xml/security/utils/IdResolver.java

Author: mullan
Date: Wed Mar 14 12:16:04 2007
New Revision: 518269

URL: http://svn.apache.org/viewvc?view=rev&rev=518269
Log:
Fixed bug 41805: Resolution of SAML 1.x ID attributes, incorrect namespace

Modified:
    xml/security/trunk/src/org/apache/xml/security/utils/IdResolver.java

Modified: xml/security/trunk/src/org/apache/xml/security/utils/IdResolver.java
URL: http://svn.apache.org/viewvc/xml/security/trunk/src/org/apache/xml/security/utils/IdResolver.java?view=diff&rev=518269&r1=518268&r2=518269
==============================================================================
--- xml/security/trunk/src/org/apache/xml/security/utils/IdResolver.java (original)
+++ xml/security/trunk/src/org/apache/xml/security/utils/IdResolver.java Wed Mar 14 12:16:04 2007
@@ -160,20 +160,23 @@
     }
    
     private static java.util.List names;
+    private static int namesLength;
     static {
-	   String namespaces[]={ Constants.SignatureSpecNS,
-			   EncryptionConstants.EncryptionSpecNS,
-			   "http://schemas.xmlsoap.org/soap/security/2000-12",
-			   "http://www.w3.org/2002/03/xkms#",
-			   "urn:oasis:names:tc:SAML:1.0:assertion",
-			   "urn:oasis:names:tc:SAML:1.0:protocol"
-		   };
-	   names=Arrays.asList(namespaces);
+	String namespaces[]={ 
+	    Constants.SignatureSpecNS,
+	    EncryptionConstants.EncryptionSpecNS,
+	    "http://schemas.xmlsoap.org/soap/security/2000-12",
+	    "http://www.w3.org/2002/03/xkms#",
+	    "urn:oasis:names:tc:SAML:1.0:assertion",
+	    "urn:oasis:names:tc:SAML:1.0:protocol"
+	};
+	names = Arrays.asList(namespaces);
+	namesLength = names.size();
     }
    
 
     private static Element getElementBySearching(Node root,String id) {
-        Element []els=new Element[6];
+        Element []els=new Element[namesLength + 1];
 	getEl(root,id,els);
 	for (int i=0;i<els.length;i++) {
 	    if (els[i]!=null) {
@@ -227,13 +230,13 @@
     	}
     	NamedNodeMap ns=el.getAttributes();
     	int elementIndex=names.indexOf(el.getNamespaceURI());
-	    elementIndex=(elementIndex<0) ? 5 : elementIndex;
+	    elementIndex=(elementIndex<0) ? namesLength : elementIndex;
     	for (int length=ns.getLength(), i=0; i<length; i++) {
     		Attr n=(Attr)ns.item(i);
     		String s=n.getNamespaceURI();
     		
 		    int index=s==null ? elementIndex : names.indexOf(n.getNamespaceURI());
-		    index=(index<0) ? 5 : index;
+		    index=(index<0) ? namesLength : index;
 		    String name=n.getLocalName();
 		    if (name.length()>2)
 		    	continue;
@@ -247,13 +250,13 @@
 		        	}
 		    	} else if (ch=='D' &&value.endsWith(id)) {
 		    		if (index!=3) {
-			            index=5;
+			            index=namesLength;
 			        }
 			        els[index]=el;
 		    	}
 		    } else if ( "id".equals(name) && value.equals(id) ) {
 		    	if (index!=2) {
-		    		index=5;
+		    		index=namesLength;
 		        }			    				   
 		        els[index]=el;
 		    }