class DummyAuthenticationProvider extends DaoAuthenticationProvider {

    @Override
    public Authentication authenticate(Authentication authentication) {
        UsernamePasswordAuthenticationToken usernamePasswordAuthentication;

        try {
            usernamePasswordAuthentication
                = (UsernamePasswordAuthenticationToken) super.authenticate(authentication);
        } catch (AuthenticationException exception) {
            throw new BadCredentialsException("Username or password are invalid.");
        } catch (Exception e) {
            throw new AuthenticationServiceException("A failure occurred when authenticating.", e);
        }

        String username = usernamePasswordAuthentication.getName();
        String token = authenticationService.createJwtToken(username, DUMMY_PROVIDER, null);

        TokenAuthentication tokenAuthentication = new TokenAuthentication(username, token);
        tokenAuthentication.setAuthenticated(true);
        return tokenAuthentication;
    }

    public  DummyAuthenticationProvider(BCryptPasswordEncoder encoder,
                                       @Qualifier("dummyService") UserDetailsService userDetailsService,
                                       AuthenticationService authenticationService);

}