BIP单点登录接口编写
This commit is contained in:
parent
2864ee5fba
commit
6530caac60
|
@ -21,13 +21,36 @@
|
|||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>${mysql-connector-java}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<dependency>
|
||||
<groupId>com.hzya.bip</groupId>
|
||||
<artifactId>pubbaseapp_nccloud_rtLevel</artifactId>
|
||||
<version>1</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/pubbaseapp_nccloud_rtLevel-1.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.hzya.bipyonyoulog</groupId>
|
||||
<artifactId>yonyoulog</artifactId>
|
||||
<version>1</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/yonyoulog.jar</systemPath>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.hzya.bcprov</groupId>
|
||||
<artifactId>bcprov</artifactId>
|
||||
<version>1</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/bcprov-jdk15on-1.57.jar</systemPath>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.hzya.DataApiSdk</groupId>
|
||||
<artifactId>DataApiSdk</artifactId>
|
||||
<version>1</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/DataApiSdk-jar-with-dependencies.jar</systemPath>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package com.hzya.frame.bip.v3.v2207.service;
|
||||
|
||||
|
||||
import com.hzya.frame.basedao.service.IBaseService;
|
||||
import com.hzya.frame.bip.v3.v2207.entity.BipTokenVo;
|
||||
import com.hzya.frame.sysnew.application.entity.SysExtensionApiEntity;
|
||||
import com.hzya.frame.web.entity.JsonResultEntity;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
|
||||
public interface IBipSsoService extends IBaseService<BipTokenVo,String>{
|
||||
/**
|
||||
*
|
||||
* @content Bip单点统一认证接口
|
||||
* @author laborer
|
||||
* @date 2024/5/30 0030 13:45
|
||||
*
|
||||
*/
|
||||
|
||||
String erpSso(String ticket)throws Exception;
|
||||
/**
|
||||
*
|
||||
* @content 此方法获取sso动态加密,heade参数动态传入
|
||||
* @author laborer
|
||||
* @date 2024/5/27 0027 11:38
|
||||
*
|
||||
*/
|
||||
SysExtensionApiEntity ssoEncrypt(SysExtensionApiEntity entity);
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
package com.hzya.frame.bip.v3.v2207.service.impl;
|
||||
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpException;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
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.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 java.util.Map;
|
||||
|
||||
|
||||
@Service(value = "BipSsoServiceImpl")
|
||||
public class BipSsoServiceImpl extends BaseService<BipTokenVo, String> implements IBipSsoService {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
private final String BASEURL = "http://hzya.ufyct.com:9955/seeyon/thirdpartyController.do?ticket=";
|
||||
private final String ESBURL = "http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface";
|
||||
/**
|
||||
*
|
||||
* @content Bip单点统一认证接口
|
||||
* @author laborer
|
||||
* @date 2024/5/30 0030 13:45
|
||||
*
|
||||
*/
|
||||
|
||||
@Override
|
||||
public String erpSso(String ticket)throws Exception {
|
||||
String result = "";
|
||||
boolean flag = true;
|
||||
logger.info("接收到致远OA认证参数的ticket:{}",ticket);
|
||||
//通过ticket获取OA用户信息
|
||||
// String usetCode = HttpUtil.get(BASEURL+ticket);
|
||||
String userCode = "yonyou";
|
||||
logger.info("获取到的OA用户信息:{}",userCode);
|
||||
String dsname = "YonBIPV3";
|
||||
String client_id = "OAREST";//第三方系统id
|
||||
StringBuffer sb = new StringBuffer();
|
||||
if(StrUtil.isNotEmpty(userCode)){
|
||||
try {
|
||||
String security = genKey(userCode,userCode + (System.currentTimeMillis() + "").substring(0, 6));
|
||||
sb.append("type=type_security&dsname="+dsname+"&usercode="+userCode+"&client_id="+client_id+"&security="+security);
|
||||
String baseUrl = "http://127.0.0.1:8888/service/genThirdPartyAccessToken?"+sb.toString();
|
||||
result = 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);
|
||||
} catch (HttpException e) {
|
||||
flag=false;
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if(flag){
|
||||
return "http://127.0.0.1:8888nccloud/resources/uap/rbac/thirdpartylogin/main/index.html?accesstoken="+result+"&redirect_uri=http://127.0.0.1:8888nccloud/resources/workbench/public/common/main/index.html#";
|
||||
}else{
|
||||
return "http://127.0.0.1:8888nccloud/resources/uap/rbac/login/main/index.html";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @content 此方法获取sso动态加密,heade参数动态传入
|
||||
* @author laborer
|
||||
* @date 2024/5/27 0027 11:38
|
||||
*
|
||||
*/
|
||||
|
||||
@Override
|
||||
public SysExtensionApiEntity ssoEncrypt(SysExtensionApiEntity entity) {
|
||||
try {
|
||||
Map<String, String> headers = entity.getHeaders();
|
||||
String userCode = headers.get("usercode");//用户编码
|
||||
String dsname = headers.get("dsname");//数据源
|
||||
String client_id = headers.get("client_id");//第三方系统id
|
||||
StringBuffer sb = new StringBuffer();
|
||||
String security = genKey(userCode,userCode + (System.currentTimeMillis() + "").substring(0, 6));
|
||||
StringBuffer querys = new StringBuffer();
|
||||
querys.append("type=type_security");
|
||||
querys.append("&dsname="+dsname);
|
||||
querys.append("&usercode="+userCode);
|
||||
querys.append("&client_id="+client_id);
|
||||
querys.append("&security="+security);
|
||||
entity.setQuerys(querys.toString());
|
||||
headers.put("Content-Type", "application/x-www-form-urlencoded");
|
||||
headers.put("userid", "admin");
|
||||
entity.setHeaders(headers);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
/**获取NCC的key*/
|
||||
private static String genKey(String userid, String key) throws Exception {
|
||||
return new Base64().encodeToString(SignatureTookKit.digestSign(userid.getBytes(), key.getBytes()));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.hzya.frame.bip.v3.v2207.util;
|
||||
|
||||
/**
|
||||
* com.hzya.frame.bip.v3.v2207.util
|
||||
*
|
||||
* @author makejava
|
||||
* @date 2024-05 -30 14:20
|
||||
*/
|
||||
|
||||
public class BipUtil {
|
||||
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
|
||||
version="4.0">
|
||||
</web-app>
|
Loading…
Reference in New Issue