diff --git a/config/src/main/java/org/springframework/security/config/SecurityNamespaceHandler.java b/config/src/main/java/org/springframework/security/config/SecurityNamespaceHandler.java
index 144d1ac02a..c86638a6d6 100644
--- a/config/src/main/java/org/springframework/security/config/SecurityNamespaceHandler.java
+++ b/config/src/main/java/org/springframework/security/config/SecurityNamespaceHandler.java
@@ -40,8 +40,8 @@ public final class SecurityNamespaceHandler implements NamespaceHandler {
public BeanDefinition parse(Element element, ParserContext pc) {
if (!namespaceMatchesVersion(element)) {
- pc.getReaderContext().fatal("You cannot use a spring-security-2.0.xsd schema with Spring Security 3." +
- " Please update your schema declarations to the 3.1 schema.", element);
+ pc.getReaderContext().fatal("You cannot use a spring-security-2.0.xsd or spring-security-3.0.xsd schema " +
+ "with Spring Security 3.1. Please update your schema declarations to the 3.1 schema.", element);
}
String name = pc.getDelegate().getLocalName(element);
BeanDefinitionParser parser = parsers.get(name);
@@ -58,13 +58,14 @@ public final class SecurityNamespaceHandler implements NamespaceHandler {
} else {
reportUnsupportedNodeType(name, pc, element);
}
+
+ return null;
}
return parser.parse(element, pc);
}
public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext pc) {
- BeanDefinitionDecorator decorator = null;
String name = pc.getDelegate().getLocalName(node);
// We only handle elements
@@ -84,9 +85,7 @@ public final class SecurityNamespaceHandler implements NamespaceHandler {
}
}
- if (decorator == null) {
- reportUnsupportedNodeType(name, pc, node);
- }
+ reportUnsupportedNodeType(name, pc, node);
return null;
}
@@ -129,8 +128,11 @@ public final class SecurityNamespaceHandler implements NamespaceHandler {
/**
* Check that the schema location declared in the source file being parsed matches the Spring Security version.
- * The old 2.0 schema is not compatible with the new 3.0 parser, so it is an error to explicitly use
- * 3.0. It might be an error to declare spring-security.xsd as an alias, but you are only going to find that out
+ * The old 2.0 schema is not compatible with the 3.1 parser, so it is an error to explicitly use
+ * 2.0.
+ *
+ * There are also differences between 3.0 and 3.1 which are sufficient that we report using 3.0 as an error too.
+ * It might be an error to declare spring-security.xsd as an alias, but you are only going to find that out
* when one of the sub parsers breaks.
*
* @param element the element that is to be parsed next
@@ -142,7 +144,7 @@ public final class SecurityNamespaceHandler implements NamespaceHandler {
private boolean matchesVersionInternal(Element element) {
String schemaLocation = element.getAttributeNS("http://www.w3.org/2001/XMLSchema-instance", "schemaLocation");
- return schemaLocation.matches("(?m).*spring-security-3.*.xsd.*")
+ return schemaLocation.matches("(?m).*spring-security-3\\.1.*.xsd.*")
|| schemaLocation.matches("(?m).*spring-security.xsd.*")
|| !schemaLocation.matches("(?m).*spring-security.*");
}
diff --git a/config/src/test/java/org/springframework/security/config/SecurityNamespacehandlerTests.java b/config/src/test/java/org/springframework/security/config/SecurityNamespacehandlerTests.java
index 12d19ca476..cca54b7c73 100644
--- a/config/src/test/java/org/springframework/security/config/SecurityNamespacehandlerTests.java
+++ b/config/src/test/java/org/springframework/security/config/SecurityNamespacehandlerTests.java
@@ -11,19 +11,23 @@ import org.springframework.security.config.util.InMemoryXmlApplicationContext;
* @author Luke Taylor
* @since 3.0
*/
-public class SecurityNamespacehandlerTests {
+public class SecurityNamespaceHandlerTests {
+ @Test
+ public void constructionSucceeds() {
+ new SecurityNamespaceHandler();
+ }
@Test
- public void pre3SchemaAreNotSupported() throws Exception {
+ public void pre31SchemaAreNotSupported() throws Exception {
try {
new InMemoryXmlApplicationContext(
"" +
" " +
- "", "2.0.4", null
+ "", "3.0.3", null
);
fail("Expected BeanDefinitionParsingException");
} catch (BeanDefinitionParsingException expected) {
- assertTrue(expected.getMessage().contains("You cannot use a spring-security-2.0.xsd schema"));
+ assertTrue(expected.getMessage().contains("You cannot use a spring-security-2.0.xsd or"));
}
}
}
diff --git a/config/src/test/java/org/springframework/security/config/authentication/AuthenticationManagerBeanDefinitionParserTests.java b/config/src/test/java/org/springframework/security/config/authentication/AuthenticationManagerBeanDefinitionParserTests.java
index 142d200df1..b419261a74 100644
--- a/config/src/test/java/org/springframework/security/config/authentication/AuthenticationManagerBeanDefinitionParserTests.java
+++ b/config/src/test/java/org/springframework/security/config/authentication/AuthenticationManagerBeanDefinitionParserTests.java
@@ -34,13 +34,13 @@ public class AuthenticationManagerBeanDefinitionParserTests {
@Test
// SEC-1225
public void providersAreRegisteredAsTopLevelBeans() throws Exception {
- setContext(CONTEXT, "3.0");
+ setContext(CONTEXT, "3.1");
assertEquals(1, appContext.getBeansOfType(AuthenticationProvider.class).size());
}
@Test
public void eventsArePublishedByDefault() throws Exception {
- setContext(CONTEXT, "3.0");
+ setContext(CONTEXT, "3.1");
AuthListener listener = new AuthListener();
appContext.addApplicationListener(listener);
diff --git a/config/src/test/resources/org/springframework/security/config/method-security.xml b/config/src/test/resources/org/springframework/security/config/method-security.xml
index d23590a295..93fec2e4e3 100644
--- a/config/src/test/resources/org/springframework/security/config/method-security.xml
+++ b/config/src/test/resources/org/springframework/security/config/method-security.xml
@@ -4,7 +4,7 @@
xmlns:b="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
-http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd">
+http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd">
diff --git a/config/src/test/resources/org/springframework/security/util/filtertest-valid.xml b/config/src/test/resources/org/springframework/security/util/filtertest-valid.xml
index 899174b22f..12808f8b0a 100644
--- a/config/src/test/resources/org/springframework/security/util/filtertest-valid.xml
+++ b/config/src/test/resources/org/springframework/security/util/filtertest-valid.xml
@@ -21,7 +21,7 @@
xmlns:sec="http://www.springframework.org/schema/security"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
-http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd">
+http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd">
@@ -42,7 +42,7 @@ http://www.springframework.org/schema/security http://www.springframework.org/sc
-
+
diff --git a/itest/context/src/test/resources/protect-pointcut-performance-app-context.xml b/itest/context/src/test/resources/protect-pointcut-performance-app-context.xml
index 03080fbedb..a1cadeb00f 100644
--- a/itest/context/src/test/resources/protect-pointcut-performance-app-context.xml
+++ b/itest/context/src/test/resources/protect-pointcut-performance-app-context.xml
@@ -2,7 +2,7 @@
xmlns:sec="http://www.springframework.org/schema/security"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
- http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd">
+ http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd">
diff --git a/itest/web/src/main/webapp/WEB-INF/http-security-basic.xml b/itest/web/src/main/webapp/WEB-INF/http-security-basic.xml
index 460950b09f..0f74a28590 100644
--- a/itest/web/src/main/webapp/WEB-INF/http-security-basic.xml
+++ b/itest/web/src/main/webapp/WEB-INF/http-security-basic.xml
@@ -4,7 +4,7 @@
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
- http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd">
+ http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd">
diff --git a/itest/web/src/main/webapp/WEB-INF/in-memory-provider.xml b/itest/web/src/main/webapp/WEB-INF/in-memory-provider.xml
index bf4dcd8a02..df6bd53832 100644
--- a/itest/web/src/main/webapp/WEB-INF/in-memory-provider.xml
+++ b/itest/web/src/main/webapp/WEB-INF/in-memory-provider.xml
@@ -4,7 +4,7 @@
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
- http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd">
+ http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd">
diff --git a/samples/tutorial/src/main/webapp/WEB-INF/applicationContext-security.xml b/samples/tutorial/src/main/webapp/WEB-INF/applicationContext-security.xml
index 129ffb4f53..c85b8e815d 100644
--- a/samples/tutorial/src/main/webapp/WEB-INF/applicationContext-security.xml
+++ b/samples/tutorial/src/main/webapp/WEB-INF/applicationContext-security.xml
@@ -9,7 +9,9 @@
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
- http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd">
+ http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd">
+
+