Browse Source

SEC-2119: Update to 3.2 schema and use default schema version when available

Rob Winch 12 năm trước cách đây
mục cha
commit
e8661913d1
25 tập tin đã thay đổi với 66 bổ sung34 xóa
  1. 19 3
      config/src/main/java/org/springframework/security/config/SecurityNamespaceHandler.java
  2. 2 1
      config/src/main/resources/META-INF/spring.schemas
  3. 6 6
      config/src/test/java/org/springframework/security/config/authentication/AuthenticationManagerBeanDefinitionParserTests.java
  4. 17 2
      config/src/test/java/org/springframework/security/config/util/InMemoryXmlApplicationContext.java
  5. 1 1
      config/src/test/resources/org/springframework/security/config/method/sec2136/sec2136.xml
  6. 1 1
      config/src/test/resources/org/springframework/security/util/filtertest-valid.xml
  7. 2 2
      docs/manual/src/docbook/namespace-config.xml
  8. 1 1
      itest/context/src/integration-test/resources/http-path-param-stripping-app-context.xml
  9. 1 1
      itest/context/src/integration-test/resources/protect-pointcut-performance-app-context.xml
  10. 1 1
      itest/context/src/integration-test/resources/sec-936-app-context.xml
  11. 1 1
      itest/web/src/main/webapp/WEB-INF/http-security-basic.xml
  12. 1 1
      itest/web/src/main/webapp/WEB-INF/http-security-concurrency.xml
  13. 1 1
      itest/web/src/main/webapp/WEB-INF/http-security-custom-concurrency.xml
  14. 1 1
      itest/web/src/main/webapp/WEB-INF/http-security.xml
  15. 1 1
      itest/web/src/main/webapp/WEB-INF/in-memory-provider.xml
  16. 1 1
      samples/aspectj/src/main/resources/aspectj-context.xml
  17. 1 1
      samples/cas/sample/src/main/webapp/WEB-INF/applicationContext-security.xml
  18. 1 1
      samples/contacts/src/main/resources/applicationContext-security.xml
  19. 1 1
      samples/dms/src/main/resources/applicationContext-dms-secure.xml
  20. 1 1
      samples/gae/src/main/webapp/WEB-INF/applicationContext-security.xml
  21. 1 1
      samples/jaas/src/main/resources/applicationContext-security.xml
  22. 1 1
      samples/ldap/src/main/webapp/WEB-INF/applicationContext-security.xml
  23. 1 1
      samples/openid/src/main/webapp/WEB-INF/applicationContext-security.xml
  24. 1 1
      samples/servletapi/src/main/resources/applicationContext-security.xml
  25. 1 1
      samples/tutorial/src/main/webapp/WEB-INF/applicationContext-security.xml

+ 19 - 3
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.*");
     }

+ 2 - 1
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

+ 6 - 6
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("<authentication-manager erase-credentials='false'/>", "3.1");
+        setContext("<authentication-manager erase-credentials='false'/>");
         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<AbstractAuthenticationEvent> {

+ 17 - 2
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) {

+ 1 - 1
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">

+ 1 - 1
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">
 
     <bean id="mockFilter" class="org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter"/>
 

+ 2 - 2
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">
     ...
 </beans>
   ]]></programlisting> 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">
     ...
 </beans:beans>
 ]]></programlisting> We'll assume this syntax is being used from now on in this chapter. </para>

+ 1 - 1
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">
 
     <http pattern="/secured/**">
         <intercept-url pattern="/secured/*user.html" access="ROLE_USER" />

+ 1 - 1
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">
 
     <sec:global-method-security>
         <sec:protect-pointcut expression="execution(* org.springframework.security.core.session.SessionRegistry.refreshLastRequest(..))" access="ROLE_ADMIN" />

+ 1 - 1
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">
 
     <security:authentication-manager alias="authenticationManager">
         <security:authentication-provider>

+ 1 - 1
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">
 
     <http>
         <intercept-url pattern="/**" access="ROLE_DEVELOPER,ROLE_USER" />

+ 1 - 1
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">
 
     <debug />
 

+ 1 - 1
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">
 
     <http pattern="/login.jsp" security="none" />
 

+ 1 - 1
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">
 
     <!--
        Http App Context to test form login, remember-me and concurrent session control.

+ 1 - 1
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.1.xsd">
+                        http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd">
 
     <authentication-manager alias="authenticationManager">
         <authentication-provider>

+ 1 - 1
samples/aspectj/src/main/resources/aspectj-context.xml

@@ -3,7 +3,7 @@
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:sec="http://www.springframework.org/schema/security"
     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">
 
     <sec:global-method-security secured-annotations="enabled" mode="aspectj" />
 <!--

+ 1 - 1
samples/cas/sample/src/main/webapp/WEB-INF/applicationContext-security.xml

@@ -5,7 +5,7 @@
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:context="http://www.springframework.org/schema/context"
     xmlns:util="http://www.springframework.org/schema/util"
-    xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd
+    xsi:schemaLocation="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.0.xsd
         http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

+ 1 - 1
samples/contacts/src/main/resources/applicationContext-security.xml

@@ -11,7 +11,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">
 
     <global-method-security pre-post-annotations="enabled">
         <expression-handler ref="expressionHandler"/>

+ 1 - 1
samples/dms/src/main/resources/applicationContext-dms-secure.xml

@@ -9,7 +9,7 @@
     xmlns:s="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">
 
     <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
         <property name="dataSource" ref="dataSource"/>

+ 1 - 1
samples/gae/src/main/webapp/WEB-INF/applicationContext-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.1.xsd">
+    http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd">
 
     <http pattern="/static/**" security="none" />
     <http pattern="/favicon.ico" security="none" />

+ 1 - 1
samples/jaas/src/main/resources/applicationContext-security.xml

@@ -4,7 +4,7 @@
 	xmlns:sec="http://www.springframework.org/schema/security"
 	xmlns:p="http://www.springframework.org/schema/p"
 	xmlns:util="http://www.springframework.org/schema/util"
-	xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd
+	xsi:schemaLocation="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.0.xsd
 		http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">
 

+ 1 - 1
samples/ldap/src/main/webapp/WEB-INF/applicationContext-security.xml

@@ -2,7 +2,7 @@
     xmlns:s="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">
 
     <s:http>
         <s:intercept-url pattern="/secure/extreme/**" access="ROLE_SUPERVISOR"/>

+ 1 - 1
samples/openid/src/main/webapp/WEB-INF/applicationContext-security.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">
 
     <http pattern="/openidlogin.jsp*" security="none" />
     <http pattern="/images/*" security="none" />

+ 1 - 1
samples/servletapi/src/main/resources/applicationContext-security.xml

@@ -4,7 +4,7 @@
   xmlns="http://www.springframework.org/schema/security"
   xmlns:p="http://www.springframework.org/schema/p"
   xmlns:util="http://www.springframework.org/schema/util"
-  xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd
+  xsi:schemaLocation="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.0.xsd
     http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">
 

+ 1 - 1
samples/tutorial/src/main/webapp/WEB-INF/applicationContext-security.xml

@@ -9,7 +9,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">
 
     <debug />