class UserController {

    @RequestMapping(value = "login", method = RequestMethod.POST)
    public LoginResponse login(@NonNull @RequestBody final LoginRequest login) throws InvalidLoginException {

        if (login.getName() == null || !userService.containsName(login.getName())
            || login.getPassword() == null || login.getPassword().isEmpty()) {
            throw new InvalidLoginException();
        }

        if (!authenticationService.userPasswordCheck(login.getName(), login.getPassword())) {
            throw new InvalidLoginException();
        }

        final UserEntity userEntity = userService.findByName(login.getName());

        return new LoginResponse(userEntity.getId().toString(), userEntity.getName(),
            authenticationService.authenticationToken(login.getName(), login.getPassword()));
    }

    @Autowired  UserController(final UserService userService, final AuthenticationService authenticationService);

}