15
15
*/
16
16
package org .springframework .security .config .annotation .web .configurers ;
17
17
18
+ import java .lang .reflect .InvocationTargetException ;
19
+ import java .util .List ;
20
+ import javax .servlet .Filter ;
21
+
18
22
import org .junit .Rule ;
19
23
import org .junit .Test ;
24
+
20
25
import org .springframework .context .annotation .Bean ;
21
26
import org .springframework .context .annotation .Configuration ;
22
27
import org .springframework .core .annotation .Order ;
31
36
import org .springframework .security .web .FilterChainProxy ;
32
37
import org .springframework .security .web .SecurityFilterChain ;
33
38
import org .springframework .security .web .access .intercept .FilterSecurityInterceptor ;
34
- import org .springframework .security .web .authentication .AbstractAuthenticationProcessingFilter ;
35
39
import org .springframework .stereotype .Component ;
36
40
37
- import javax .servlet .Filter ;
38
- import java .lang .reflect .InvocationTargetException ;
39
- import java .lang .reflect .Method ;
40
- import java .util .List ;
41
-
42
41
import static org .assertj .core .api .Java6Assertions .assertThat ;
43
42
44
43
/**
@@ -68,9 +67,11 @@ public static class WebSecurityAdapter extends WebSecurityConfigurerAdapter {
68
67
69
68
@ Override
70
69
protected void configure (HttpSecurity http ) throws Exception {
70
+ // @formatter:off
71
71
http
72
- .authorizeRequests ()
72
+ .authorizeRequests ()
73
73
.anyRequest ().hasRole ("USER" );
74
+ // @formatter:on
74
75
}
75
76
}
76
77
@@ -96,33 +97,30 @@ public void multiHttpWebSecurityConfigurerAdapterDefaultsToAutowired() throws No
96
97
assertThat (secondFilter .getAuthenticationManager ().authenticate (token )).isEqualTo (CustomAuthenticationManager .RESULT );
97
98
}
98
99
99
- private AuthenticationManager getAuthManager (AbstractAuthenticationProcessingFilter filter ) throws NoSuchMethodException , InvocationTargetException , IllegalAccessException {
100
- final Method getAuthenticationManager = filter .getClass ().getDeclaredMethod ("getAuthenticationManager" );
101
- getAuthenticationManager .setAccessible (true );
102
- return (AuthenticationManager ) getAuthenticationManager .invoke (filter );
103
- }
104
-
105
100
@ EnableWebSecurity
106
101
static class MultiWebSecurityConfigurerAdapterDefaultsAuthManagerConfig {
107
102
@ Component
108
103
@ Order (1 )
109
104
public static class ApiWebSecurityAdapter extends WebSecurityConfigurerAdapter {
110
105
@ Override
111
106
protected void configure (HttpSecurity http ) throws Exception {
112
- http
113
- .antMatcher ("/api/**" )
114
- .authorizeRequests ()
107
+ // @formatter:off
108
+ http .antMatcher ("/api/**" )
109
+ .authorizeRequests ()
115
110
.anyRequest ().hasRole ("USER" );
111
+ // @formatter:on
116
112
}
117
113
}
118
114
119
115
@ Component
120
116
public static class WebSecurityAdapter extends WebSecurityConfigurerAdapter {
121
117
@ Override
122
118
protected void configure (HttpSecurity http ) throws Exception {
119
+ // @formatter:off
123
120
http
124
- .authorizeRequests ()
121
+ .authorizeRequests ()
125
122
.anyRequest ().hasRole ("USER" );
123
+ // @formatter:on
126
124
}
127
125
}
128
126
@@ -143,7 +141,7 @@ public Authentication authenticate(Authentication authentication) throws Authent
143
141
}
144
142
}
145
143
146
- protected Filter findFilter (Class <?> filter , int index ) {
144
+ Filter findFilter (Class <?> filter , int index ) {
147
145
List <Filter > filters = filterChain (index ).getFilters ();
148
146
for (Filter it : filters ) {
149
147
if (filter .isAssignableFrom (it .getClass ())) {
0 commit comments