|
@@ -20,12 +20,14 @@ public class OAuthController {
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/api/oauth2/authorize", method = RequestMethod.GET)
|
|
|
- public @ResponseBody ModelAndView Authorize(@RequestHeader HttpHeaders headers,
|
|
|
+ public ModelAndView Authorize(@RequestHeader HttpHeaders headers,
|
|
|
@RequestParam(value = "response_type", required = true) String responseType,
|
|
|
@RequestParam(value = "client_id", required = true) String clientId,
|
|
|
@RequestParam(value = "state", required = true) String state, @RequestParam(value = "scope") String scope,
|
|
|
@RequestParam(value = "redirect_uri", required = true) String redirectUri, HttpSession httpSession) {
|
|
|
|
|
|
+ logger.info("/api/oauth2/authorize");
|
|
|
+
|
|
|
ModelAndView mav = new ModelAndView();
|
|
|
|
|
|
mav.setViewName("/view/authorize.html");
|
|
@@ -33,12 +35,15 @@ public class OAuthController {
|
|
|
httpSession.setAttribute("redirectUri", redirectUri);
|
|
|
httpSession.setAttribute("state", state);
|
|
|
|
|
|
+ logger.info(httpSession.toString());
|
|
|
return mav;
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/api/oauth2/auth", method = RequestMethod.GET)
|
|
|
- public @ResponseBody RedirectView Redirect(HttpSession httpSession) {
|
|
|
+ public @ResponseBody RedirectView SendCode(HttpSession httpSession) {
|
|
|
+ logger.info("/api/oauth2/auth");
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -53,36 +58,37 @@ public class OAuthController {
|
|
|
|
|
|
}
|
|
|
|
|
|
- @RequestMapping(value = "/api/oauth2/token", method = RequestMethod.GET)
|
|
|
- public @ResponseBody RedirectView Token(HttpSession httpSession) {
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+ @RequestMapping(value = "/api/oauth2/redirect", method = RequestMethod.GET, produces = "application/json")
|
|
|
+ public @ResponseBody RedirectView RedirectTester(HttpSession httpSession,
|
|
|
+ @RequestParam(value = "code", required = false) String code) {
|
|
|
+ logger.info("/api/oauth2/redirect");
|
|
|
|
|
|
|
|
|
-
|
|
|
- String redirectUri = (String) httpSession.getAttribute("redirectUri");
|
|
|
- String code = "SampleCode";
|
|
|
- redirectUri += "?state=" + httpSession.getAttribute("state");
|
|
|
- redirectUri += "&code=" + code;
|
|
|
- logger.info(redirectUri);
|
|
|
+ String redirectUri = "http://127.0.0.1:8080/api/oauth2/token?grant_type=authorization_code&code=" + code;
|
|
|
RedirectView redirectView = new RedirectView();
|
|
|
redirectView.setUrl(redirectUri);
|
|
|
return redirectView;
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- @RequestMapping(value = "/api/oauth2/redirect", method = RequestMethod.GET, produces = "application/json")
|
|
|
+ @RequestMapping(value = "/api/oauth2/token", method = RequestMethod.GET)
|
|
|
public @ResponseBody String Token(@RequestParam(value = "grant_type", required = true) String grantType,
|
|
|
@RequestParam(value = "code", required = false) String code,
|
|
|
@RequestParam(value = "refresh_token", required = false) String refreshToken, HttpSession httpSession) {
|
|
|
|
|
|
+ logger.info("/api/oauth2/token");
|
|
|
|
|
|
|
|
|
+ logger.info(code);
|
|
|
+ logger.info(grantType);
|
|
|
String newAccessToken = "ACCESSTOKEN";
|
|
|
String newRefreshToken = "REFRESHTOKEN";
|
|
|
String tokenType = "bearer";
|
|
|
int expiresIn = 3600;
|
|
|
|
|
|
+
|
|
|
String result = "{" + "access_toke:" + newAccessToken + ", refresh_token:" + newRefreshToken + ", token_type:"
|
|
|
+ tokenType + ", expires_in:" + expiresIn + "}";
|
|
|
|