From 6e716b5367960d9cff75cc2dfd818b04789578fc Mon Sep 17 00:00:00 2001 From: liyawei Date: Mon, 30 May 2022 17:45:17 +0800 Subject: [PATCH] =?UTF-8?q?opensso=E5=88=87=E6=8D=A2=E7=94=9F=E4=BA=A7?= =?UTF-8?q?=E7=8E=AF=E5=A2=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test/java/com/adc/da/ApplicationTests.java | 16 ++++++++++++++++ .../opensso/controller/SSOLoginController.java | 13 ++++++++----- .../modules/system/timer/PPSyncDataTimer.java | 4 ++-- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/jero-boot/jero-boot-center/src/test/java/com/adc/da/ApplicationTests.java b/jero-boot/jero-boot-center/src/test/java/com/adc/da/ApplicationTests.java index 6a843a224..a5e48479d 100644 --- a/jero-boot/jero-boot-center/src/test/java/com/adc/da/ApplicationTests.java +++ b/jero-boot/jero-boot-center/src/test/java/com/adc/da/ApplicationTests.java @@ -1,16 +1,32 @@ package com.adc.da; +import com.alibaba.fastjson.JSONObject; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; +import java.util.List; + @RunWith(SpringRunner.class) @SpringBootTest public class ApplicationTests { @Test public void contextLoads() { + String json = "[{\n" + + " \"id\":\"用户id111,字符串逗号拼接\",\n" + + " \"name\":\"部门id,字符串逗号拼接\",\n" + + " \"selecteddepartCodes\":\"部门code,字符串逗号拼接\"\n" + + "},"+ + "{\n" + + " \"id\":\"用户id222,字符串逗号拼接\",\n" + + " \"orgCode\":\"部门id,字符串逗号拼接\",\n" + + " \"selecteddepartCodes\":\"部门code,字符串逗号拼接\"\n" + + "}]"; + + List ooeo = JSONObject.parseArray(json, OOEO.class); + System.out.println("ok"); } } 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 828401057..99f07dbab 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 @@ -16,6 +16,7 @@ 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.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; @@ -63,6 +64,8 @@ public class SSOLoginController { //密码登录错误的最大限制次数 public static final int RETRY_LOGIN_MAX_COUNT = 5; + @Value("${opensso.authorizeUrl}") + private String authorizeUrl; @Value("${opensso.accessTokenUrl}") private String accessTokenUrl; @Value("${opensso.profileUrl}") @@ -79,7 +82,7 @@ public class SSOLoginController { @GetMapping(value = "/ssoAuth") public void ssoAuth(HttpServletRequest request, HttpServletResponse response){ String callbackUri = "http%3A%2F%2F139.9.235.66%3A8008%2Fjero-boot%2Fopensso%2Fcallback"; - String authUrl = "https://signin-test.nio.com/oauth2/authorize" +"?client_id=" + clientId + String authUrl = authorizeUrl +"?client_id=" + clientId + "&redirect_uri=" + redirectUri + "&response_type=code"; try { response.sendRedirect(authUrl); @@ -103,8 +106,8 @@ public class SSOLoginController { log.info("access_token_url:" + getAccessTokenUrl); Map headerMapToken = new HashMap<>(); headerMapToken.put("Content-Type", "text/html;charset=utf-8"); -// String accessTokenResult = HttpRequestUtil.getResponseOfGET(getAccessTokenUrl, headerMapToken); - String accessTokenResult = "access_token=2.0N6OFCARTH7MRCVPSENQONSA67WGHV4FDR25TSHFCCXI6FA3NRVAA----&expires=602405"; + String accessTokenResult = HttpRequestUtil.getResponseOfGET(getAccessTokenUrl, headerMapToken); +// String accessTokenResult = "access_token=2.0N6OFCARTH7MRCVPSENQONSA67WGHV4FDR25TSHFCCXI6FA3NRVAA----&expires=602405"; log.info("获取access_token返回结果:" + accessTokenResult); // 返回结果:access_token=2.0N6OFCARTH7MRCVPSENQONSA67WGHV4FDR25TSHFCCXI6FA3NRVAA----&expires=602405 if(StringUtils.isEmpty(accessTokenResult) || !accessTokenResult.contains("access_token")){ @@ -120,8 +123,8 @@ public class SSOLoginController { 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 = "{ id: \"chengjun.wang.o\", attributes: [{workNo: \"\"},{account_id: \"\"},{user_name: \"chengjun.wang.o\"},{email: \"chengjun.wang.o@nio.com\"}]}"; + String profileResult = HttpRequestUtil.getResponseOfGET(getProfileUrl, headerMapProfile); +// String profileResult = "{ id: \"chengjun.wang.o\", attributes: [{workNo: \"\"},{account_id: \"\"},{user_name: \"chengjun.wang.o\"},{email: \"chengjun.wang.o@nio.com\"}]}"; log.info("获取profile返回结果:" + profileResult); // 返回结果:{ id: "chengjun.wang.o", attributes: [{workNo: ""},{account_id: ""},{user_name: "chengjun.wang.o"},{email: "chengjun.wang.o@nio.com"}]} JSONObject userThirdIdJson = JSONObject.parseObject(profileResult); diff --git a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/timer/PPSyncDataTimer.java b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/timer/PPSyncDataTimer.java index b67b9da3d..bd3ccc583 100644 --- a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/timer/PPSyncDataTimer.java +++ b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/timer/PPSyncDataTimer.java @@ -29,7 +29,7 @@ public class PPSyncDataTimer { @Autowired private ISyncDataService syncDataService; -// @Scheduled(cron = "0 10 0 * * ?") //每天凌晨0点10分执行 + @Scheduled(cron = "0 10 0 * * ?") //每天凌晨0点10分执行 public void syncDepartInfo() { if (isOpen) { log.info("<======================================启动同步部门信息======================================>"); @@ -47,7 +47,7 @@ public class PPSyncDataTimer { } } -// @Scheduled(cron = "0 10 1 * * ?") //每天凌晨1点10分执行 + @Scheduled(cron = "0 10 1 * * ?") //每天凌晨1点10分执行 public void syncUserInfo() { log.info("<======================================启动同步用户信息=======================================>"); if (isOpen) {