瀏覽代碼

Update servlet:xml:dms to use Spring 6

Issue gh-46
Marcus Da Coregio 3 年之前
父節點
當前提交
7d80162ab9

+ 6 - 4
servlet/xml/java/dms/build.gradle

@@ -9,8 +9,8 @@ repositories {
 }
 
 dependencies {
-	implementation platform("org.springframework.security:spring-security-bom:5.6.0-SNAPSHOT")
-	implementation platform("org.springframework:spring-framework-bom:5.3.9")
+	implementation platform("org.springframework.security:spring-security-bom:6.0.0-SNAPSHOT")
+	implementation platform("org.springframework:spring-framework-bom:6.0.0-SNAPSHOT")
 	implementation platform("org.junit:junit-bom:5.7.0")
 
 	implementation 'org.springframework:spring-beans'
@@ -19,15 +19,17 @@ dependencies {
 	implementation "org.springframework.security:spring-security-acl"
 	implementation "org.springframework.security:spring-security-core"
 	implementation "org.springframework.security:spring-security-config"
-	implementation "org.thymeleaf:thymeleaf-spring5:3.0.11.RELEASE"
-	implementation 'javax.servlet:jstl:1.2'
 	implementation 'org.slf4j:slf4j-api:1.7.30'
 	implementation 'org.slf4j:slf4j-simple:1.7.30'
 
+	providedCompile "jakarta.servlet:jakarta.servlet-api:5.0.0"
+	providedCompile "org.glassfish.web:jakarta.servlet.jsp.jstl:2.0.0"
+
 	runtimeOnly 'net.sf.ehcache:ehcache:2.10.5'
 	runtimeOnly 'org.hsqldb:hsqldb:2.5.0'
 	runtimeOnly 'org.springframework:spring-context-support'
 
+	testImplementation 'org.mockito:mockito-core:3.12.4'
 	testImplementation "org.springframework:spring-test"
 	testImplementation "org.springframework.security:spring-security-test"
 	testImplementation("org.junit.jupiter:junit-jupiter-api")

+ 23 - 35
servlet/xml/java/dms/src/main/resources/applicationContext-dms-secure.xml

@@ -62,23 +62,11 @@
 
    <bean id="daoAuthenticationProvider" class="org.springframework.security.authentication.dao.DaoAuthenticationProvider">
 	  <property name="userDetailsService" ref="jdbcDaoImpl"/>
-	  <property name="userCache" ref="userCache"/>
 	  <property name="passwordEncoder">
 		<bean class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder"/>
 	  </property>
    </bean>
 
-   <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"/>
-
-   <bean id="userCacheBackend" class="org.springframework.cache.ehcache.EhCacheFactoryBean">
-	  <property name="cacheManager" ref="cacheManager"/>
-	  <property name="cacheName" value="userCache"/>
-   </bean>
-
-   <bean id="userCache" class="org.springframework.security.core.userdetails.cache.EhCacheBasedUserCache">
-	  <property name="cache" ref="userCacheBackend"/>
-   </bean>
-
    <!-- Automatically receives AuthenticationEvent messages -->
    <bean id="loggerListener" class="org.springframework.security.authentication.event.LoggerListener"/>
 
@@ -139,32 +127,32 @@
    </bean>
 
    <!-- ========= ACCESS CONTROL LIST LOOKUP MANAGER DEFINITIONS ========= -->
+	<bean id="cacheManager" class="org.springframework.cache.concurrent.ConcurrentMapCacheManager"/>
+	
+	<bean id="userCacheBackend" class="org.springframework.cache.concurrent.ConcurrentMapCache">
+		<constructor-arg name="name" value="userCache"/>
+	</bean>
 
-	<bean id="aclCache" class="org.springframework.security.acls.domain.EhCacheBasedAclCache">
+	<bean id="aclCache" class="org.springframework.security.acls.domain.SpringCacheBasedAclCache">
+		<constructor-arg name="cache" ref="userCacheBackend"/>
+		<constructor-arg>
+			<bean class="org.springframework.security.acls.domain.DefaultPermissionGrantingStrategy">
+				<constructor-arg>
+					<bean class="org.springframework.security.acls.domain.ConsoleAuditLogger"/>
+				</constructor-arg>
+			</bean>
+		</constructor-arg>
 		<constructor-arg>
-		   <bean class="org.springframework.cache.ehcache.EhCacheFactoryBean">
-			  <property name="cacheManager" ref="cacheManager"/>
-			  <property name="cacheName" value="aclCache"/>
-		   </bean>
+			<bean class="org.springframework.security.acls.domain.AclAuthorizationStrategyImpl">
+				<constructor-arg>
+					<list>
+						<bean class="org.springframework.security.core.authority.SimpleGrantedAuthority">
+							<constructor-arg value="ROLE_ACL_ADMIN"/>
+						</bean>
+					</list>
+				</constructor-arg>
+			</bean>
 		</constructor-arg>
-	<constructor-arg>
-		<bean class="org.springframework.security.acls.domain.DefaultPermissionGrantingStrategy">
-			<constructor-arg>
-				<bean class="org.springframework.security.acls.domain.ConsoleAuditLogger"/>
-			</constructor-arg>
-		</bean>
-	</constructor-arg>
-	<constructor-arg>
-		<bean class="org.springframework.security.acls.domain.AclAuthorizationStrategyImpl">
-			<constructor-arg>
-				<list>
-					<bean class="org.springframework.security.core.authority.SimpleGrantedAuthority">
-						<constructor-arg value="ROLE_ACL_ADMIN"/>
-					</bean>
-				</list>
-			</constructor-arg>
-		</bean>
-	</constructor-arg>
 	</bean>
 
 	<bean id="lookupStrategy" class="org.springframework.security.acls.jdbc.BasicLookupStrategy">