Page 470 - MDP2022-3
P. 470
import org.springframework.http.ResponseEntity;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
i m p o r t
org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerB
uilder;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@Slf4j
@RestController
@RequestMapping("/api")
public class UserInfoController {
private final UserInfoService userInfoService;
private final JwtTokenProvider jwtTokenProvider;
private final JwtService jwtService;
private final AuthenticationManagerBuilder authenticationManagerBuilder;
private final MailService mailService;
public UserInfoController(
UserInfoService userInfoService,
JwtTokenProvider jwtTokenProvider,
JwtService jwtService,
AuthenticationManagerBuilder authenticationManagerBuilder,
MailService mailService
) {
this.userInfoService = userInfoService;
this.jwtTokenProvider = jwtTokenProvider;
this.jwtService = jwtService;
this.authenticationManagerBuilder = authenticationManagerBuilder;
this.mailService = mailService;
}
@RequestMapping(value = "/printAll",
method = {RequestMethod.GET, RequestMethod.POST}
)
public ResponseEntity<List<UserInfo>> printAll(){
List<UserInfo> userInfoList;
userInfoList = userInfoService.findAll();
System.out.println(userInfoList);