代码优化
This commit is contained in:
parent
d02e106ae1
commit
74d51d6bed
@ -2,33 +2,32 @@ package com.zhgd.sjmq.listener;
|
|||||||
|
|
||||||
import com.chinacreator.c2.uop.sync.receiver.UopMQMessageReceiverServiceImpl;
|
import com.chinacreator.c2.uop.sync.receiver.UopMQMessageReceiverServiceImpl;
|
||||||
import com.zhgd.sjmq.service.UopCustomMessageReceiverServiceImpl;
|
import com.zhgd.sjmq.service.UopCustomMessageReceiverServiceImpl;
|
||||||
|
import com.zhgd.xmgl.util.ProfileJudgeUtil;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import javax.annotation.PreDestroy;
|
import javax.annotation.PreDestroy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 三江用户和机构同步mq初始化
|
||||||
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
@ConditionalOnProperty(name = "spring.profiles.active",havingValue = "sjjt-gsx")
|
|
||||||
public class UopModifyMessageReceiveListener {
|
public class UopModifyMessageReceiveListener {
|
||||||
private UopMQMessageReceiverServiceImpl receiver;
|
private UopMQMessageReceiverServiceImpl receiver;
|
||||||
@Value("${spring.profiles.active}")
|
@Value("${uop_sync_mq_brokerurl:}")
|
||||||
private String activeProfile;
|
|
||||||
|
|
||||||
@Value("${uop_sync_mq_brokerurl}")
|
|
||||||
private String uop_sync_mq_brokerurl;
|
private String uop_sync_mq_brokerurl;
|
||||||
@Value("${uop_sync_mq_username}")
|
@Value("${uop_sync_mq_username:}")
|
||||||
private String uop_sync_mq_username;
|
private String uop_sync_mq_username;
|
||||||
@Value("${uop_sync_mq_password}")
|
@Value("${uop_sync_mq_password:}")
|
||||||
private String uop_sync_mq_password;
|
private String uop_sync_mq_password;
|
||||||
@Value("${c2_orguser_subscription}")
|
@Value("${c2_orguser_subscription:}")
|
||||||
private String c2_orguser_subscription;
|
private String c2_orguser_subscription;
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void start() {
|
public void start() {
|
||||||
if ("sjjt-gsx".equals(activeProfile)) {
|
if (ProfileJudgeUtil.isSjjtGsx()) {
|
||||||
if (receiver != null) {
|
if (receiver != null) {
|
||||||
receiver.stop();
|
receiver.stop();
|
||||||
}
|
}
|
||||||
@ -46,7 +45,7 @@ public class UopModifyMessageReceiveListener {
|
|||||||
|
|
||||||
@PreDestroy
|
@PreDestroy
|
||||||
public void end() {
|
public void end() {
|
||||||
if ("sjjt-gsx".equals(activeProfile)) {
|
if (ProfileJudgeUtil.isSjjtGsx()) {
|
||||||
receiver.stop();
|
receiver.stop();
|
||||||
System.out.println("关闭mq");
|
System.out.println("关闭mq");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,13 @@
|
|||||||
package com.zhgd.xmgl.modules.basicdata.controller;
|
package com.zhgd.xmgl.modules.basicdata.controller;
|
||||||
|
|
||||||
|
import com.zhgd.jeecg.common.api.vo.Result;
|
||||||
import com.zhgd.xmgl.entity.sj.TokenResponse;
|
import com.zhgd.xmgl.entity.sj.TokenResponse;
|
||||||
import com.zhgd.xmgl.util.sj.CookieUtils;
|
import com.zhgd.xmgl.util.sj.CookieUtils;
|
||||||
import com.zhgd.xmgl.util.sj.SjUnifiedAuthenticationHttpUtil;
|
import com.zhgd.xmgl.util.sj.SjUnifiedAuthenticationHttpUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.CookieValue;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
@ -20,11 +22,19 @@ import java.io.IOException;
|
|||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RequestMapping("/xmgl")
|
@RequestMapping("/xmgl/sj/unifiedAuthentication")
|
||||||
public class SjLoginController {
|
public class SjLoginController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private SjUnifiedAuthenticationHttpUtil sjUnifiedAuthenticationHttpUtil;
|
private SjUnifiedAuthenticationHttpUtil sjUnifiedAuthenticationHttpUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据code获取token
|
||||||
|
*
|
||||||
|
* @param code
|
||||||
|
* @param response
|
||||||
|
* @param request
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
@GetMapping("/getTokenByCode")
|
@GetMapping("/getTokenByCode")
|
||||||
public void getTokenByCode(@RequestParam String code, HttpServletResponse response, HttpServletRequest request) throws IOException {
|
public void getTokenByCode(@RequestParam String code, HttpServletResponse response, HttpServletRequest request) throws IOException {
|
||||||
//根据授权码获取令牌
|
//根据授权码获取令牌
|
||||||
@ -38,6 +48,13 @@ public class SjLoginController {
|
|||||||
response.sendRedirect("http://baidu.com");
|
response.sendRedirect("http://baidu.com");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登出接口
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
* @param response
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
@GetMapping("/logout")
|
@GetMapping("/logout")
|
||||||
public void logout(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
public void logout(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||||
//④清除本地请求头request里面存储的cookie:C2AT、C2RT,返回302重定向到应用页面
|
//④清除本地请求头request里面存储的cookie:C2AT、C2RT,返回302重定向到应用页面
|
||||||
@ -47,4 +64,15 @@ public class SjLoginController {
|
|||||||
//重定向到应用页面(一般为首页)
|
//重定向到应用页面(一般为首页)
|
||||||
response.sendRedirect("http://baidu.com");
|
response.sendRedirect("http://baidu.com");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据token获取用户登录信息
|
||||||
|
*
|
||||||
|
* @param c2at
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("getLoginInfoByToken")
|
||||||
|
public Result getLoginInfoByToken(@CookieValue("C2AT") String c2at) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,6 +23,7 @@ import com.zhgd.xmgl.modules.project.entity.dto.ProgressTaskPredecessorDTO;
|
|||||||
import com.zhgd.xmgl.modules.project.entity.vo.ActualProgressVO;
|
import com.zhgd.xmgl.modules.project.entity.vo.ActualProgressVO;
|
||||||
import com.zhgd.xmgl.modules.project.mapper.ProgressTaskMapper;
|
import com.zhgd.xmgl.modules.project.mapper.ProgressTaskMapper;
|
||||||
import com.zhgd.xmgl.modules.project.service.ProgressTaskService;
|
import com.zhgd.xmgl.modules.project.service.ProgressTaskService;
|
||||||
|
import com.zhgd.xmgl.util.ProfileJudgeUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.sf.mpxj.ProjectFile;
|
import net.sf.mpxj.ProjectFile;
|
||||||
import net.sf.mpxj.Relation;
|
import net.sf.mpxj.Relation;
|
||||||
@ -87,7 +88,7 @@ public class ProgressTaskServiceImpl extends ServiceImpl<ProgressTaskMapper, Pro
|
|||||||
log.info("原progressTasks:{}", JSON.toJSONString(progressTasks));
|
log.info("原progressTasks:{}", JSON.toJSONString(progressTasks));
|
||||||
progressTaskMapper.delete(Wrappers.lambdaQuery(ProgressTask.class).eq(ProgressTask::getProjectSn, projectSn));
|
progressTaskMapper.delete(Wrappers.lambdaQuery(ProgressTask.class).eq(ProgressTask::getProjectSn, projectSn));
|
||||||
|
|
||||||
if (activeProfile.equals("zjsj")) {
|
if (ProfileJudgeUtil.isZjsj()) {
|
||||||
//调用BIM同步删除数据
|
//调用BIM同步删除数据
|
||||||
List<BIMProgressTaskRqBody> deleteList = getBimTasksByProgressTasks(progressTasks);
|
List<BIMProgressTaskRqBody> deleteList = getBimTasksByProgressTasks(progressTasks);
|
||||||
if (CollUtil.isNotEmpty(deleteList)) {
|
if (CollUtil.isNotEmpty(deleteList)) {
|
||||||
@ -101,7 +102,7 @@ public class ProgressTaskServiceImpl extends ServiceImpl<ProgressTaskMapper, Pro
|
|||||||
log.info("importData的新增数据:{}", progressTaskList);
|
log.info("importData的新增数据:{}", progressTaskList);
|
||||||
if (CollUtil.isNotEmpty(progressTaskList)) {
|
if (CollUtil.isNotEmpty(progressTaskList)) {
|
||||||
progressTaskMapper.insertBatch(progressTaskList);
|
progressTaskMapper.insertBatch(progressTaskList);
|
||||||
if (activeProfile.equals("zjsj")) {
|
if (ProfileJudgeUtil.isZjsj()) {
|
||||||
//调用BIM同步添加数据
|
//调用BIM同步添加数据
|
||||||
List<BIMProgressTaskRqBody> bimProgressTaskRqBodies = getBimTasksByProgressTasks(progressTasks);
|
List<BIMProgressTaskRqBody> bimProgressTaskRqBodies = getBimTasksByProgressTasks(progressTasks);
|
||||||
if (CollUtil.isNotEmpty(bimProgressTaskRqBodies)) {
|
if (CollUtil.isNotEmpty(bimProgressTaskRqBodies)) {
|
||||||
@ -367,7 +368,7 @@ public class ProgressTaskServiceImpl extends ServiceImpl<ProgressTaskMapper, Pro
|
|||||||
setDutyUserName(progressTask);
|
setDutyUserName(progressTask);
|
||||||
progressTaskMapper.updateById(progressTask);
|
progressTaskMapper.updateById(progressTask);
|
||||||
|
|
||||||
if (activeProfile.equals("zjsj")) {
|
if (ProfileJudgeUtil.isZjsj()) {
|
||||||
//同步数据到bim,先删除再更新bim
|
//同步数据到bim,先删除再更新bim
|
||||||
if (progressTask.getParentId() != 0) {
|
if (progressTask.getParentId() != 0) {
|
||||||
ProgressTask top = progressTaskMapper.selectById(progressTask.getParentId());
|
ProgressTask top = progressTaskMapper.selectById(progressTask.getParentId());
|
||||||
@ -636,7 +637,7 @@ public class ProgressTaskServiceImpl extends ServiceImpl<ProgressTaskMapper, Pro
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void autoTaskUpdateForBim() {
|
public void autoTaskUpdateForBim() {
|
||||||
if (activeProfile.equals("zjsj")) {
|
if (ProfileJudgeUtil.isZjsj()) {
|
||||||
List<ProgressTask> progressTasks = progressTaskMapper.selectList(new LambdaQueryWrapper<>());
|
List<ProgressTask> progressTasks = progressTaskMapper.selectList(new LambdaQueryWrapper<>());
|
||||||
List<BIMProgressTaskRqBody> bimTasksByProgressTasks = getBimTasksByProgressTasks(progressTasks);
|
List<BIMProgressTaskRqBody> bimTasksByProgressTasks = getBimTasksByProgressTasks(progressTasks);
|
||||||
if (CollUtil.isNotEmpty(bimTasksByProgressTasks)) {
|
if (CollUtil.isNotEmpty(bimTasksByProgressTasks)) {
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package com.zhgd.xmgl.security;
|
|||||||
|
|
||||||
import com.zhgd.xmgl.entity.sj.JwtPayloadUserInfo;
|
import com.zhgd.xmgl.entity.sj.JwtPayloadUserInfo;
|
||||||
import com.zhgd.xmgl.entity.sj.TokenResponse;
|
import com.zhgd.xmgl.entity.sj.TokenResponse;
|
||||||
|
import com.zhgd.xmgl.util.ProfileJudgeUtil;
|
||||||
import com.zhgd.xmgl.util.sj.JwtRsaUtils;
|
import com.zhgd.xmgl.util.sj.JwtRsaUtils;
|
||||||
import com.zhgd.xmgl.util.sj.SjUnifiedAuthenticationHttpUtil;
|
import com.zhgd.xmgl.util.sj.SjUnifiedAuthenticationHttpUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -35,8 +36,6 @@ public class JwtTokenFilter extends OncePerRequestFilter {
|
|||||||
private JwtTokenProvider jwtTokenProvider;
|
private JwtTokenProvider jwtTokenProvider;
|
||||||
@Value("${security.enable}")
|
@Value("${security.enable}")
|
||||||
private boolean securityEnable;
|
private boolean securityEnable;
|
||||||
@Value("${spring.profiles.active}")
|
|
||||||
private String activeProfile;
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SjUnifiedAuthenticationHttpUtil sjUnifiedAuthenticationHttpUtil;
|
private SjUnifiedAuthenticationHttpUtil sjUnifiedAuthenticationHttpUtil;
|
||||||
|
|
||||||
@ -47,18 +46,18 @@ public class JwtTokenFilter extends OncePerRequestFilter {
|
|||||||
@Override
|
@Override
|
||||||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
|
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
|
||||||
if (securityEnable) {
|
if (securityEnable) {
|
||||||
//三江统一认证
|
//三江统一认证,3.登录:过滤器判断,回调地址获取code调用获取令牌,首页根据令牌获取登录数据信息
|
||||||
if ("sjjt-gsx".equals(activeProfile)) {
|
if (ProfileJudgeUtil.isSjjtGsx()) {
|
||||||
//try {
|
try {
|
||||||
// //验证不通过不放行
|
//验证不通过不放行
|
||||||
// boolean b = validateSjProfile(request, response, filterChain);
|
boolean b = validateSjProfile(request, response, filterChain);
|
||||||
// if (!b) {
|
if (!b) {
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
//} catch (InvalidKeySpecException e) {
|
} catch (InvalidKeySpecException e) {
|
||||||
// log.error("认证失败ex::", e);
|
log.error("认证失败ex::", e);
|
||||||
// return;
|
return;
|
||||||
//}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
validateOtherProfile(request);
|
validateOtherProfile(request);
|
||||||
@ -86,19 +85,19 @@ public class JwtTokenFilter extends OncePerRequestFilter {
|
|||||||
//C2AT的校验
|
//C2AT的校验
|
||||||
//1.判断是否过期
|
//1.判断是否过期
|
||||||
//2.令牌校验
|
//2.令牌校验
|
||||||
JwtPayloadUserInfo jwtPayloadUserInfo = null;
|
JwtPayloadUserInfo jwtPayloadUserInfo = JwtRsaUtils.verifyWithUserInfo(c2AT);
|
||||||
|
//token校验失败,先尝试刷新token,失败就重定向统一登录
|
||||||
jwtPayloadUserInfo = JwtRsaUtils.verifyWithUserInfo(c2AT);
|
|
||||||
if (jwtPayloadUserInfo == null) {
|
if (jwtPayloadUserInfo == null) {
|
||||||
String c2rt = request.getHeader("C2RT");
|
String c2rt = request.getHeader("C2RT");
|
||||||
if (StringUtils.isNotBlank(c2rt)) {
|
if (StringUtils.isNotBlank(c2rt)) {
|
||||||
//刷新token
|
//刷新token
|
||||||
TokenResponse rs = sjUnifiedAuthenticationHttpUtil.refreshToken(c2rt);
|
TokenResponse rs = sjUnifiedAuthenticationHttpUtil.refreshToken(c2rt);
|
||||||
|
//刷新token成功
|
||||||
if (rs.getErrorCode() == null) {
|
if (rs.getErrorCode() == null) {
|
||||||
response.addCookie(new Cookie("C2AT", rs.getAccess_token()));
|
response.addCookie(new Cookie("C2AT", rs.getAccess_token()));
|
||||||
response.addCookie(new Cookie("C2RT", rs.getRefresh_token()));
|
response.addCookie(new Cookie("C2RT", rs.getRefresh_token()));
|
||||||
} else {
|
} else {
|
||||||
//重定向登录页面
|
//刷新token失败,重定向登录页面
|
||||||
sjUnifiedAuthenticationHttpUtil.getCodeRedirect(response);
|
sjUnifiedAuthenticationHttpUtil.getCodeRedirect(response);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,8 @@ package com.zhgd.xmgl.util;
|
|||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 环境判断
|
* 环境判断
|
||||||
*/
|
*/
|
||||||
@ -11,12 +13,39 @@ public class ProfileJudgeUtil {
|
|||||||
@Value("${spring.profiles.active}")
|
@Value("${spring.profiles.active}")
|
||||||
private String activeProfile;
|
private String activeProfile;
|
||||||
|
|
||||||
|
private static String p;
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void setActiveProfile() {
|
||||||
|
p = activeProfile;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否金林湾生产环境
|
* 是否金林湾生产环境
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean isJlw() {
|
public static boolean isJlw() {
|
||||||
return "ljw".equals(activeProfile);
|
return "ljw".equals(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否三江本地环境
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean isSjjtGsx() {
|
||||||
|
return "sjjt-gsx".equals(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否中建四局生产环境
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean isZjsj() {
|
||||||
|
return "zjsj".equals(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,6 @@ package com.zhgd.xmgl.util.sj;
|
|||||||
|
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
|
|
||||||
import com.nimbusds.jose.JOSEException;
|
import com.nimbusds.jose.JOSEException;
|
||||||
import com.nimbusds.jose.JWSAlgorithm;
|
import com.nimbusds.jose.JWSAlgorithm;
|
||||||
import com.nimbusds.jose.JWSHeader;
|
import com.nimbusds.jose.JWSHeader;
|
||||||
@ -223,12 +222,12 @@ public class JwtRsaUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证jwt并返回用户信息
|
* 三江统一登录,验证jwt并返回用户信息
|
||||||
*
|
*
|
||||||
* @throws InvalidKeySpecException
|
* @throws InvalidKeySpecException
|
||||||
*/
|
*/
|
||||||
public static JwtPayloadUserInfo verifyWithUserInfo(String token) throws InvalidKeySpecException {
|
public static JwtPayloadUserInfo verifyWithUserInfo(String token) throws InvalidKeySpecException {
|
||||||
String publicKey = FileUtil.readString(Thread.currentThread().getContextClassLoader().getResource("auth_public_key.pem").getPath(), "UTF-8");
|
String publicKey = FileUtil.readString(Thread.currentThread().getContextClassLoader().getResource("sj/auth_public_key.pem").getPath(), "UTF-8");
|
||||||
RSAKey rsaKey = JwtRsaUtils.getRsaKey("", publicKey);
|
RSAKey rsaKey = JwtRsaUtils.getRsaKey("", publicKey);
|
||||||
|
|
||||||
// 验证并返回payload
|
// 验证并返回payload
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import cn.hutool.http.HttpUtil;
|
|||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.zhgd.xmgl.entity.sj.TokenResponse;
|
import com.zhgd.xmgl.entity.sj.TokenResponse;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
@ -12,6 +13,13 @@ import java.io.IOException;
|
|||||||
@Component
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class SjUnifiedAuthenticationHttpUtil {
|
public class SjUnifiedAuthenticationHttpUtil {
|
||||||
|
|
||||||
|
@Value("${sj.unifiedAuthentication.login.url:}")
|
||||||
|
private String sjUnifiedAuthenticationLoginUrl;
|
||||||
|
|
||||||
|
@Value("${sj.unifiedAuthentication.login.code.url:}")
|
||||||
|
private String sjUnifiedAuthenticationLoginCodeUrl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 令牌检验
|
* 令牌检验
|
||||||
*/
|
*/
|
||||||
@ -27,7 +35,7 @@ public class SjUnifiedAuthenticationHttpUtil {
|
|||||||
* 更新令牌
|
* 更新令牌
|
||||||
*/
|
*/
|
||||||
public TokenResponse refreshToken(String refresh_token) {
|
public TokenResponse refreshToken(String refresh_token) {
|
||||||
String url = "http://116.169.63.183:30913/oauth2/refresh_token?client_id=EuPYxx1mTw-0JIA47wBYww&client_secret=StDiw5ZZSby0iJeOHcGmiQ&grant_type=refresh_token&refresh_token="
|
String url = sjUnifiedAuthenticationLoginUrl + "/oauth2/refresh_token?client_id=EuPYxx1mTw-0JIA47wBYww&client_secret=StDiw5ZZSby0iJeOHcGmiQ&grant_type=refresh_token&refresh_token="
|
||||||
+ refresh_token;
|
+ refresh_token;
|
||||||
log.info("refreshToken的url:{}", url);
|
log.info("refreshToken的url:{}", url);
|
||||||
String rs = HttpUtil.get(url);
|
String rs = HttpUtil.get(url);
|
||||||
@ -40,10 +48,9 @@ public class SjUnifiedAuthenticationHttpUtil {
|
|||||||
*/
|
*/
|
||||||
public void getCodeRedirect(HttpServletResponse response) throws IOException {
|
public void getCodeRedirect(HttpServletResponse response) throws IOException {
|
||||||
//获取授权码,客户端申请授权的URI,在浏览器中以GET请求发送到认证服务器:
|
//获取授权码,客户端申请授权的URI,在浏览器中以GET请求发送到认证服务器:
|
||||||
String redirect_uri = "http://ruau8s.natappfree.cc/test/getTokenByCode";
|
String redirectLoginUrl = sjUnifiedAuthenticationLoginUrl + "/oauth2/authorize?client_id=EuPYxx1mTw-0JIA47wBYww&response_type=code" +
|
||||||
String redirectLoginUrl = "http://116.169.63.183:30913/oauth2/authorize?client_id=EuPYxx1mTw-0JIA47wBYww&response_type=code" +
|
"&redirect_uri=" + sjUnifiedAuthenticationLoginCodeUrl + "&scope=user.read";
|
||||||
"&redirect_uri=" + redirect_uri + "&scope=user.read";
|
log.info("getCode重定向的url:{}", sjUnifiedAuthenticationLoginCodeUrl);
|
||||||
log.info("getCode重定向的url:{}", redirect_uri);
|
|
||||||
// 将data数据进行响应
|
// 将data数据进行响应
|
||||||
response.sendRedirect(redirectLoginUrl);
|
response.sendRedirect(redirectLoginUrl);
|
||||||
}
|
}
|
||||||
@ -53,7 +60,7 @@ public class SjUnifiedAuthenticationHttpUtil {
|
|||||||
*/
|
*/
|
||||||
public TokenResponse getTokenByCode(String code) {
|
public TokenResponse getTokenByCode(String code) {
|
||||||
String redirect_uri = "http://ruau8s.natappfree.cc/test/getTokenByCode";
|
String redirect_uri = "http://ruau8s.natappfree.cc/test/getTokenByCode";
|
||||||
String url = "http://116.169.63.183:30913/oauth2/access_token?client_id=EuPYxx1mTw-0JIA47wBYww&client_secret=StDiw5ZZSby0iJeOHcGmiQ&grant_type=authorization_code&code="
|
String url = sjUnifiedAuthenticationLoginUrl + "/oauth2/access_token?client_id=EuPYxx1mTw-0JIA47wBYww&client_secret=StDiw5ZZSby0iJeOHcGmiQ&grant_type=authorization_code&code="
|
||||||
+ code + "&redirect_uri="
|
+ code + "&redirect_uri="
|
||||||
+ redirect_uri;
|
+ redirect_uri;
|
||||||
log.info("getTokenByCode的url:{}", url);
|
log.info("getTokenByCode的url:{}", url);
|
||||||
|
|||||||
@ -73,3 +73,11 @@ license.licensePath=C:/jxj/prod/backEnd/license/license.lic
|
|||||||
license.publicKeysStorePath=C:/jxj/prod/backEnd/license/publicCerts.keystore
|
license.publicKeysStorePath=C:/jxj/prod/backEnd/license/publicCerts.keystore
|
||||||
#\u9AD8\u652F\u6A21\u7684tcp\u670D\u52A1\u7AEF\u7684\u7AEF\u53E3\u53F7
|
#\u9AD8\u652F\u6A21\u7684tcp\u670D\u52A1\u7AEF\u7684\u7AEF\u53E3\u53F7
|
||||||
high_formwork.netty.port=15333
|
high_formwork.netty.port=15333
|
||||||
|
#\u4E09\u6C5F\u7EDF\u4E00\u767B\u5F55\u5730\u5740
|
||||||
|
sj.unifiedAuthentication.login.url=http://116.169.63.183:30913
|
||||||
|
#\u4E09\u6C5F\u7EDF\u4E00\u767B\u5F55\u6210\u529F\u8DF3\u8F6C\u540E\u63A5\u6536code\u7684\u5730\u5740
|
||||||
|
sj.unifiedAuthentication.login.code.url=http://ruau8s.natappfree.cc/test/getTokenByCode
|
||||||
|
#\u4E09\u6C5F\u7EDF\u4E00\u767B\u5F55\u6210\u529F\u540E\u8DF3\u8F6C\u81EA\u5DF1\u5E94\u7528\u7684\u5730\u5740
|
||||||
|
sj.unifiedAuthentication.application.home.url=http://baidu.com
|
||||||
|
#\u4E09\u6C5F\u7EDF\u4E00\u767B\u51FA\u5730\u5740
|
||||||
|
sj.unifiedAuthentication.logout.redirect.url=
|
||||||
6
src/main/resources/sj/auth_public_key.pem
Normal file
6
src/main/resources/sj/auth_public_key.pem
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
-----BEGIN PUBLIC KEY-----
|
||||||
|
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCufiaX7LnqAL9YNax00Gi9L/Zq
|
||||||
|
W4syUa5c0G9aJiwKc7YD2oljH78fSO+zekmKGLm3LRHvEEKooYlabispSMc0iNOt
|
||||||
|
5x+IHDwjrX+c66vl2udEh4m7OaSO0Locittt7dKQe0BbleGQt/VY2tmX3gvF4TDn
|
||||||
|
5kSYYNmRpBYTWXYqrwIDAQAB
|
||||||
|
-----END PUBLIC KEY-----
|
||||||
Loading…
x
Reference in New Issue
Block a user