In the project I am working we authenticate based on role ids rather than role description and this mapping is stored in the database.
My question is, How do I remov
May be somebody need decision with annotation based for web application
@Configuration
@EnableGlobalMethodSecurity(securedEnabled = true)
protected static class GlobalSecurityConfig extends GlobalMethodSecurityConfiguration {
@Override
protected AccessDecisionManager accessDecisionManager() {
AffirmativeBased accessDecisionManager = (AffirmativeBased)super.accessDecisionManager();
for(AccessDecisionVoter voter: accessDecisionManager.getDecisionVoters()){
if(voter instanceof RoleVoter){
// do what you whant
}
}
return accessDecisionManager;
}
}
@Configuration
@EnableWebSecurity
protected static class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
@Bean
@Primary
public AccessDecisionManager accessDecisionManager() {
List> decisionVoters = Arrays.asList(
new WebExpressionVoter(),
new RoleVoter(),
new AuthenticatedVoter()
);
return new AffirmativeBased(decisionVoters);
}
}