diff --git a/handling-spring-static-resources/.classpath b/handling-spring-static-resources/.classpath index 88536687a5..71a1c1e0b5 100644 --- a/handling-spring-static-resources/.classpath +++ b/handling-spring-static-resources/.classpath @@ -19,9 +19,9 @@ - + - + diff --git a/handling-spring-static-resources/pom.xml b/handling-spring-static-resources/pom.xml index 677d705932..8efacc4b28 100644 --- a/handling-spring-static-resources/pom.xml +++ b/handling-spring-static-resources/pom.xml @@ -171,33 +171,29 @@ - 1.7 + 1.8 - 4.1.5.RELEASE - 3.2.5.RELEASE + 4.2.4.RELEASE + 4.0.3.RELEASE 1.8.1 2.3.2-b01 - - 4.1.5.RELEASE - 3.2.5.RELEASE - - 4.3.10.Final - 5.1.35 - 1.7.2.RELEASE + 4.3.11.Final + 5.1.37 + 1.9.2.RELEASE - 2.5.5 + 2.6.4 1.7.13 1.1.3 - 5.1.3.Final + 5.2.2.Final 19.0 diff --git a/handling-spring-static-resources/src/main/resources/webSecurityConfig.xml b/handling-spring-static-resources/src/main/resources/webSecurityConfig.xml index 56d7f9c113..76b5015e7b 100644 --- a/handling-spring-static-resources/src/main/resources/webSecurityConfig.xml +++ b/handling-spring-static-resources/src/main/resources/webSecurityConfig.xml @@ -2,10 +2,10 @@ @@ -21,7 +21,7 @@ - + diff --git a/handling-spring-static-resources/src/main/webapp/WEB-INF/view/login.jsp b/handling-spring-static-resources/src/main/webapp/WEB-INF/view/login.jsp index 1b09f7c634..8c9f46c027 100644 --- a/handling-spring-static-resources/src/main/webapp/WEB-INF/view/login.jsp +++ b/handling-spring-static-resources/src/main/webapp/WEB-INF/view/login.jsp @@ -41,15 +41,15 @@

