From e8661913d164d5b5fd44d5805b0371f42e99c30f Mon Sep 17 00:00:00 2001 From: Rob Winch Date: Fri, 1 Mar 2013 16:27:01 -0600 Subject: [PATCH] SEC-2119: Update to 3.2 schema and use default schema version when available --- .../config/SecurityNamespaceHandler.java | 22 ++++++++++++++++--- .../main/resources/META-INF/spring.schemas | 3 ++- ...ationManagerBeanDefinitionParserTests.java | 12 +++++----- .../util/InMemoryXmlApplicationContext.java | 19 ++++++++++++++-- .../config/method/sec2136/sec2136.xml | 2 +- .../security/util/filtertest-valid.xml | 2 +- docs/manual/src/docbook/namespace-config.xml | 4 ++-- .../http-path-param-stripping-app-context.xml | 2 +- ...otect-pointcut-performance-app-context.xml | 2 +- .../resources/sec-936-app-context.xml | 2 +- .../webapp/WEB-INF/http-security-basic.xml | 2 +- .../WEB-INF/http-security-concurrency.xml | 2 +- .../http-security-custom-concurrency.xml | 2 +- .../src/main/webapp/WEB-INF/http-security.xml | 2 +- .../webapp/WEB-INF/in-memory-provider.xml | 2 +- .../src/main/resources/aspectj-context.xml | 2 +- .../WEB-INF/applicationContext-security.xml | 2 +- .../resources/applicationContext-security.xml | 2 +- .../applicationContext-dms-secure.xml | 2 +- .../WEB-INF/applicationContext-security.xml | 2 +- .../resources/applicationContext-security.xml | 2 +- .../WEB-INF/applicationContext-security.xml | 2 +- .../WEB-INF/applicationContext-security.xml | 2 +- .../resources/applicationContext-security.xml | 2 +- .../WEB-INF/applicationContext-security.xml | 2 +- 25 files changed, 66 insertions(+), 34 deletions(-) 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 41950fa219..2582d18fbe 100644 --- a/config/src/main/java/org/springframework/security/config/SecurityNamespaceHandler.java +++ b/config/src/main/java/org/springframework/security/config/SecurityNamespaceHandler.java @@ -1,5 +1,23 @@ +/* + * Copyright 2009-2013 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.security.config; +import java.util.HashMap; +import java.util.Map; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.config.BeanDefinition; @@ -28,8 +46,6 @@ import org.springframework.util.ClassUtils; import org.w3c.dom.Element; import org.w3c.dom.Node; -import java.util.*; - /** * Parses elements from the "security" namespace (http://www.springframework.org/schema/security). * @@ -180,7 +196,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\\.1.*.xsd.*") + return schemaLocation.matches("(?m).*spring-security-3\\.2.*.xsd.*") || schemaLocation.matches("(?m).*spring-security.xsd.*") || !schemaLocation.matches("(?m).*spring-security.*"); } diff --git a/config/src/main/resources/META-INF/spring.schemas b/config/src/main/resources/META-INF/spring.schemas index 4d623cd673..5c543a8c64 100644 --- a/config/src/main/resources/META-INF/spring.schemas +++ b/config/src/main/resources/META-INF/spring.schemas @@ -1,4 +1,5 @@ -http\://www.springframework.org/schema/security/spring-security.xsd=org/springframework/security/config/spring-security-3.1.xsd +http\://www.springframework.org/schema/security/spring-security.xsd=org/springframework/security/config/spring-security-3.2.xsd +http\://www.springframework.org/schema/security/spring-security-3.2.xsd=org/springframework/security/config/spring-security-3.2.xsd http\://www.springframework.org/schema/security/spring-security-3.1.xsd=org/springframework/security/config/spring-security-3.1.xsd http\://www.springframework.org/schema/security/spring-security-3.0.3.xsd=org/springframework/security/config/spring-security-3.0.3.xsd http\://www.springframework.org/schema/security/spring-security-3.0.xsd=org/springframework/security/config/spring-security-3.0.xsd 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 73d7830aa6..43c97f9b09 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.1"); + setContext(CONTEXT); assertEquals(1, appContext.getBeansOfType(AuthenticationProvider.class).size()); } @Test public void eventsArePublishedByDefault() throws Exception { - setContext(CONTEXT, "3.1"); + setContext(CONTEXT); AuthListener listener = new AuthListener(); appContext.addApplicationListener(listener); @@ -55,20 +55,20 @@ public class AuthenticationManagerBeanDefinitionParserTests { @Test public void credentialsAreClearedByDefault() throws Exception { - setContext(CONTEXT, "3.1"); + setContext(CONTEXT); ProviderManager pm = (ProviderManager) appContext.getBeansOfType(ProviderManager.class).values().toArray()[0]; assertTrue(pm.isEraseCredentialsAfterAuthentication()); } @Test public void clearCredentialsPropertyIsRespected() throws Exception { - setContext("", "3.1"); + setContext(""); ProviderManager pm = (ProviderManager) appContext.getBeansOfType(ProviderManager.class).values().toArray()[0]; assertFalse(pm.isEraseCredentialsAfterAuthentication()); } - private void setContext(String context, String version) { - appContext = new InMemoryXmlApplicationContext(context, version, null); + private void setContext(String context) { + appContext = new InMemoryXmlApplicationContext(context); } private static class AuthListener implements ApplicationListener { diff --git a/config/src/test/java/org/springframework/security/config/util/InMemoryXmlApplicationContext.java b/config/src/test/java/org/springframework/security/config/util/InMemoryXmlApplicationContext.java index b83058c0bc..053cf67f96 100644 --- a/config/src/test/java/org/springframework/security/config/util/InMemoryXmlApplicationContext.java +++ b/config/src/test/java/org/springframework/security/config/util/InMemoryXmlApplicationContext.java @@ -1,3 +1,18 @@ +/* + * Copyright 2009-2013 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.security.config.util; import org.springframework.beans.factory.support.DefaultListableBeanFactory; @@ -25,11 +40,11 @@ public class InMemoryXmlApplicationContext extends AbstractXmlApplicationContext Resource inMemoryXml; public InMemoryXmlApplicationContext(String xml) { - this(xml, "3.1", null); + this(xml, "3.2", null); } public InMemoryXmlApplicationContext(String xml, ApplicationContext parent) { - this(xml, "3.1", parent); + this(xml, "3.2", parent); } public InMemoryXmlApplicationContext(String xml, String secVersion, ApplicationContext parent) { diff --git a/config/src/test/resources/org/springframework/security/config/method/sec2136/sec2136.xml b/config/src/test/resources/org/springframework/security/config/method/sec2136/sec2136.xml index efd213362b..7258048397 100644 --- a/config/src/test/resources/org/springframework/security/config/method/sec2136/sec2136.xml +++ b/config/src/test/resources/org/springframework/security/config/method/sec2136/sec2136.xml @@ -6,7 +6,7 @@ xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:security="http://www.springframework.org/schema/security" xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd - http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd + http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.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 a2cda067c6..4aa0b0ac2c 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 @@ -24,7 +24,7 @@ xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd - http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd"> + http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd"> diff --git a/docs/manual/src/docbook/namespace-config.xml b/docs/manual/src/docbook/namespace-config.xml index 0759c12b8d..b1ca9f1584 100644 --- a/docs/manual/src/docbook/namespace-config.xml +++ b/docs/manual/src/docbook/namespace-config.xml @@ -39,7 +39,7 @@ 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.1.xsd"> + http://www.springframework.org/schema/security/spring-security.xsd"> ... ]]> In many of the examples you will see (and in the sample) applications, we @@ -54,7 +54,7 @@ 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.1.xsd"> + http://www.springframework.org/schema/security/spring-security.xsd"> ... ]]> We'll assume this syntax is being used from now on in this chapter. diff --git a/itest/context/src/integration-test/resources/http-path-param-stripping-app-context.xml b/itest/context/src/integration-test/resources/http-path-param-stripping-app-context.xml index 4ea30cfb1c..2a77740dbf 100644 --- a/itest/context/src/integration-test/resources/http-path-param-stripping-app-context.xml +++ b/itest/context/src/integration-test/resources/http-path-param-stripping-app-context.xml @@ -8,7 +8,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.1.xsd"> + http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd"> diff --git a/itest/context/src/integration-test/resources/protect-pointcut-performance-app-context.xml b/itest/context/src/integration-test/resources/protect-pointcut-performance-app-context.xml index a1cadeb00f..5da11cc959 100644 --- a/itest/context/src/integration-test/resources/protect-pointcut-performance-app-context.xml +++ b/itest/context/src/integration-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.1.xsd"> + http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd"> diff --git a/itest/context/src/integration-test/resources/sec-936-app-context.xml b/itest/context/src/integration-test/resources/sec-936-app-context.xml index 1d5c9a8bec..3ab778af80 100755 --- a/itest/context/src/integration-test/resources/sec-936-app-context.xml +++ b/itest/context/src/integration-test/resources/sec-936-app-context.xml @@ -5,7 +5,7 @@ xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd - http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd"> + http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.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 0f74a28590..5f1e0efe2c 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.1.xsd"> + http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd"> diff --git a/itest/web/src/main/webapp/WEB-INF/http-security-concurrency.xml b/itest/web/src/main/webapp/WEB-INF/http-security-concurrency.xml index cda8631376..e6dad8243f 100644 --- a/itest/web/src/main/webapp/WEB-INF/http-security-concurrency.xml +++ b/itest/web/src/main/webapp/WEB-INF/http-security-concurrency.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.1.xsd"> + http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd"> diff --git a/itest/web/src/main/webapp/WEB-INF/http-security-custom-concurrency.xml b/itest/web/src/main/webapp/WEB-INF/http-security-custom-concurrency.xml index 2177c12e09..80979621e9 100644 --- a/itest/web/src/main/webapp/WEB-INF/http-security-custom-concurrency.xml +++ b/itest/web/src/main/webapp/WEB-INF/http-security-custom-concurrency.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.1.xsd"> + http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd"> diff --git a/itest/web/src/main/webapp/WEB-INF/http-security.xml b/itest/web/src/main/webapp/WEB-INF/http-security.xml index 004c1f0ad1..90a2a7511c 100644 --- a/itest/web/src/main/webapp/WEB-INF/http-security.xml +++ b/itest/web/src/main/webapp/WEB-INF/http-security.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.1.xsd"> + http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd">