BIP单据与获取token公用方法编写
This commit is contained in:
parent
1fac2d06a3
commit
564b7b6138
|
@ -5,7 +5,7 @@ logging:
|
|||
encodings: UTF-8
|
||||
file:
|
||||
# 日志保存路径
|
||||
path: /Users/apple/Desktop/log/local
|
||||
path: /zt/log
|
||||
spring:
|
||||
flyway:
|
||||
# 启动flyway migration, 默认为true
|
||||
|
@ -16,12 +16,32 @@ spring:
|
|||
filters: stat,log4j2
|
||||
datasource:
|
||||
master:
|
||||
url: jdbc:dm://hzya.ufyct.com:9040?schema=businesscenter&zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8&compatibleMode=oracle
|
||||
username: hzyazt
|
||||
password: 62e4295b615a30dbf3b8ee96f41c820b
|
||||
url: jdbc:dm://10.75.51.82:5238?schema=businesscenter&zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8&compatibleMode=oracle
|
||||
username: businesscenter
|
||||
password: 6842568689469adad597d144ee104063
|
||||
driver-class-name: dm.jdbc.driver.DmDriver
|
||||
savefile:
|
||||
# 文件保存路径
|
||||
path: /Users/apple/Desktop/log/local
|
||||
path: /zt/file
|
||||
ax:
|
||||
url: http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface
|
||||
url: http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface
|
||||
#logging:
|
||||
# #日志级别 指定目录级别
|
||||
# level:
|
||||
# root: warn
|
||||
# encodings: UTF-8
|
||||
# file:
|
||||
# # 日志保存路径
|
||||
# path: /home/webservice/zt/log
|
||||
#spring:
|
||||
# datasource:
|
||||
# dynamic:
|
||||
# datasource:
|
||||
# master:
|
||||
# url: jdbc:mysql://hzya.ufyct.com:9014/businesscenter?serverTimezone=UTC&useUnicode=true&characterEncoding=UTF8&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowLoadLocalInfile=false&autoReconnect=true&failOverReadOnly=false&connectTimeout=30000&socketTimeout=30000&autoReconnectForPools=true
|
||||
# username: root
|
||||
# password: 62e4295b615a30dbf3b8ee96f41c820b
|
||||
# driver-class-name: com.mysql.jdbc.Driver # 3.2.0开始支持SPI可省略此配置
|
||||
#savefile:
|
||||
# # 文件保存路径
|
||||
# path: /home/webservice/zt/file
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -441,6 +441,7 @@
|
|||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>**/*.yml</include>
|
||||
<include>**/*.jar</include>
|
||||
<include>**/*.properties</include>
|
||||
<include>**/*.xml</include>
|
||||
<include>**/*.xmreport</include>
|
||||
|
@ -459,6 +460,7 @@
|
|||
<directory>src/</directory>
|
||||
<includes>
|
||||
<include>**/*.yml</include>
|
||||
<include>**/*.jar</include>
|
||||
<include>**/*.properties</include>
|
||||
<include>**/*.xml</include>
|
||||
<include>**/*.json</include>
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.hzya.frame.web.entity.JsonResultEntity;
|
|||
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
public interface IBipSsoService extends IBaseService<BipTokenVo,String>{
|
||||
/**
|
||||
|
@ -18,7 +19,7 @@ public interface IBipSsoService extends IBaseService<BipTokenVo,String>{
|
|||
*
|
||||
*/
|
||||
|
||||
String erpSso(String ticket)throws Exception;
|
||||
String erpSso( HttpServletRequest request,String ticket)throws Exception;
|
||||
/**
|
||||
*
|
||||
* @content 此方法获取sso动态加密,heade参数动态传入
|
||||
|
|
|
@ -5,15 +5,23 @@ import cn.hutool.core.util.StrUtil;
|
|||
import cn.hutool.http.HttpException;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.hzya.frame.basedao.service.impl.BaseService;
|
||||
import com.hzya.frame.bip.v3.v2207.entity.BipTokenVo;
|
||||
import com.hzya.frame.bip.v3.v2207.service.IBipSsoService;
|
||||
import com.hzya.frame.iputil.IPUtil;
|
||||
import com.hzya.frame.sysnew.application.entity.SysExtensionApiEntity;
|
||||
import nccloud.security.impl.SignatureTookKit;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.net.*;
|
||||
import java.util.Enumeration;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
|
@ -21,7 +29,7 @@ import java.util.Map;
|
|||
public class BipSsoServiceImpl extends BaseService<BipTokenVo, String> implements IBipSsoService {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
private final String BASEURL = "http://192.168.2.237:8099/seeyon/thirdpartyController.do?ticket=";
|
||||
private final String ESBURL = "http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface";
|
||||
private final String ESBURL = "http://127.0.0.1:9081/kangarooDataCenterV3/entranceController/externalCallInterface";
|
||||
/**
|
||||
*
|
||||
* @content Bip单点统一认证接口
|
||||
|
@ -31,46 +39,46 @@ public class BipSsoServiceImpl extends BaseService<BipTokenVo, String> implement
|
|||
*/
|
||||
|
||||
@Override
|
||||
public String erpSso(String userCode)throws Exception {
|
||||
public String erpSso(HttpServletRequest request,String userCode)throws Exception {
|
||||
logger.info("当前IP地址为"+ JSON.toJSONString(IPUtil.getIpAddress(request)));
|
||||
String result = "";
|
||||
boolean flag = true;
|
||||
// logger.info("接收到致远OA认证参数的ticket:{}",ticket);
|
||||
//通过ticket获取OA用户信息
|
||||
// String userCode = HttpUtil.get(BASEURL+ticket);
|
||||
// String userCode = "yonyou";
|
||||
logger.info("获取到的OA用户信息:{}",userCode);
|
||||
String dsname = "YonBIPV3";
|
||||
String dsname = "ycjf";
|
||||
String client_id = "OAREST";//第三方系统id
|
||||
StringBuffer sb = new StringBuffer();
|
||||
if(StrUtil.isNotEmpty(userCode)){
|
||||
try {
|
||||
logger.info("开始加密");
|
||||
String security = genKey(userCode,userCode + (System.currentTimeMillis() + "").substring(0, 6));
|
||||
logger.info("加密结束:{}",security);
|
||||
sb.append("type=type_security&dsname="+dsname+"&usercode="+userCode+"&client_id="+client_id+"&security="+security);
|
||||
String baseUrl = "http://192.168.2.85:8888/service/genThirdPartyAccessToken?"+sb.toString();
|
||||
// logger.info("请求BIPtokenbaseUrl:{}",baseUrl);
|
||||
result = result = HttpRequest.post(baseUrl)
|
||||
String baseUrl = "http://10.75.51.78:8899/service/genThirdPartyAccessToken?"+sb.toString();
|
||||
logger.info("请求BIPtokenbaseUrl:{}",baseUrl);
|
||||
result = HttpRequest.post(baseUrl)
|
||||
.header("Content-Type", "application/x-www-form-urlencoded")//头信息,多个头信息多次调用此方法即可
|
||||
.header("Content-Length", "10000")//头信息,多个头信息多次调用此方法即可
|
||||
.header("userid", "admin")//头信息,多个头信息多次调用此方法即可
|
||||
.body("{}")//表单内容
|
||||
.timeout(20000)//超时,毫秒
|
||||
.execute().body();
|
||||
// logger.info("获取到的BIPtoken信息:{}",result);
|
||||
logger.info("获取到的BIPtoken信息:{}",result);
|
||||
} catch (HttpException e) {
|
||||
flag=false;
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if(flag){
|
||||
String indexUR = "http://192.168.2.85:8888/nccloud/resources/uap/rbac/thirdpartylogin/main/index.html?accesstoken="+result+"&redirect_uri=http://192.168.2.85:8888/nccloud/resources/workbench/public/common/main/index.html#";
|
||||
String indexUR = "http://10.75.51.78:8899/nccloud/resources/uap/rbac/thirdpartylogin/main/index.html?accesstoken="+result+"&redirect_uri=http://10.75.51.78:8899/nccloud/resources/workbench/public/common/main/index.html#";
|
||||
logger.info(indexUR);
|
||||
return indexUR;
|
||||
}else{
|
||||
return "http://192.168.2.85:8888/nccloud/resources/uap/rbac/login/main/index.html";
|
||||
return "http://10.75.51.78:8899/nccloud/resources/uap/rbac/login/main/index.html";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @content 此方法获取sso动态加密,heade参数动态传入
|
||||
|
|
|
@ -67,36 +67,36 @@ public class LoginServiceImpl implements ILoginService {
|
|||
return BaseResult.getFailureMessageEntity("当前用户已停用,请先启用");
|
||||
}
|
||||
//校验当前登陆人是否有权限
|
||||
boolean flag = false;
|
||||
SysInterfaceEntity sysInterfaceEntity = (SysInterfaceEntity) interfaceCache.get("6","beanNameloginServiceinterfacNamedoLogin");
|
||||
if(sysInterfaceEntity == null || sysInterfaceEntity.getId() == null){
|
||||
return BaseResult.getFailureMessageEntity("用户无访问权限,请联系管理员");
|
||||
}
|
||||
//查询用户权限
|
||||
if(!flag){
|
||||
SysPopedomInterfaceEntity userPopedomInterfaceEntity = (SysPopedomInterfaceEntity) interfaceCache.get("4","userId"+sysUserEntity.getId()+"interfaceId"+sysInterfaceEntity.getId());
|
||||
if(userPopedomInterfaceEntity != null && userPopedomInterfaceEntity.getId() != null ){
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
// boolean flag = false;
|
||||
// SysInterfaceEntity sysInterfaceEntity = (SysInterfaceEntity) interfaceCache.get("6","beanNameloginServiceinterfacNamedoLogin");
|
||||
// if(sysInterfaceEntity == null || sysInterfaceEntity.getId() == null){
|
||||
// return BaseResult.getFailureMessageEntity("用户无访问权限,请联系管理员");
|
||||
// }
|
||||
// //查询用户权限
|
||||
// if(!flag){
|
||||
// SysPopedomInterfaceEntity userPopedomInterfaceEntity = (SysPopedomInterfaceEntity) interfaceCache.get("4","userId"+sysUserEntity.getId()+"interfaceId"+sysInterfaceEntity.getId());
|
||||
// if(userPopedomInterfaceEntity != null && userPopedomInterfaceEntity.getId() != null ){
|
||||
// flag = true;
|
||||
// }
|
||||
// }
|
||||
//查询用户角色的权限
|
||||
if(!flag){
|
||||
List<SysUserRolesEntity> userRoleMap = (List<SysUserRolesEntity>) interfaceCache.get("3",null);
|
||||
if(userRoleMap != null && userRoleMap.size() > 0){
|
||||
for (SysUserRolesEntity sysUserRolesEntity : userRoleMap) {
|
||||
if(sysUserRolesEntity.getUserId().equals(sysUserEntity.getId())){
|
||||
SysPopedomInterfaceEntity sysPopedomInterfaceEntity = (SysPopedomInterfaceEntity) interfaceCache.get("5","roleId"+sysUserRolesEntity.getRoleId()+"interfaceId"+sysInterfaceEntity.getId());
|
||||
if(sysPopedomInterfaceEntity != null && sysPopedomInterfaceEntity.getId() != null ){
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!flag){
|
||||
return BaseResult.getFailureMessageEntity("用户无访问权限,请联系管理员");
|
||||
}
|
||||
// if(!flag){
|
||||
// List<SysUserRolesEntity> userRoleMap = (List<SysUserRolesEntity>) interfaceCache.get("3",null);
|
||||
// if(userRoleMap != null && userRoleMap.size() > 0){
|
||||
// for (SysUserRolesEntity sysUserRolesEntity : userRoleMap) {
|
||||
// if(sysUserRolesEntity.getUserId().equals(sysUserEntity.getId())){
|
||||
// SysPopedomInterfaceEntity sysPopedomInterfaceEntity = (SysPopedomInterfaceEntity) interfaceCache.get("5","roleId"+sysUserRolesEntity.getRoleId()+"interfaceId"+sysInterfaceEntity.getId());
|
||||
// if(sysPopedomInterfaceEntity != null && sysPopedomInterfaceEntity.getId() != null ){
|
||||
// flag = true;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if(!flag){
|
||||
// return BaseResult.getFailureMessageEntity("用户无访问权限,请联系管理员");
|
||||
// }
|
||||
//登录
|
||||
StpUtil.login(sysUserEntity.getId());
|
||||
//获取token
|
||||
|
|
|
@ -172,10 +172,7 @@ public class EntranceController {
|
|||
@RequestMapping(value = "/erpSso")
|
||||
@ResponseBody
|
||||
public String erpSso(HttpServletRequest request,HttpServletResponse response, String ticket) throws Exception {
|
||||
String indexUrl = bipSsoService.erpSso(request,ticket);
|
||||
response.sendRedirect(indexUrl);
|
||||
// response.sendRedirect("https://www.sojson.com/aaa");
|
||||
// response.sendRedirect("http://127.0.0.1:8888/nccloud/resources/uap/rbac/login/main/index.html");
|
||||
return indexUrl;
|
||||
// response.sendRedirect(bipSsoService.erpSso(request,ticket));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue