Код: Выделить всё
@PostMapping("/login")
1) public ResponseEntity login (@RequestBody LoginDTO loginDTO) {
2) String method = "login ()";
3) logger.info("Entering, " + method);
4) Authentication authenticate = auth.authenticate(new UsernamePasswordAuthenticationToken(loginDTO.getusername(), loginDTO.getpassword())); 5) SecurityContextHolder.getContext().setAuthentication(authenticate);
6) System.out.println("Your authentication object: " + authenticate);
7) String principal = SecurityContextHolder.getContext().getAuthentication().getName();
8) System.out.println("Principal " + principal);
9) logger.debug(authenticate);
10) return new ResponseEntity ("Welcome, " + loginDTO.getusername() + "!", HttpStatus.OK); }
Подробнее здесь: https://stackoverflow.com/questions/784 ... al-is-null