File tree Expand file tree Collapse file tree
spring-security-mvc-custom Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99
1010 <parent >
1111 <groupId >com.baeldung</groupId >
12- <artifactId >parent-spring-4 </artifactId >
12+ <artifactId >parent-spring-5 </artifactId >
1313 <version >0.0.1-SNAPSHOT</version >
14- <relativePath >../parent-spring-4 </relativePath >
14+ <relativePath >../parent-spring-5 </relativePath >
1515 </parent >
1616
1717 <dependencies >
193193
194194 <properties >
195195 <!-- Spring -->
196- <org .springframework.security.version>4.2 .6.RELEASE</org .springframework.security.version>
196+ <org .springframework.security.version>5.0 .6.RELEASE</org .springframework.security.version>
197197
198198 <!-- persistence -->
199199 <hibernate .version>5.2.5.Final</hibernate .version>
200200 <mysql-connector-java .version>5.1.40</mysql-connector-java .version>
201201
202202 <!-- various -->
203- <hibernate-validator .version>5.3.3 .Final</hibernate-validator .version>
203+ <hibernate-validator .version>5.4.1 .Final</hibernate-validator .version>
204204 <javax .servlet.version>3.1.0</javax .servlet.version>
205205 <jstl .version>1.2</jstl .version>
206206
207207 <!-- util -->
208208 <guava .version>19.0</guava .version>
209209 <commons-lang3 .version>3.5</commons-lang3 .version>
210- <jackson-databind .version>2.9.1 </jackson-databind .version>
210+ <jackson-databind .version>2.9.4 </jackson-databind .version>
211211
212212 <httpclient .version>4.5.2</httpclient .version>
213213 <httpcore .version>4.4.5</httpcore .version>
214214
215- <rest-assured .version>2.9.0 </rest-assured .version>
215+ <rest-assured .version>3.0.7 </rest-assured .version>
216216
217217 <!-- Maven plugins -->
218218 <maven-war-plugin .version>2.6</maven-war-plugin .version>
Original file line number Diff line number Diff line change 1010import org .springframework .web .servlet .config .annotation .EnableWebMvc ;
1111import org .springframework .web .servlet .config .annotation .InterceptorRegistry ;
1212import org .springframework .web .servlet .config .annotation .ViewControllerRegistry ;
13- import org .springframework .web .servlet .config .annotation .WebMvcConfigurerAdapter ;
13+ import org .springframework .web .servlet .config .annotation .WebMvcConfigurer ;
1414import org .springframework .web .servlet .view .InternalResourceViewResolver ;
1515import org .springframework .web .servlet .view .JstlView ;
1616
1717@ EnableWebMvc
1818@ Configuration
1919@ ComponentScan ("org.baeldung.web.controller" )
20- public class MvcConfig extends WebMvcConfigurerAdapter {
20+ public class MvcConfig implements WebMvcConfigurer {
2121
2222 public MvcConfig () {
2323 super ();
@@ -27,8 +27,6 @@ public MvcConfig() {
2727
2828 @ Override
2929 public void addViewControllers (final ViewControllerRegistry registry ) {
30- super .addViewControllers (registry );
31-
3230 registry .addViewController ("/anonymous.html" );
3331
3432 registry .addViewController ("/login.html" );
Original file line number Diff line number Diff line change 66@ Configuration
77@ ImportResource ({ "classpath:webSecurityConfig.xml" })
88public class SecSecurityConfig {
9+
10+
911
1012 public SecSecurityConfig () {
1113 super ();
Original file line number Diff line number Diff line change 11package org .baeldung .web .controller ;
22
3+ import javax .annotation .Resource ;
34import javax .servlet .http .HttpServletRequest ;
45import javax .servlet .http .HttpSession ;
56
1819@ RequestMapping (value = "/custom" )
1920public class LoginController {
2021
21- @ Autowired
22+ @ Resource ( name = "authenticationManager" )
2223 private AuthenticationManager authManager ;
2324
2425 public LoginController () {
Original file line number Diff line number Diff line change 22<beans : beans xmlns =" http://www.springframework.org/schema/security" xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xmlns : beans =" http://www.springframework.org/schema/beans"
33 xsi : schemaLocation ="
44 http://www.springframework.org/schema/security
5- http://www.springframework.org/schema/security/spring-security-4.2 .xsd
5+ http://www.springframework.org/schema/security/spring-security.xsd
66 http://www.springframework.org/schema/beans
7- http://www.springframework.org/schema/beans/spring-beans-4.3 .xsd"
7+ http://www.springframework.org/schema/beans/spring-beans.xsd"
88>
99
1010 <http use-expressions =" true" >
2424
2525 <beans : bean id =" myAuthenticationSuccessHandler" class =" org.baeldung.security.MySimpleUrlAuthenticationSuccessHandler" />
2626
27- <authentication-manager >
27+ <authentication-manager id = " authenticationManager " >
2828 <authentication-provider >
2929 <user-service >
30- <user name =" user1" password =" user1Pass" authorities =" ROLE_USER" />
31- <user name =" admin1" password =" admin1Pass" authorities =" ROLE_ADMIN" />
30+ <user name =" user1" password =" {noop} user1Pass" authorities =" ROLE_USER" />
31+ <user name =" admin1" password =" {noop} admin1Pass" authorities =" ROLE_ADMIN" />
3232 </user-service >
3333 </authentication-provider >
3434 </authentication-manager >
You can’t perform that action at this time.
0 commit comments