diff --git a/src/main/java/com/eactive/eai/authserver/custom/KjbMGOAuth2Controller.java b/src/main/java/com/eactive/eai/authserver/custom/KjbMGOAuth2Controller.java index e63949a..58e3a54 100644 --- a/src/main/java/com/eactive/eai/authserver/custom/KjbMGOAuth2Controller.java +++ b/src/main/java/com/eactive/eai/authserver/custom/KjbMGOAuth2Controller.java @@ -31,6 +31,7 @@ import org.springframework.security.oauth2.provider.endpoint.TokenEndpoint; import org.springframework.security.oauth2.provider.token.TokenEnhancer; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -63,11 +64,27 @@ public class KjbMGOAuth2Controller { private TokenIssuanceLogDAO tokenIssuanceLogDAO; - @RequestMapping(value = "/mapi/oauth2/token", method = RequestMethod.POST, produces = "application/json; charset=\"UTF-8\"") + @RequestMapping(value = "/mapi/oauth2/token", method = RequestMethod.POST, consumes = "application/json", produces = "application/json; charset=UTF-8") @ResponseBody - public ResponseEntity token(@RequestBody KjbMGOAuth2AccessTokenRequest tokenRequest, + public ResponseEntity tokenJson(@RequestBody KjbMGOAuth2AccessTokenRequest tokenRequest, HttpServletRequest request, HttpServletResponse response) { - + + return issueToken(tokenRequest, request, response); + } + + @RequestMapping(value = "/mapi/oauth2/token", method = RequestMethod.POST, consumes = "application/x-www-form-urlencoded", produces = "application/json; charset=UTF-8") + @ResponseBody + public ResponseEntity tokenForm(@RequestParam Map params, HttpServletRequest request, + HttpServletResponse response) { + + KjbMGOAuth2AccessTokenRequest tokenRequest = new KjbMGOAuth2AccessTokenRequest(); + + tokenRequest.setGrantType(params.get("grant_type")); + tokenRequest.setClientId(params.get("client_id")); + tokenRequest.setClientSecret(params.get("client_secret")); + tokenRequest.setScope(params.get("scope")); + tokenRequest.setResource(params.get("resource")); + return issueToken(tokenRequest, request, response); }