title: AuthenticationException throws with correct credentials
body: <p>I'm trying to secure a REST API with JWT and I have a problem during the sign in.</p>
  
  <p>UserService.java</p>
  
  <pre><code>private final UserRepository repository;
  private final PasswordEncoder passwordEncoder;
  private final JwtTokenProvider jwtTokenProvider;
  private final AuthenticationManager authenticationManager;
  
  @Autowired
  public UserService(UserRepository repository, PasswordEncoder passwordEncoder,
                     JwtTokenProvider jwtTokenProvider, AuthenticationManager authenticationManager) {
      this.repository = repository;
      this.passwordEncoder = passwordEncoder;
      this.jwtTokenProvider = jwtTokenProvider;
      this.authenticationManager = authenticationManager;
  }
  
  public String signin(String email, String password) {
      try {
  
          UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(email, password);
          authenticationManager.authenticate(token);
          return jwtTokenProvider.createToken(email, Collections.singletonList(ROLE_CLIENT));
      } catch (AuthenticationException e) {
          throw new CustomException("Invalid email/password supplied", HttpStatus.UNPROCESSABLE_ENTITY);
      }
  }
  
  public String signup(UsersEntity user) {
      if (!repository.existsByEmail(user.getEmail())) {
          user.setPassword(passwordEncoder.encode(user.getPassword()));
  
          repository.save(user);
          return jwtTokenProvider.createToken(user.getEmail(), Collections.singletonList(ROLE_CLIENT));
      } else {
          throw new CustomException("Email is already in use", HttpStatus.UNPROCESSABLE_ENTITY);
      }
  }
  </code></pre>
  
  <p>It successfully signs up user, but when I'm trying to login it always throws an <code>AuthenticationException</code> on <code>authenticationManager.authenticate(token);</code>.</p>
  
  <p>What m I doing wrong?</p>
  
  <p><a href="https://pastebin.com/SiRnwDfC" rel="nofollow noreferrer">Full stacktrace</a></p>