I have a case where I should enable method security check

The problem is when I add @EnableGlobalMethodSecurity(prePostEnabled = true) in security config class, I get an error while creating a bean because of AuthenticationTrustResolver

This is my code hope someone helps me

@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
    @Autowired
    @Qualifier("customUserDetailsService")
    UserDetailsService userDetailsService;

    @Autowired
    PersistentTokenRepository tokenRepository;

    @Autowired
    public void configureGlobalSecurity(AuthenticationManagerBuilder auth) throws Exception {
        auth.userDetailsService(userDetailsService);
        auth.authenticationProvider(authenticationProvider());
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.
                authorizeRequests().
                antMatchers("/test/**").permitAll().
                antMatchers("/admin/**").access("hasRole('ADMIN')").
                and().formLogin().loginPage("/login").
                defaultSuccessUrl("/success-callback").
                loginProcessingUrl("/login").usernameParameter("username").passwordParameter("password").
                and().rememberMe().rememberMeParameter("remember-me").tokenRepository(tokenRepository).
                tokenValiditySeconds(86400 * 2);
    }
    @Bean
    public PasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
    }

    @Bean
    public DaoAuthenticationProvider authenticationProvider() {
        DaoAuthenticationProvider authenticationProvider = new DaoAuthenticationProvider();
        authenticationProvider.setUserDetailsService(userDetailsService);
        authenticationProvider.setPasswordEncoder(passwordEncoder());
        return authenticationProvider;
    }

    @Bean
    public PersistentTokenBasedRememberMeServices getPersistentTokenBasedRememberMeServices() {
        PersistentTokenBasedRememberMeServices tokenBasedservice = new PersistentTokenBasedRememberMeServices(
                "remember-me", userDetailsService, tokenRepository);
        return tokenBasedservice;
    }

    @Bean
    public AuthenticationTrustResolver getAuthenticationTrustResolver() {
        return new AuthenticationTrustResolverImpl();
    }

}

Comment From: eleftherias

Closing since this has been answered on StackOverflow https://stackoverflow.com/questions/45521922/getting-error-when-i-use-enableglobalmethodsecurityprepostenabled-true