-
+ - + - + diff --git a/spring-security-login-and-registration/.classpath b/spring-security-login-and-registration/.classpath index 91f27076be..26981b6dd7 100644 --- a/spring-security-login-and-registration/.classpath +++ b/spring-security-login-and-registration/.classpath @@ -23,7 +23,7 @@ - + diff --git a/spring-security-login-and-registration/pom.xml b/spring-security-login-and-registration/pom.xml index ffa8be484b..9e0f15688f 100644 --- a/spring-security-login-and-registration/pom.xml +++ b/spring-security-login-and-registration/pom.xml @@ -9,67 +9,108 @@ spring-security-login-and-registration war - - org.springframework.boot - spring-boot-starter-parent - 1.2.6.RELEASE - + - + + - org.springframework.boot - spring-boot-starter-web - - - org.springframework - spring-context-support + org.springframework.security + spring-security-web + ${org.springframework.security.version} org.springframework.security spring-security-config + ${org.springframework.security.version} + + + org.springframework.security + spring-security-taglibs + ${org.springframework.security.version} - + + - org.springframework.boot - spring-boot-starter-tomcat - provided + org.springframework + spring-core + ${org.springframework.version} + + + commons-logging + commons-logging + + - org.apache.tomcat.embed - tomcat-embed-websocket - provided + org.springframework + spring-context + ${org.springframework.version} + + + org.springframework + spring-context-support + ${org.springframework.version} + + + org.springframework + spring-jdbc + ${org.springframework.version} + + + org.springframework + spring-beans + ${org.springframework.version} + + + org.springframework + spring-aop + ${org.springframework.version} + + + org.springframework + spring-tx + ${org.springframework.version} + + + org.springframework + spring-expression + ${org.springframework.version} + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} javax.servlet javax.servlet-api + ${javax.servlet.version} + provided - - javax.servlet.jsp - javax.servlet.jsp-api - ${javax.servlet.jsp-api.version} - + javax.servlet jstl + ${jstl.version} + runtime - - org.springframework.security - spring-security-taglibs - - - javax.el - el-api - 2.2 - + org.springframework spring-test + ${org.springframework.version} test @@ -77,17 +118,19 @@ org.passay passay - 1.0 + ${passay.version} org.springframework.data spring-data-jpa + ${spring-data-jpa.version} org.hibernate hibernate-entitymanager + ${hibernate.version} @@ -98,25 +141,29 @@ org.hibernate hibernate-validator + ${hibernate-validator.version} mysql mysql-connector-java + ${mysql-connector-java.version} commons-dbcp commons-dbcp + ${commons-dbcp.version} com.fasterxml.jackson.core jackson-databind + ${jackson.version} javax.mail mail - 1.4.7 + ${javax.mail.version} com.google.guava @@ -128,32 +175,51 @@ org.slf4j slf4j-api + ${org.slf4j.version} ch.qos.logback logback-classic + ${logback.version} + org.slf4j jcl-over-slf4j + ${org.slf4j.version} org.slf4j log4j-over-slf4j + ${org.slf4j.version} junit junit + ${junit.version} test - + + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + + com.jayway.restassured rest-assured - 2.4.0 + ${rest-assured.version} test @@ -163,6 +229,11 @@ + + javax.el + el-api + 2.2 + @@ -181,8 +252,8 @@ maven-compiler-plugin ${maven-compiler-plugin.version} - ${java-version} - ${java-version} + 1.8 + 1.8 @@ -192,36 +263,13 @@ ${maven-war-plugin.version} - - org.codehaus.cargo - cargo-maven2-plugin - ${cargo-maven2-plugin.version} - - true - - tomcat8x - embedded - - - - - - - 8081 - - - - - org.apache.maven.plugins maven-surefire-plugin ${maven-surefire-plugin.version} - true - **/*IntegrationTest.java - **/*LiveTest.java + @@ -229,21 +277,54 @@ + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + + + - 1.7 - 4.1.6.RELEASE + 1.8 + + + 4.2.4.RELEASE 4.0.3.RELEASE + + 4.3.11.Final + 5.2.2.Final + 5.1.37 + 1.9.2.RELEASE + + 1.7.13 1.1.3 2.3.2-b01 - + 3.0.1 + 1.2 + 1 @@ -253,6 +334,14 @@ 19.0 + 1.3 + 4.12 + 1.0 + 2.4.0 + 1.4.7 + 2.6.4 + 1.4 + 1.4.17 3.3 diff --git a/spring-security-login-and-registration/src/main/java/org/baeldung/security/CustomAuthenticationFailureHandler.java b/spring-security-login-and-registration/src/main/java/org/baeldung/security/CustomAuthenticationFailureHandler.java index e8d995e781..94440f8a89 100644 --- a/spring-security-login-and-registration/src/main/java/org/baeldung/security/CustomAuthenticationFailureHandler.java +++ b/spring-security-login-and-registration/src/main/java/org/baeldung/security/CustomAuthenticationFailureHandler.java @@ -15,7 +15,7 @@ import org.springframework.security.web.authentication.SimpleUrlAuthenticationFa import org.springframework.stereotype.Component; import org.springframework.web.servlet.LocaleResolver; -@Component +@Component("authenticationFailureHandler") public class CustomAuthenticationFailureHandler extends SimpleUrlAuthenticationFailureHandler { @Autowired diff --git a/spring-security-login-and-registration/src/main/java/org/baeldung/spring/MvcConfig.java b/spring-security-login-and-registration/src/main/java/org/baeldung/spring/MvcConfig.java index 56141d8f33..1234cde0d0 100644 --- a/spring-security-login-and-registration/src/main/java/org/baeldung/spring/MvcConfig.java +++ b/spring-security-login-and-registration/src/main/java/org/baeldung/spring/MvcConfig.java @@ -35,7 +35,7 @@ public class MvcConfig extends WebMvcConfigurerAdapter { @Override public void addViewControllers(final ViewControllerRegistry registry) { super.addViewControllers(registry); - registry.addViewController("/login.html"); + registry.addViewController("/login"); registry.addViewController("/registration.html"); registry.addViewController("/logout.html"); registry.addViewController("/homepage.html"); diff --git a/spring-security-login-and-registration/src/main/java/org/baeldung/spring/SecSecurityConfig.java b/spring-security-login-and-registration/src/main/java/org/baeldung/spring/SecSecurityConfig.java index 677ad514e5..9ae8f6e78b 100644 --- a/spring-security-login-and-registration/src/main/java/org/baeldung/spring/SecSecurityConfig.java +++ b/spring-security-login-and-registration/src/main/java/org/baeldung/spring/SecSecurityConfig.java @@ -51,7 +51,7 @@ public class SecSecurityConfig extends WebSecurityConfigurerAdapter { http .csrf().disable() .authorizeRequests() - .antMatchers("/j_spring_security_check*","/login*", "/logout*", "/signin/**", "/signup/**", + .antMatchers("/login*","/login*", "/logout*", "/signin/**", "/signup/**", "/user/registration*", "/regitrationConfirm*", "/expiredAccount*", "/registration*", "/badUser*", "/user/resendRegistrationToken*" ,"/forgetPassword*", "/user/resetPassword*", "/user/changePassword*", "/emailError*", "/resources/**","/old/user/registration*","/successRegister*").permitAll() @@ -59,14 +59,11 @@ public class SecSecurityConfig extends WebSecurityConfigurerAdapter { .anyRequest().authenticated() .and() .formLogin() - .loginPage("/login.html") - .loginProcessingUrl("/j_spring_security_check") + .loginPage("/login") .defaultSuccessUrl("/homepage.html") - .failureUrl("/login.html?error=true") + .failureUrl("/login?error=true") .successHandler(myAuthenticationSuccessHandler) .failureHandler(authenticationFailureHandler) - .usernameParameter("j_username") - .passwordParameter("j_password") .permitAll() .and() .sessionManagement() @@ -75,7 +72,6 @@ public class SecSecurityConfig extends WebSecurityConfigurerAdapter { .and() .logout() .invalidateHttpSession(false) - .logoutUrl("/j_spring_security_logout") .logoutSuccessUrl("/logout.html?logSucc=true") .deleteCookies("JSESSIONID") .permitAll(); diff --git a/spring-security-login-and-registration/src/main/resources/webSecurityConfig.xml b/spring-security-login-and-registration/src/main/resources/webSecurityConfig.xml index 3141b19142..4e67a1200f 100644 --- a/spring-security-login-and-registration/src/main/resources/webSecurityConfig.xml +++ b/spring-security-login-and-registration/src/main/resources/webSecurityConfig.xml @@ -2,7 +2,7 @@ @@ -28,10 +28,17 @@ - - - + + + + + + + + diff --git a/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/admin.jsp b/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/admin.jsp index db3d8f20ba..ad0a8231ad 100644 --- a/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/admin.jsp +++ b/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/admin.jsp @@ -15,7 +15,7 @@ "> diff --git a/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/changePassword.jsp b/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/changePassword.jsp index c5ff23287d..88836e96f5 100644 --- a/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/changePassword.jsp +++ b/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/changePassword.jsp @@ -17,7 +17,7 @@ diff --git a/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/console.jsp b/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/console.jsp index 1cf661af87..e06cdd39f0 100644 --- a/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/console.jsp +++ b/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/console.jsp @@ -13,7 +13,7 @@ "> diff --git a/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/home.jsp b/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/home.jsp index f8db1632f6..027f583d61 100644 --- a/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/home.jsp +++ b/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/home.jsp @@ -14,7 +14,7 @@ diff --git a/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/homepage.jsp b/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/homepage.jsp index 86cac0152f..af931ac66f 100644 --- a/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/homepage.jsp +++ b/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/homepage.jsp @@ -15,7 +15,7 @@ "> diff --git a/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/login.jsp b/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/login.jsp index 949b8164de..c22c3241cd 100644 --- a/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/login.jsp +++ b/spring-security-login-and-registration/src/main/webapp/WEB-INF/view/login.jsp @@ -58,18 +58,17 @@ ${SPRING_SECURITY_LAST_EXCEPTION} - | + |

- + + - +

- +

- ">"> diff --git a/spring-security-login-and-registration/src/test/java/org/baeldung/test/ChangePasswordLiveTest.java b/spring-security-login-and-registration/src/test/java/org/baeldung/test/ChangePasswordLiveTest.java index 05377d5578..3939b5685c 100644 --- a/spring-security-login-and-registration/src/test/java/org/baeldung/test/ChangePasswordLiveTest.java +++ b/spring-security-login-and-registration/src/test/java/org/baeldung/test/ChangePasswordLiveTest.java @@ -38,7 +38,7 @@ public class ChangePasswordLiveTest { @Autowired private PasswordEncoder passwordEncoder; - private final FormAuthConfig formConfig = new FormAuthConfig(URL_PREFIX + "/j_spring_security_check", "j_username", "j_password"); + private final FormAuthConfig formConfig = new FormAuthConfig(URL_PREFIX + "/login", "username", "password"); @Before public void init() {
/>