|
27 | 27 |
|
28 | 28 | import java.nio.charset.Charset;
|
29 | 29 | import java.nio.charset.StandardCharsets;
|
30 |
| -import java.util.Collections; |
31 | 30 | import java.util.List;
|
32 | 31 | import java.util.Map;
|
33 | 32 |
|
|
52 | 51 | import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
|
53 | 52 | import org.springframework.integration.http.multipart.UploadedMultipartFile;
|
54 | 53 | import org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler;
|
55 |
| -import org.springframework.integration.security.channel.ChannelSecurityInterceptor; |
56 |
| -import org.springframework.integration.security.channel.SecuredChannel; |
57 | 54 | import org.springframework.messaging.Message;
|
58 | 55 | import org.springframework.messaging.MessageChannel;
|
59 | 56 | import org.springframework.messaging.PollableChannel;
|
60 | 57 | import org.springframework.messaging.support.ErrorMessage;
|
61 | 58 | import org.springframework.mock.web.MockPart;
|
62 |
| -import org.springframework.security.access.AccessDecisionManager; |
63 |
| -import org.springframework.security.access.vote.AffirmativeBased; |
64 |
| -import org.springframework.security.access.vote.RoleVoter; |
65 |
| -import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; |
| 59 | +import org.springframework.security.authorization.AuthorityAuthorizationManager; |
66 | 60 | import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
67 | 61 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
68 | 62 | import org.springframework.security.core.userdetails.User;
|
69 | 63 | import org.springframework.security.core.userdetails.UserDetailsService;
|
70 | 64 | import org.springframework.security.crypto.factory.PasswordEncoderFactories;
|
| 65 | +import org.springframework.security.messaging.access.intercept.AuthorizationChannelInterceptor; |
71 | 66 | import org.springframework.security.provisioning.InMemoryUserDetailsManager;
|
72 | 67 | import org.springframework.security.web.SecurityFilterChain;
|
73 | 68 | import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
@@ -335,9 +330,11 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
335 | 330 | }
|
336 | 331 |
|
337 | 332 | @Bean
|
338 |
| - @SecuredChannel(interceptor = "channelSecurityInterceptor", sendAccess = "ROLE_ADMIN") |
339 | 333 | public MessageChannel transformSecuredChannel() {
|
340 |
| - return new DirectChannel(); |
| 334 | + DirectChannel directChannel = new DirectChannel(); |
| 335 | + directChannel.addInterceptor( |
| 336 | + new AuthorizationChannelInterceptor(AuthorityAuthorizationManager.hasRole("ADMIN"))); |
| 337 | + return directChannel; |
341 | 338 | }
|
342 | 339 |
|
343 | 340 | @Bean
|
@@ -393,21 +390,6 @@ public MultipartResolver multipartResolver() {
|
393 | 390 | return new StandardServletMultipartResolver();
|
394 | 391 | }
|
395 | 392 |
|
396 |
| - @Bean |
397 |
| - public AccessDecisionManager accessDecisionManager() { |
398 |
| - return new AffirmativeBased(Collections.singletonList(new RoleVoter())); |
399 |
| - } |
400 |
| - |
401 |
| - @Bean |
402 |
| - public ChannelSecurityInterceptor channelSecurityInterceptor(AccessDecisionManager accessDecisionManager, |
403 |
| - AuthenticationManagerBuilder authenticationManagerBuilder) { |
404 |
| - |
405 |
| - ChannelSecurityInterceptor channelSecurityInterceptor = new ChannelSecurityInterceptor(); |
406 |
| - channelSecurityInterceptor.setAuthenticationManager(authenticationManagerBuilder.getOrBuild()); |
407 |
| - channelSecurityInterceptor.setAccessDecisionManager(accessDecisionManager); |
408 |
| - return channelSecurityInterceptor; |
409 |
| - } |
410 |
| - |
411 | 393 | @Bean
|
412 | 394 | public Validator customValidator() {
|
413 | 395 | return new TestModelValidator();
|
|
0 commit comments