Я некоторое время изучал безопасность Spring с JWT и заметил, что в каждом прочитанном уроке имя пользователя и пароль берутся, оборачиваются в UsernamePasswordAuthenticationToken и передаются в AuthenticationManager.authenticate (), что-то вроде этого:
@RequestMapping(value = "${jwt.route.authentication.path}", method = RequestMethod.POST)
public ResponseEntity<?> createAuthenticationToken(@RequestBody JwtAuthenticationRequest authenticationRequest) throws AuthenticationException {
authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(authenticationRequest.getUsername(), authenticationRequest.getPassword()));
// Reload password post-security so we can generate the token
final UserDetails userDetails = userDetailsService.loadUserByUsername(authenticationRequest.getUsername());
final String token = jwtTokenUtil.generateToken(userDetails);
// Return the token
return ResponseEntity.ok(new JwtAuthenticationResponse(token));
}
Мой вопрос: что делает метод аутентификации, почему он используется?