diff --git a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/opensso/controller/SSOLoginController.java b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/opensso/controller/SSOLoginController.java index 28e694770..5dd4b3156 100644 --- a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/opensso/controller/SSOLoginController.java +++ b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/opensso/controller/SSOLoginController.java @@ -12,13 +12,13 @@ import com.jero.common.system.vo.LoginUser; import com.jero.common.util.RedisUtil; import com.jero.common.util.oConvertUtils; import com.jero.modules.base.service.BaseCommonService; -import com.jero.modules.opensso.URLRequestResultUtil; import com.jero.modules.system.entity.SysDepart; import com.jero.modules.system.entity.SysUser; import com.jero.modules.system.service.ISysDepartService; import com.jero.modules.system.service.ISysDictService; import com.jero.modules.system.service.ISysLogService; import com.jero.modules.system.service.ISysUserService; +import com.jero.modules.system.util.HttpRequestUtil; import com.jero.modules.system.util.StringUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -36,7 +36,6 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; -import java.net.URLEncoder; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -104,12 +103,12 @@ public class SSOLoginController { Result result = new Result(); // 获取access_token String getAccessTokenUrl = accessTokenUrl + "?client_id=" + clientId + "&client_secret=" - + clientSecret + "&redirect_uri=" + redirectUri + "&code=" + URLEncoder.encode(code, "utf-8"); + + clientSecret + "&redirect_uri=" + redirectUri + "&code=" + code; log.info("access_token_url:" + getAccessTokenUrl); Map headerMapToken = new HashMap<>(); headerMapToken.put("Content-Type", "text/html;charset=utf-8"); -// String accessTokenResult = HttpRequestUtil.getResponseOfGET(accessTokenUrl, headerMapToken); - String accessTokenResult = URLRequestResultUtil.getProxyRequestResult(accessTokenUrl); + String accessTokenResult = HttpRequestUtil.getResponseOfGET(getAccessTokenUrl, headerMapToken); +// String accessTokenResult = URLRequestResultUtil.getProxyRequestResult(getAccessTokenUrl); log.info("获取access_token返回结果:" + accessTokenResult); // 返回结果:access_token=2.0N6OFCARTH7MRCVPSENQONSA67WGHV4FDR25TSHFCCXI6FA3NRVAA----&expires=602405 if(StringUtils.isEmpty(accessTokenResult) || !accessTokenResult.contains("access_token")){ @@ -121,12 +120,12 @@ public class SSOLoginController { //https://signin-test.nio.com/oauth2/profile?access_token=2.0N6OFCARTH7MRCVPSENQONSA67WGHV4FDR25TSHFCCXI6FA3NRVAA---- //获取登录用户 - String getProfileUrl = profileUrl + "?access_token=" + URLEncoder.encode(accessToken, "utf-8"); + String getProfileUrl = profileUrl + "?access_token=" + accessToken; log.info("profile_url:" + getProfileUrl); Map headerMapProfile = new HashMap<>(); headerMapProfile.put("Content-Type", "application/json; charset=utf-8"); -// String profileResult = HttpRequestUtil.getResponseOfGET(getProfileUrl, headerMapProfile); - String profileResult = URLRequestResultUtil.getProxyRequestResult(getProfileUrl); + String profileResult = HttpRequestUtil.getResponseOfGET(getProfileUrl, headerMapProfile); +// String profileResult = URLRequestResultUtil.getProxyRequestResult(getProfileUrl); log.info("获取profile返回结果:" + profileResult); // 返回结果:{ id: "xuetao.li3.o", attributes: [{workNo: "CW19057"},{account_id: ""},{user_name: "xuetao.li3.o"},{email: "xuetao.li3.o@nio.com"}]} JSONObject userThirdIdJson = JSONObject.parseObject(profileResult);