Search in sources :

Example 1 with MockAuthenticationManager

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;
}
Also used : AffirmativeBased(org.springframework.security.access.vote.AffirmativeBased) MockAuthenticationManager(org.springframework.integration.security.MockAuthenticationManager) List(java.util.List) RoleVoter(org.springframework.security.access.vote.RoleVoter)

Aggregations

List (java.util.List)1 MockAuthenticationManager (org.springframework.integration.security.MockAuthenticationManager)1 AffirmativeBased (org.springframework.security.access.vote.AffirmativeBased)1 RoleVoter (org.springframework.security.access.vote.RoleVoter)1