use of org.springframework.integration.security.MockAuthenticationManager in project spring-integration by spring-projects.
the class ChannelSecurityInterceptorTests method createInterceptor.
@SuppressWarnings("rawtypes")
private static ChannelSecurityInterceptor createInterceptor(String role) throws Exception {
ChannelSecurityMetadataSource securityMetadataSource = new ChannelSecurityMetadataSource();
securityMetadataSource.addPatternMapping(Pattern.compile("secured.*"), new DefaultChannelAccessPolicy(role, null));
ChannelSecurityInterceptor interceptor = new ChannelSecurityInterceptor(securityMetadataSource);
AffirmativeBased accessDecisionManager = AffirmativeBased.class.getConstructor(List.class).newInstance(Collections.singletonList(new RoleVoter()));
accessDecisionManager.afterPropertiesSet();
interceptor.setAccessDecisionManager(accessDecisionManager);
interceptor.setAuthenticationManager(new MockAuthenticationManager(true));
interceptor.afterPropertiesSet();
return interceptor;
}
Aggregations