Fix namespace problems with Element.getTagName()
authorwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Thu, 22 Jan 2004 20:02:22 +0000 (20:02 +0000)
committerwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Thu, 22 Jan 2004 20:02:22 +0000 (20:02 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@844 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

src/edu/internet2/middleware/shibboleth/common/BaseNameIdentifierMapping.java
src/edu/internet2/middleware/shibboleth/common/Credentials.java
src/edu/internet2/middleware/shibboleth/common/NameMapper.java
src/edu/internet2/middleware/shibboleth/hs/provider/CryptoShibHandle.java

index 2398ca6..5cb8458 100644 (file)
@@ -65,7 +65,7 @@ public abstract class BaseNameIdentifierMapping implements NameIdentifierMapping
 
        public BaseNameIdentifierMapping(Element config) throws NameIdentifierMappingException {
 
-               if (!config.getTagName().equals("NameMapping")) {
+               if (!config.getLocalName().equals("NameMapping")) {
                        throw new IllegalArgumentException();
                }
 
index d3cafc3..a2e0aea 100644 (file)
@@ -97,8 +97,7 @@ public class Credentials {
 
        public Credentials(Element e) {
 
-               if (!e.getTagName().equals("Credentials")
-                       && (!(e.getNamespaceURI().equals(Credentials.credentialsNamespace)) || !e.getTagName().endsWith(":Credentials"))) {
+               if (!e.getLocalName().equals("Credentials")) {
                        throw new IllegalArgumentException();
                }
 
@@ -146,19 +145,19 @@ public class Credentials {
                private static Logger log = Logger.getLogger(CredentialFactory.class.getName());
 
                public static Credential loadCredential(Element e) throws CredentialFactoryException {
-                       if (e.getTagName().equals("KeyInfo")) {
+                       if (e.getLocalName().equals("KeyInfo")) {
                                return new KeyInfoCredentialResolver().loadCredential(e);
                        }
 
-                       if (e.getTagName().equals("FileResolver")) {
+                       if (e.getLocalName().equals("FileResolver")) {
                                return new FileCredentialResolver().loadCredential(e);
                        }
 
-                       if (e.getTagName().equals("KeyStoreResolver")) {
+                       if (e.getLocalName().equals("KeyStoreResolver")) {
                                return new KeystoreCredentialResolver().loadCredential(e);
                        }
 
-                       if (e.getTagName().equals("CustomResolver")) {
+                       if (e.getLocalName().equals("CustomResolver")) {
                                return new CustomCredentialResolver().loadCredential(e);
                        }
 
@@ -191,7 +190,7 @@ class FileCredentialResolver implements CredentialResolver {
 
        public Credential loadCredential(Element e) throws CredentialFactoryException {
 
-               if (!e.getTagName().equals("FileResolver")) {
+               if (!e.getLocalName().equals("FileResolver")) {
                        log.error("Invalid Credential Resolver configuration: expected <FileResolver> .");
                        throw new CredentialFactoryException("Failed to initialize Credential Resolver.");
                }
@@ -1328,7 +1327,7 @@ class KeystoreCredentialResolver implements CredentialResolver {
 
        public Credential loadCredential(Element e) throws CredentialFactoryException {
 
-               if (!e.getTagName().equals("KeyStoreResolver")) {
+               if (!e.getLocalName().equals("KeyStoreResolver")) {
                        log.error("Invalid Credential Resolver configuration: expected <KeyStoreResolver> .");
                        throw new CredentialFactoryException("Failed to initialize Credential Resolver.");
                }
@@ -1519,7 +1518,7 @@ class CustomCredentialResolver implements CredentialResolver {
 
        public Credential loadCredential(Element e) throws CredentialFactoryException {
 
-               if (!e.getTagName().equals("CustomCredResolver")) {
+               if (!e.getLocalName().equals("CustomCredResolver")) {
                        log.error("Invalid Credential Resolver configuration: expected <CustomCredResolver> .");
                        throw new CredentialFactoryException("Failed to initialize Credential Resolver.");
                }
index 336862c..28e828e 100644 (file)
@@ -137,11 +137,11 @@ public class NameMapper {
         */
        public void addNameMapping(Element e) throws NameIdentifierMappingException {
                
-               if (!e.getTagName().equals("NameMapping")
-                       && (!(e.getNamespaceURI().equals(NameIdentifierMapping.mappingNamespace))
-                               || !e.getTagName().endsWith(":NameMapping"))) {
+               if (!e.getLocalName().equals("NameMapping")) {
                        throw new IllegalArgumentException();
                }
+               
+               log.info("Found Name Mapping. Loading...");
 
                String type = ((Element) e).getAttribute("type");
                String implementation = ((Element) e).getAttribute("class");
index 5a85375..0740b9e 100644 (file)
@@ -86,6 +86,7 @@ import sun.misc.BASE64Encoder;
 import edu.internet2.middleware.shibboleth.common.AuthNPrincipal;
 import edu.internet2.middleware.shibboleth.common.IdentityProvider;
 import edu.internet2.middleware.shibboleth.common.InvalidNameIdentifierException;
+import edu.internet2.middleware.shibboleth.common.NameIdentifierMapping;
 import edu.internet2.middleware.shibboleth.common.NameIdentifierMappingException;
 import edu.internet2.middleware.shibboleth.common.ServiceProvider;
 import edu.internet2.middleware.shibboleth.common.ShibResource;
@@ -287,11 +288,8 @@ public class CryptoShibHandle extends AQHNameIdentifierMapping implements HSName
 
        private String getElementConfigData(Element e, String itemName) throws NameIdentifierMappingException {
 
-               //TODO move to namespace aware method
-               //NodeList itemElements =
-               // e.getElementsByTagNameNS(NameIdentifierMapping.mappingNamespace,
-               // itemName);
-               NodeList itemElements = e.getElementsByTagName(itemName);
+               NodeList itemElements =e.getElementsByTagNameNS(NameIdentifierMapping.mappingNamespace, itemName);
+               
                if (itemElements.getLength() < 1) {
                        log.error(itemName + " not specified.");
                        throw new NameIdentifierMappingException(