Skip to content

Commit 1a0d627

Browse files
committed
update xml configuration
1 parent 62fd1e6 commit 1a0d627

3 files changed

Lines changed: 55 additions & 3 deletions

File tree

‎spring-security-login-and-registration/src/main/java/org/baeldung/spring/SecSecurityConfig.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
@Configuration
2020
@ComponentScan(basePackages = { "org.baeldung.security" })
21+
// @ImportResource({ "classpath:webSecurityConfig.xml" })
2122
@EnableWebSecurity
2223
public class SecSecurityConfig extends WebSecurityConfigurerAdapter {
2324

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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"
3+
xsi:schemaLocation="
4+
http://www.springframework.org/schema/security
5+
http://www.springframework.org/schema/security/spring-security.xsd
6+
http://www.springframework.org/schema/beans
7+
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd"
8+
>
9+
10+
<http use-expressions="true">
11+
<intercept-url pattern="/login*" access="permitAll" />
12+
<intercept-url pattern="/logout*" access="permitAll" />
13+
<intercept-url pattern="/signin/**" access="permitAll" />
14+
<intercept-url pattern="/signup/**" access="permitAll" />
15+
<intercept-url pattern="/user/registration*" access="permitAll" />
16+
<intercept-url pattern="/regitrationConfirm*" access="permitAll" />
17+
<intercept-url pattern="/expiredAccount*" access="permitAll" />
18+
<intercept-url pattern="/registration*" access="permitAll" />
19+
<intercept-url pattern="/badUser*" access="permitAll" />
20+
<intercept-url pattern="/resources/**" access="permitAll" />
21+
<intercept-url pattern="/invalidSession*" access="isAnonymous()" />
22+
<intercept-url pattern="/**" access="isAuthenticated()" />
23+
<form-login login-page='/login.html'
24+
authentication-failure-url="/login.html?error=true"
25+
authentication-success-handler-ref="myAuthenticationSuccessHandler"
26+
default-target-url="/homepage.html" />
27+
<session-management invalid-session-url="/invalidSession.html"
28+
session-fixation-protection="none" />
29+
<logout invalidate-session="false" logout-success-url="/logout.html?logSucc=true"
30+
logout-url="/j_spring_security_logout" delete-cookies="JSESSIONID" />
31+
</http>
32+
33+
<beans:bean id="myAuthenticationSuccessHandler"
34+
class="org.baeldung.security.MySimpleUrlAuthenticationSuccessHandler" />
35+
36+
<authentication-manager>
37+
<authentication-provider user-service-ref="userDetailsService" />
38+
</authentication-manager>
39+
<beans:bean id="userDetailsService" class="org.baeldung.security.MyUserDetailsService" />
40+
41+
</beans:beans>

‎spring-security-login-and-registration/src/main/resources/webSecurityConfig.xml‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8"?>
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"
3-
xmlns:mvc="http://www.springframework.org/schema/mvc"
43
xsi:schemaLocation="
5-
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-4.0.xsd
6-
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd"
4+
http://www.springframework.org/schema/security
5+
http://www.springframework.org/schema/security/spring-security.xsd
6+
http://www.springframework.org/schema/beans
7+
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd"
78
>
89

910
<http use-expressions="true">
@@ -36,5 +37,14 @@
3637
<authentication-manager>
3738
<authentication-provider ref="authProvider"/>
3839
</authentication-manager>
40+
41+
<beans:bean id="authProvider" class="org.springframework.security.authentication.dao.DaoAuthenticationProvider">
42+
<beans:property name="userDetailsService" ref="userDetailsService"/>
43+
<beans:property name="passwordEncoder" ref="passwordEncoder"/>
44+
</beans:bean>
45+
46+
<beans:bean id="passwordEncoder" class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder">
47+
<beans:constructor-arg value="11"/>
48+
</beans:bean>
3949

4050
</beans:beans>

0 commit comments

Comments
 (0)