use of org.springframework.security.access.vote.RoleVoter in project spring-security by spring-projects.
the class PrePostSecured method setUp.
@Before
public final void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
interceptor = new AspectJMethodSecurityInterceptor();
AccessDecisionVoter[] voters = new AccessDecisionVoter[] { new RoleVoter(), new PreInvocationAuthorizationAdviceVoter(new ExpressionBasedPreInvocationAdvice()) };
adm = new AffirmativeBased(Arrays.<AccessDecisionVoter<? extends Object>>asList(voters));
interceptor.setAccessDecisionManager(adm);
interceptor.setAuthenticationManager(authman);
interceptor.setSecurityMetadataSource(new SecuredAnnotationSecurityMetadataSource());
AnnotationSecurityAspect secAspect = AnnotationSecurityAspect.aspectOf();
secAspect.setSecurityInterceptor(interceptor);
}
use of org.springframework.security.access.vote.RoleVoter in project faf-java-server by FAForever.
the class IntegrationSecurityConfig method channelSecurityInterceptor.
@Bean
public ChannelSecurityInterceptor channelSecurityInterceptor(AuthenticationManager authenticationManager) {
ChannelSecurityInterceptor channelSecurityInterceptor = new ChannelSecurityInterceptor();
channelSecurityInterceptor.setAuthenticationManager(authenticationManager);
channelSecurityInterceptor.setAccessDecisionManager(new AffirmativeBased(Collections.singletonList(new RoleVoter())));
return channelSecurityInterceptor;
}
use of org.springframework.security.access.vote.RoleVoter in project tutorials by eugenp.
the class SecurityConfig method customAccessDecisionManager.
@Bean
public AccessDecisionManager customAccessDecisionManager() {
List<AccessDecisionVoter<? extends Object>> decisionVoters = new ArrayList<>();
decisionVoters.add(new RoleVoter());
decisionVoters.add(new UsernameAccessDecisionVoter());
AccessDecisionManager accessDecisionManager = new AffirmativeBased(decisionVoters);
return accessDecisionManager;
}
use of org.springframework.security.access.vote.RoleVoter in project motech by motech.
the class SecurityRuleBuilder method addFilterSecurityInterceptor.
private void addFilterSecurityInterceptor(List<Filter> filters, MotechURLSecurityRule securityRule) {
Map<RequestMatcher, Collection<ConfigAttribute>> requestMap = new LinkedHashMap<>();
List<AccessDecisionVoter> voters = new ArrayList<>();
Collection<ConfigAttribute> configAtts = new ArrayList<>();
if (CollectionUtils.isEmpty(securityRule.getPermissionAccess()) && CollectionUtils.isEmpty(securityRule.getUserAccess())) {
configAtts.add(new SecurityConfig("IS_AUTHENTICATED_FULLY"));
AuthenticatedVoter authVoter = new AuthenticatedVoter();
voters.add(authVoter);
} else {
if (!CollectionUtils.isEmpty(securityRule.getPermissionAccess())) {
for (String permission : securityRule.getPermissionAccess()) {
configAtts.add(new SecurityConfig(permission));
}
}
if (!CollectionUtils.isEmpty(securityRule.getUserAccess())) {
for (String userAccess : securityRule.getUserAccess()) {
configAtts.add(new SecurityConfig(SecurityConfigConstants.USER_ACCESS_PREFIX + userAccess));
}
}
}
buildRequestMap(requestMap, configAtts, securityRule);
FilterInvocationSecurityMetadataSource metadataSource = new DefaultFilterInvocationSecurityMetadataSource((LinkedHashMap<RequestMatcher, Collection<ConfigAttribute>>) requestMap);
FilterSecurityInterceptor interceptor = new FilterSecurityInterceptor();
interceptor.setSecurityMetadataSource(metadataSource);
RoleVoter roleVoter = new RoleVoter();
roleVoter.setRolePrefix(SecurityConfigConstants.ROLE_ACCESS_PREFIX);
voters.add(roleVoter);
voters.add(new MotechAccessVoter());
AccessDecisionManager decisionManager = new AffirmativeBased(voters);
interceptor.setAccessDecisionManager(decisionManager);
interceptor.setAuthenticationManager(authenticationManager);
filters.add(interceptor);
}
use of org.springframework.security.access.vote.RoleVoter in project spring-security by spring-projects.
the class AnnotationSecurityAspectTests method setUp.
@BeforeEach
public final void setUp() {
MockitoAnnotations.initMocks(this);
this.interceptor = new AspectJMethodSecurityInterceptor();
AccessDecisionVoter[] voters = new AccessDecisionVoter[] { new RoleVoter(), new PreInvocationAuthorizationAdviceVoter(new ExpressionBasedPreInvocationAdvice()) };
this.adm = new AffirmativeBased(Arrays.<AccessDecisionVoter<? extends Object>>asList(voters));
this.interceptor.setAccessDecisionManager(this.adm);
this.interceptor.setAuthenticationManager(this.authman);
this.interceptor.setSecurityMetadataSource(new SecuredAnnotationSecurityMetadataSource());
AnnotationSecurityAspect secAspect = AnnotationSecurityAspect.aspectOf();
secAspect.setSecurityInterceptor(this.interceptor);
}
Aggregations