|
1 | | -package org.baeldung.spring; |
| 1 | +package org.baeldung.security.filter.configuration; |
2 | 2 |
|
3 | 3 | import org.baeldung.security.basic.MyBasicAuthenticationEntryPoint; |
4 | 4 | import org.baeldung.security.filter.CustomFilter; |
5 | 5 | import org.springframework.beans.factory.annotation.Autowired; |
6 | | -import org.springframework.context.annotation.ComponentScan; |
7 | 6 | import org.springframework.context.annotation.Configuration; |
8 | 7 | import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; |
9 | 8 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; |
|
13 | 12 |
|
14 | 13 | @Configuration |
15 | 14 | @EnableWebSecurity |
16 | | -@ComponentScan("org.baeldung.security") |
17 | | -public class SecSecurityConfigJava extends WebSecurityConfigurerAdapter { |
| 15 | +public class CustomWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter { |
18 | 16 | @Autowired |
19 | 17 | private MyBasicAuthenticationEntryPoint authenticationEntryPoint; |
20 | 18 |
|
21 | 19 | @Autowired |
22 | | - public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { |
| 20 | + public void configureGlobal(AuthenticationManagerBuilder auth) |
| 21 | + throws Exception { |
23 | 22 | auth |
24 | | - .inMemoryAuthentication() |
25 | | - .withUser("user1").password("user1Pass").authorities("ROLE_USER"); |
| 23 | + .inMemoryAuthentication() |
| 24 | + .withUser("user1").password("user1Pass") |
| 25 | + .authorities("ROLE_USER"); |
26 | 26 | } |
27 | 27 |
|
28 | 28 | @Override |
29 | 29 | protected void configure(HttpSecurity http) throws Exception { |
30 | 30 | http.authorizeRequests() |
31 | | - .antMatchers("/securityNone").permitAll() |
32 | | - .anyRequest().authenticated() |
33 | | - .and() |
| 31 | + .antMatchers("/securityNone").permitAll() |
| 32 | + .anyRequest().authenticated() |
| 33 | + .and() |
34 | 34 | .httpBasic() |
35 | | - .authenticationEntryPoint(authenticationEntryPoint); |
| 35 | + .authenticationEntryPoint(authenticationEntryPoint); |
36 | 36 |
|
37 | | - http.addFilterAfter(new CustomFilter(), BasicAuthenticationFilter.class); |
| 37 | + http.addFilterAfter(new CustomFilter(), |
| 38 | + BasicAuthenticationFilter.class); |
38 | 39 | } |
39 | | - |
40 | 40 | } |
0 commit comments