AccessDecisionVoter and AccessDecisionManager in Spring 5

Spring Boot Version: 2.0
Spring Version: 5.0.4

Facing the following issues on trying to implement AccessDecisionManager

1. When used

public class WebConfig implements WebMvcConfigurer

Issue:  uanble to override protected void configure(HttpSecurity http) throws Exception {

2. When used

public class WebConfig extends WebSecurityConfigurerAdapter {

Issue: unable to override the following

a. public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
b. public void addResourceHandlers(ResourceHandlerRegistry registry) {
c. public void addInterceptors(InterceptorRegistry registry) {

3. Throws error "java.lang.IllegalStateException: No ServletContext set" when used as below

public class WebConfig extends WebSecurityConfigurerAdapter implements WebMvcConfigurer {

URL for reference:  http://www.baeldung.com/spring-security-custom-voter

@Bean
public AccessDecisionManager accessDecisionManager() {
    List<AccessDecisionVoter<? extends Object>> decisionVoters
      = Arrays.asList(
        new WebExpressionVoter(),
        new RoleVoter(),
        new AuthenticatedVoter(),
        new MinuteBasedVoter());
    return new UnanimousBased(decisionVoters);
}

@Override
protected void configure(HttpSecurity http) throws Exception {
    http
    ...
    .anyRequest()
    .authenticated()
    .accessDecisionManager(accessDecisionManager());
}
Software ProgrammerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kyle SantosQuality AssuranceCommented:
Hi,

I am following up on your question.  Do you still need help?

If you solved the problem on your own, would you please post the solution here in case others have the same problem?

Regards,

Kyle Santos
Customer Relations
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.