Преглед на файлове

Remove use of wrong DOMUtils class (from com.sun package).

Luke Taylor преди 15 години
родител
ревизия
dccb30ad63

+ 7 - 5
config/src/main/java/org/springframework/security/config/authentication/AuthenticationManagerBeanDefinitionParser.java

@@ -21,12 +21,11 @@ import org.springframework.security.core.Authentication;
 import org.springframework.security.core.AuthenticationException;
 import org.springframework.util.Assert;
 import org.springframework.util.StringUtils;
+import org.springframework.util.xml.DomUtils;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
-import com.sun.tools.internal.xjc.util.DOMUtils;
-
 /**
  * Registers the central ProviderManager used by the namespace configuration, and allows the configuration of an
  * alias, allowing users to reference it in their beans and clearly see where the name is
@@ -58,9 +57,12 @@ public class AuthenticationManagerBeanDefinitionParser implements BeanDefinition
             if (node instanceof Element) {
                 Element providerElt = (Element)node;
                 if (StringUtils.hasText(providerElt.getAttribute(ATT_REF))) {
-                    if (DOMUtils.getChildElements(providerElt).length > 0) {
-                        pc.getReaderContext().error("authentication-provider element cannot have children when used " +
-                                "with 'ref' atribute", pc.extractSource(element));
+                    NodeList providerChildren = providerElt.getChildNodes();
+                    for (int j = 0; j < providerChildren.getLength(); j++) {
+                        if (providerChildren.item(j) instanceof Element) {
+                            pc.getReaderContext().error("authentication-provider element cannot have child elements when used " +
+                                    "with 'ref' attribute", pc.extractSource(element));
+                        }
                     }
                     providers.add(new RuntimeBeanReference(providerElt.getAttribute(ATT_REF)));
                 } else {

+ 1 - 1
config/src/test/java/org/springframework/security/config/authentication/AuthenticationProviderBeanDefinitionParserTests.java

@@ -135,7 +135,7 @@ public class AuthenticationProviderBeanDefinitionParserTests {
     public void exernalProviderDoesNotSupportChildElements() throws Exception {
         appContext = new InMemoryXmlApplicationContext(
                 "    <authentication-manager>" +
-                "      <authentication-provider ref='aProvider'>" +
+                "      <authentication-provider ref='aProvider'> " +
                 "        <password-encoder ref='customPasswordEncoder'/>" +
                 "      </authentication-provider>" +
                 "    </authentication-manager>" +