opensso切换生产环境
This commit is contained in:
@@ -1,16 +1,32 @@
|
|||||||
package com.adc.da;
|
package com.adc.da;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
public class ApplicationTests {
|
public class ApplicationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void contextLoads() {
|
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> ooeo = JSONObject.parseArray(json, OOEO.class);
|
||||||
|
System.out.println("ok");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-5
@@ -16,6 +16,7 @@ import com.jero.modules.system.entity.SysUser;
|
|||||||
import com.jero.modules.system.service.ISysDepartService;
|
import com.jero.modules.system.service.ISysDepartService;
|
||||||
import com.jero.modules.system.service.ISysDictService;
|
import com.jero.modules.system.service.ISysDictService;
|
||||||
import com.jero.modules.system.service.ISysUserService;
|
import com.jero.modules.system.service.ISysUserService;
|
||||||
|
import com.jero.modules.system.util.HttpRequestUtil;
|
||||||
import com.jero.modules.system.util.StringUtils;
|
import com.jero.modules.system.util.StringUtils;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
@@ -63,6 +64,8 @@ public class SSOLoginController {
|
|||||||
//密码登录错误的最大限制次数
|
//密码登录错误的最大限制次数
|
||||||
public static final int RETRY_LOGIN_MAX_COUNT = 5;
|
public static final int RETRY_LOGIN_MAX_COUNT = 5;
|
||||||
|
|
||||||
|
@Value("${opensso.authorizeUrl}")
|
||||||
|
private String authorizeUrl;
|
||||||
@Value("${opensso.accessTokenUrl}")
|
@Value("${opensso.accessTokenUrl}")
|
||||||
private String accessTokenUrl;
|
private String accessTokenUrl;
|
||||||
@Value("${opensso.profileUrl}")
|
@Value("${opensso.profileUrl}")
|
||||||
@@ -79,7 +82,7 @@ public class SSOLoginController {
|
|||||||
@GetMapping(value = "/ssoAuth")
|
@GetMapping(value = "/ssoAuth")
|
||||||
public void ssoAuth(HttpServletRequest request, HttpServletResponse response){
|
public void ssoAuth(HttpServletRequest request, HttpServletResponse response){
|
||||||
String callbackUri = "http%3A%2F%2F139.9.235.66%3A8008%2Fjero-boot%2Fopensso%2Fcallback";
|
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";
|
+ "&redirect_uri=" + redirectUri + "&response_type=code";
|
||||||
try {
|
try {
|
||||||
response.sendRedirect(authUrl);
|
response.sendRedirect(authUrl);
|
||||||
@@ -103,8 +106,8 @@ public class SSOLoginController {
|
|||||||
log.info("access_token_url:" + getAccessTokenUrl);
|
log.info("access_token_url:" + getAccessTokenUrl);
|
||||||
Map<String, String> headerMapToken = new HashMap<>();
|
Map<String, String> headerMapToken = new HashMap<>();
|
||||||
headerMapToken.put("Content-Type", "text/html;charset=utf-8");
|
headerMapToken.put("Content-Type", "text/html;charset=utf-8");
|
||||||
// String accessTokenResult = HttpRequestUtil.getResponseOfGET(getAccessTokenUrl, headerMapToken);
|
String accessTokenResult = HttpRequestUtil.getResponseOfGET(getAccessTokenUrl, headerMapToken);
|
||||||
String accessTokenResult = "access_token=2.0N6OFCARTH7MRCVPSENQONSA67WGHV4FDR25TSHFCCXI6FA3NRVAA----&expires=602405";
|
// String accessTokenResult = "access_token=2.0N6OFCARTH7MRCVPSENQONSA67WGHV4FDR25TSHFCCXI6FA3NRVAA----&expires=602405";
|
||||||
log.info("获取access_token返回结果:" + accessTokenResult);
|
log.info("获取access_token返回结果:" + accessTokenResult);
|
||||||
// 返回结果:access_token=2.0N6OFCARTH7MRCVPSENQONSA67WGHV4FDR25TSHFCCXI6FA3NRVAA----&expires=602405
|
// 返回结果:access_token=2.0N6OFCARTH7MRCVPSENQONSA67WGHV4FDR25TSHFCCXI6FA3NRVAA----&expires=602405
|
||||||
if(StringUtils.isEmpty(accessTokenResult) || !accessTokenResult.contains("access_token")){
|
if(StringUtils.isEmpty(accessTokenResult) || !accessTokenResult.contains("access_token")){
|
||||||
@@ -120,8 +123,8 @@ public class SSOLoginController {
|
|||||||
log.info("profile_url:" + getProfileUrl);
|
log.info("profile_url:" + getProfileUrl);
|
||||||
Map<String, String> headerMapProfile = new HashMap<>();
|
Map<String, String> headerMapProfile = new HashMap<>();
|
||||||
headerMapProfile.put("Content-Type", "application/json; charset=utf-8");
|
headerMapProfile.put("Content-Type", "application/json; charset=utf-8");
|
||||||
// String profileResult = HttpRequestUtil.getResponseOfGET(getProfileUrl, headerMapProfile);
|
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 = "{ id: \"chengjun.wang.o\", attributes: [{workNo: \"\"},{account_id: \"\"},{user_name: \"chengjun.wang.o\"},{email: \"chengjun.wang.o@nio.com\"}]}";
|
||||||
log.info("获取profile返回结果:" + profileResult);
|
log.info("获取profile返回结果:" + profileResult);
|
||||||
// 返回结果:{ id: "chengjun.wang.o", attributes: [{workNo: ""},{account_id: ""},{user_name: "chengjun.wang.o"},{email: "chengjun.wang.o@nio.com"}]}
|
// 返回结果:{ id: "chengjun.wang.o", attributes: [{workNo: ""},{account_id: ""},{user_name: "chengjun.wang.o"},{email: "chengjun.wang.o@nio.com"}]}
|
||||||
JSONObject userThirdIdJson = JSONObject.parseObject(profileResult);
|
JSONObject userThirdIdJson = JSONObject.parseObject(profileResult);
|
||||||
|
|||||||
+2
-2
@@ -29,7 +29,7 @@ public class PPSyncDataTimer {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ISyncDataService syncDataService;
|
private ISyncDataService syncDataService;
|
||||||
|
|
||||||
// @Scheduled(cron = "0 10 0 * * ?") //每天凌晨0点10分执行
|
@Scheduled(cron = "0 10 0 * * ?") //每天凌晨0点10分执行
|
||||||
public void syncDepartInfo() {
|
public void syncDepartInfo() {
|
||||||
if (isOpen) {
|
if (isOpen) {
|
||||||
log.info("<======================================启动同步部门信息======================================>");
|
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() {
|
public void syncUserInfo() {
|
||||||
log.info("<======================================启动同步用户信息=======================================>");
|
log.info("<======================================启动同步用户信息=======================================>");
|
||||||
if (isOpen) {
|
if (isOpen) {
|
||||||
|
|||||||
Reference in New Issue
Block a user