Commit 21589cee authored by Quxl's avatar Quxl

x

parent 422e9925
...@@ -77,7 +77,7 @@ public interface OAuthApi { ...@@ -77,7 +77,7 @@ public interface OAuthApi {
OAuthClientRequest oauthResponse = builder.buildQueryMessage(); OAuthClientRequest oauthResponse = builder.buildQueryMessage();
String redirectUrl = oauthResponse.getLocationUri(); String redirectUrl = oauthResponse.getLocationUri();
redirectUrl = redirectUrl.replaceAll("\\+", "%20"); redirectUrl = redirectUrl.replaceAll("\\+", "%20");
logger.debug("redirect:" + redirectUrl); logger.debug("oauth authorization url:" + redirectUrl);
return redirectUrl; return redirectUrl;
} catch (OAuthApiException e) { } catch (OAuthApiException e) {
throw e; throw e;
...@@ -89,7 +89,7 @@ public interface OAuthApi { ...@@ -89,7 +89,7 @@ public interface OAuthApi {
default void callback() { default void callback() {
try { try {
HttpServletRequest request = this.getHttpServletRequest(); HttpServletRequest request = this.getHttpServletRequest();
logger.debug("oauth callback: " + request.getRequestURI() + " " + JSON.toJSONString(request.getParameterMap())); logger.debug("oauth callback request: " + request.getRequestURI() + " " + JSON.toJSONString(request.getParameterMap()));
OAuthConfig config = this.getOAuthConfig(); OAuthConfig config = this.getOAuthConfig();
OAuthAuthzResponse oauthAuthzResponse = OAuthAuthzResponse.oauthCodeAuthzResponse(request); OAuthAuthzResponse oauthAuthzResponse = OAuthAuthzResponse.oauthCodeAuthzResponse(request);
String code = oauthAuthzResponse.getCode(); String code = oauthAuthzResponse.getCode();
...@@ -108,6 +108,7 @@ public interface OAuthApi { ...@@ -108,6 +108,7 @@ public interface OAuthApi {
String idToken = oAuthResponse.getParam("id_token"); String idToken = oAuthResponse.getParam("id_token");
String tokenType = oAuthResponse.getTokenType(); String tokenType = oAuthResponse.getTokenType();
OAuthToken token = new OAuthToken(accessToken, refreshToken, idToken, tokenType, expiresIn); OAuthToken token = new OAuthToken(accessToken, refreshToken, idToken, tokenType, expiresIn);
logger.debug("oauth callback result: " + JSON.toJSONString(token));
saveOAuthToken(token); saveOAuthToken(token);
} catch (OAuthApiException e) { } catch (OAuthApiException e) {
throw e; throw e;
...@@ -147,11 +148,9 @@ public interface OAuthApi { ...@@ -147,11 +148,9 @@ public interface OAuthApi {
builder.setClientId(config.getClientId()); builder.setClientId(config.getClientId());
builder.setClientSecret(config.getClientSecret()); builder.setClientSecret(config.getClientSecret());
OAuthClientRequest oauthClientRequest = builder.buildQueryMessage(); OAuthClientRequest oauthClientRequest = builder.buildQueryMessage();
logger.debug("oauth refresh request: " + oauthClientRequest.getLocationUri()); logger.debug("oauth refresh request: " + oauthClientRequest.getLocationUri());
logger.debug("oauth refresh headers: " + JSON.toJSONString(oauthClientRequest.getHeaders())); logger.debug("oauth refresh headers: " + JSON.toJSONString(oauthClientRequest.getHeaders()));
logger.debug("oauth refresh body: " + JSON.toJSONString(oauthClientRequest.getBody())); logger.debug("oauth refresh body: " + JSON.toJSONString(oauthClientRequest.getBody()));
OAuthClient oAuthClient = new OAuthClient(new URLConnectionClient()); OAuthClient oAuthClient = new OAuthClient(new URLConnectionClient());
OAuthJSONAccessTokenResponse oAuthResponse = oAuthClient.accessToken(oauthClientRequest, OAuth.HttpMethod.POST); OAuthJSONAccessTokenResponse oAuthResponse = oAuthClient.accessToken(oauthClientRequest, OAuth.HttpMethod.POST);
String accessToken = oAuthResponse.getAccessToken(); String accessToken = oAuthResponse.getAccessToken();
...@@ -160,7 +159,7 @@ public interface OAuthApi { ...@@ -160,7 +159,7 @@ public interface OAuthApi {
String idToken = oAuthResponse.getParam("id_token"); String idToken = oAuthResponse.getParam("id_token");
String tokenType = oAuthResponse.getTokenType(); String tokenType = oAuthResponse.getTokenType();
OAuthToken newToken = new OAuthToken(accessToken, refreshToken, idToken, tokenType, expiresIn); OAuthToken newToken = new OAuthToken(accessToken, refreshToken, idToken, tokenType, expiresIn);
logger.debug("oauth refresh:" + JSON.toJSONString(newToken)); logger.debug("oauth refresh result:" + JSON.toJSONString(newToken));
session.setAttribute(OAUTH_TOKEN_SESSION, newToken); session.setAttribute(OAUTH_TOKEN_SESSION, newToken);
} catch (OAuthApiException e) { } catch (OAuthApiException e) {
throw e; throw e;
...@@ -171,9 +170,9 @@ public interface OAuthApi { ...@@ -171,9 +170,9 @@ public interface OAuthApi {
default String doPost(String url, Map<String, String> headers, JSONObject data) { default String doPost(String url, Map<String, String> headers, JSONObject data) {
try { try {
logger.debug("oauth post: " + url); logger.debug("oauth post url: " + url);
logger.debug("oauth headers: " + JSON.toJSONString(headers)); logger.debug("oauth post headers: " + JSON.toJSONString(headers));
logger.debug("oauth data: " + data.toJSONString()); logger.debug("oauth post data: " + data.toJSONString());
String accept = "application/json"; String accept = "application/json";
String requestId = ("" + System.currentTimeMillis()); String requestId = ("" + System.currentTimeMillis());
String countryCode = System.getProperty("X-SE-IFW-CountryCode"); String countryCode = System.getProperty("X-SE-IFW-CountryCode");
...@@ -194,7 +193,7 @@ public interface OAuthApi { ...@@ -194,7 +193,7 @@ public interface OAuthApi {
clientRequest.setHeaders(headers); clientRequest.setHeaders(headers);
OAuthResourceResponse resourceResponse = oAuthClient.resource(clientRequest, "POST", OAuthResourceResponse.class); OAuthResourceResponse resourceResponse = oAuthClient.resource(clientRequest, "POST", OAuthResourceResponse.class);
String resBody = resourceResponse.getBody(); String resBody = resourceResponse.getBody();
logger.debug("oauth result: " + resBody); logger.debug("oauth post result: " + resBody);
return resBody; return resBody;
} catch (OAuthApiException e) { } catch (OAuthApiException e) {
throw e; throw e;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment