11.8kaifa
This commit is contained in:
@@ -0,0 +1,125 @@
|
||||
package com.ruoyi.common.utils;
|
||||
|
||||
import com.ruoyi.common.config.EsignDemoConfig;
|
||||
import com.ruoyi.common.constant.EsignHeaderConstant;
|
||||
import com.ruoyi.common.core.domain.entity.EsignHttpResponse;
|
||||
import com.ruoyi.common.enums.EsignRequestType;
|
||||
import com.ruoyi.common.exception.EsignDemoException;
|
||||
import com.ruoyi.common.utils.bean.EsignFileBean;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class SealUtil {
|
||||
private static String eSignHost = EsignDemoConfig.EsignHost;
|
||||
private static String eSignAppId = EsignDemoConfig.EsignAppId;
|
||||
private static String eSignAppSecret = EsignDemoConfig.EsignAppSecret;
|
||||
|
||||
/**
|
||||
* 获取机构认证&授权页面链接
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static EsignHttpResponse getOrgEmpower() throws EsignDemoException {
|
||||
String apiaddr = "/v3/org-auth-url";
|
||||
String nickName = "何进波";
|
||||
String phonenumber = "15191509780";
|
||||
String deptName = "西安云美公司";
|
||||
String jsonParm = "{\n" +
|
||||
" \"orgAuthConfig\": {\n" +
|
||||
" \"orgName\": \"" + deptName + " \",\n" +
|
||||
" \"transactorInfo\": {\n" +
|
||||
" \"psnAccount\": \"" + phonenumber + "\",\n" +
|
||||
" \"psnInfo\": {\n" +
|
||||
" \"psnName\": \"" + nickName + "\",\n" +
|
||||
" \"psnMobile\": \"" + phonenumber + "\"\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
" \"authorizeConfig\": {\n" +
|
||||
" \"authorizedScopes\": [\n" +
|
||||
" \"get_org_identity_info\",\n" +
|
||||
" \"get_psn_identity_info\",\n" +
|
||||
" \"org_initiate_sign\",\n" +
|
||||
" \"psn_initiate_sign\",\n" +
|
||||
" \"manage_org_resource\",\n" +
|
||||
" \"manage_psn_resource\",\n" +
|
||||
" \"use_org_order\"\n" +
|
||||
" ]\n" +
|
||||
" }\n" +
|
||||
"}";
|
||||
//请求方法
|
||||
EsignRequestType requestType = EsignRequestType.POST;
|
||||
//生成请求签名鉴权方式的Header
|
||||
Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId, eSignAppSecret, jsonParm, requestType.name(), apiaddr, true);
|
||||
//发起接口请求
|
||||
return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, true);
|
||||
|
||||
}
|
||||
/**
|
||||
* 查询认证授权流程详情
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static EsignHttpResponse queryAuthProcess(String authFlowId ) throws EsignDemoException {
|
||||
String apiaddr = "/v3/auth-flow/" + authFlowId;
|
||||
//请求参数body体,json格式。get或者delete请求时jsonString传空json:"{}"或者null
|
||||
String jsonParm=null;
|
||||
//请求方法
|
||||
EsignRequestType requestType= EsignRequestType.GET;
|
||||
//生成签名鉴权方式的的header
|
||||
Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId,eSignAppSecret,jsonParm,requestType.name(),apiaddr,true);
|
||||
//发起接口请求
|
||||
return EsignHttpHelper.doCommHttp(eSignHost, apiaddr,requestType , jsonParm, header,true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 步骤一:获取印章图片上传地址fileUploadUrl
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static EsignHttpResponse getFileUploadUrl() throws EsignDemoException {
|
||||
//自定义的文件封装类,传入文件地址可以获取文件的名称大小,文件流等数据
|
||||
String filePath = "D:\\develop\\Snipaste_2023-10-27_09-59-23.jpg";
|
||||
EsignFileBean esignFileBean = new EsignFileBean(filePath);
|
||||
String apiaddr="/v3/files/file-key";
|
||||
//请求参数body体,json格式。get或者delete请求时jsonString传空json:"{}"或者null
|
||||
String jsonParm="{\n" +
|
||||
" \"contentMd5\": \""+esignFileBean.getFileContentMD5()+"\",\n" +
|
||||
" \"fileName\":\""+esignFileBean.getFileName()+"\"," +
|
||||
" \"fileSize\": "+esignFileBean.getFileSize()+",\n" +
|
||||
" \"contentType\": \""+ EsignHeaderConstant.CONTENTTYPE_STREAM.VALUE()+"\"\n" +
|
||||
"}";
|
||||
//请求方法
|
||||
EsignRequestType requestType= EsignRequestType.POST;
|
||||
//生成签名鉴权方式的的header
|
||||
Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId,eSignAppSecret,jsonParm,requestType.name(),apiaddr,true);
|
||||
//发起接口请求
|
||||
EsignHttpResponse response = EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, true);
|
||||
System.out.println(response);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 步骤二:将印章图片文件流上传到fileUploadUrl
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static EsignHttpResponse fileStreamUpload(String uploadUrl,String filePath) throws EsignDemoException {
|
||||
//根据文件地址获取文件contentMd5
|
||||
EsignFileBean esignFileBean = new EsignFileBean(filePath);
|
||||
//请求方法
|
||||
EsignRequestType requestType= EsignRequestType.PUT;
|
||||
return EsignHttpHelper.doUploadHttp(uploadUrl,requestType,esignFileBean.getFileBytes(),esignFileBean.getFileContentMD5(), EsignHeaderConstant.CONTENTTYPE_STREAM.VALUE(),true);
|
||||
}
|
||||
public static void main(String[] args) throws Exception {
|
||||
// createOrgByImage();
|
||||
// getOrgEmpower();
|
||||
// queryAuthProcess("OF-2b00885895080028");
|
||||
// getFileUploadUrl();
|
||||
// String uplodUrl = "https://esignoss.esign.cn/7438987614/8e278262-5960-4004-bff3-297c11e2652e/Snipaste_2023-10-27_09-59-23.jpg?Expires=1699439095&OSSAccessKeyId=STS.NTZ8NBHcTVQXgsxVRH4iyC5AY&Signature=3yu3ZQifphZsnOgN0CI0SJdqFhY%3D&callback-var=eyJ4OmZpbGVfa2V5IjoiJDliM2Y3ZjkyLTdkOWUtNGZkZi04NWU4LWE4ZDU4MzEwZjIzOCQ0MTQwNTE2ODk5In0%3D%0A&callback=eyJjYWxsYmFja1VybCI6Imh0dHA6Ly9zbWx0YXBpLnRzaWduLmNuL2FueWRvb3IvZmlsZS1zeXN0ZW0vY2FsbGJhY2svYWxpb3NzIiwiY2FsbGJhY2tCb2R5IjogIntcIm1pbWVUeXBlXCI6JHttaW1lVHlwZX0sXCJzaXplXCI6ICR7c2l6ZX0sXCJidWNrZXRcIjogJHtidWNrZXR9LFwib2JqZWN0XCI6ICR7b2JqZWN0fSxcImV0YWdcIjogJHtldGFnfSxcImZpbGVfa2V5XCI6JHt4OmZpbGVfa2V5fX0iLCJjYWxsYmFja0JvZHlUeXBlIjogImFwcGxpY2F0aW9uL2pzb24ifQ%3D%3D%0A&security-token=CAIS%2BAF1q6Ft5B2yfSjIr5fvc%2FT2pbx14ZOzZVXJslIdOOZVrPDquzz2IHtKdXRvBu8Xs%2F4wnmxX7f4YlqB6T55OSAmcNZEoWWWTbdH4MeT7oMWQweEurv%2FMQBqyaXPS2MvVfJ%2BOLrf0ceusbFbpjzJ6xaCAGxypQ12iN%2B%2Fm6%2FNgdc9FHHPPD1x8CcxROxFppeIDKHLVLozNCBPxhXfKB0ca0WgVy0EHsPnvm5DNs0uH1AKjkbRM9r6ceMb0M5NeW75kSMqw0eBMca7M7TVd8RAi9t0t1%2FIVpGiY4YDAWQYLv0rda7DOltFiMkpla7MmXqlft%2BhzcgeQY0pc%2FRqAAXGx8FDtPQxW3RSasFgOFBJaxbYjH3WFFrbV25v8a%2BS9OWPAYqOCvmkxbM7N4hOge2iaBAG4SRLMb6ypPJ15YEpoZI8KkdeDvQJryZEWchmc0Lhz0yDRqrN%2BzYhgu4VpBJu1WJg%2FyXrvAZ0gWhBN%2BILrblSR9QHVWVVYZTAKN4ejIAA%3D";
|
||||
// fileStreamUpload(uplodUrl,"D:\\develop\\Snipaste_2023-10-27_09-59-23.jpg");
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,28 @@ public class DeptIdentify extends BaseEntity {
|
||||
/** 印章名称 */
|
||||
private String sealName;
|
||||
|
||||
/** 机构账号ID */
|
||||
private String orgId;
|
||||
|
||||
/** 认证授权流程ID */
|
||||
private String authFlowId;
|
||||
|
||||
public String getAuthFlowId() {
|
||||
return authFlowId;
|
||||
}
|
||||
|
||||
public void setAuthFlowId(String authFlowId) {
|
||||
this.authFlowId = authFlowId;
|
||||
}
|
||||
|
||||
public String getOrgId() {
|
||||
return orgId;
|
||||
}
|
||||
|
||||
public void setOrgId(String orgId) {
|
||||
this.orgId = orgId;
|
||||
}
|
||||
|
||||
public String getSealName() {
|
||||
return sealName;
|
||||
}
|
||||
|
||||
+3
@@ -56,6 +56,9 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
|
||||
JsonObject signUrlJsonObject = gson.fromJson(identifyUrl.getBody(), JsonObject.class);
|
||||
JsonObject signUrlData = signUrlJsonObject.getAsJsonObject("data");
|
||||
String url = signUrlData.get("authUrl").getAsString();
|
||||
//获取本次认证授权流程ID
|
||||
String authFlowId = signUrlData.get("authFlowId").getAsString();
|
||||
deptIdentify.setAuthFlowId(authFlowId);
|
||||
deptIdentifynew.setIdentifyUrl(url);
|
||||
}
|
||||
|
||||
|
||||
+5
-7
@@ -7,6 +7,7 @@ import com.ruoyi.common.constant.CaseApplicationConstants;
|
||||
import com.ruoyi.common.constant.FileTransformation;
|
||||
import com.ruoyi.common.core.domain.entity.EsignHttpResponse;
|
||||
import com.ruoyi.common.exception.EsignDemoException;
|
||||
import com.ruoyi.common.utils.SealUtil;
|
||||
import com.ruoyi.common.utils.file.SaaSAPIFileUtils;
|
||||
import com.ruoyi.wisdomarbitrate.domain.CaseApplication;
|
||||
import com.ruoyi.wisdomarbitrate.domain.CaseAttach;
|
||||
@@ -168,7 +169,6 @@ public class FixSelectFlowDetailUtils {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Scheduled(cron = "0/30 * * * * ?")
|
||||
@Transactional
|
||||
public void fixExecuteSelectDeptIndentifyUtils() throws EsignDemoException {
|
||||
@@ -182,9 +182,12 @@ public class FixSelectFlowDetailUtils {
|
||||
JsonObject identifyInfoJsonObject = gson.fromJson(identifyInfo.getBody(), JsonObject.class);
|
||||
JsonObject identifyInfoData = identifyInfoJsonObject.getAsJsonObject("data");
|
||||
int realnameStatus = identifyInfoData.get("realnameStatus").getAsInt();
|
||||
String orgId = identifyInfoData.get("orgId").getAsString();
|
||||
if(realnameStatus==1){
|
||||
String orgId = identifyInfoData.get("orgId").getAsString();
|
||||
EsignHttpResponse identifyInfo1 = SignAward.deptIdentifySealList(orgId);
|
||||
//将orgId保存到数据库里
|
||||
DeptIdentify deptIdentifynew = deptIdentifysnew.get(i);
|
||||
deptIdentifynew.setOrgId(orgId);
|
||||
JsonObject identifyInfoJsonObject1 = gson.fromJson(identifyInfo1.getBody(), JsonObject.class);
|
||||
JsonObject identifyInfoData1 = identifyInfoJsonObject1.getAsJsonObject("data");
|
||||
JsonArray sealArray = identifyInfoData1.get("seals").getAsJsonArray();
|
||||
@@ -198,16 +201,11 @@ public class FixSelectFlowDetailUtils {
|
||||
}
|
||||
}
|
||||
String sealName = sealNames.substring(0,sealNames.length()-1);
|
||||
DeptIdentify deptIdentifynew = deptIdentifysnew.get(i);
|
||||
deptIdentifynew.setIdentifyStatus(1);
|
||||
deptIdentifynew.setSealName(sealName);
|
||||
int row = deptIdentifyMapper.updateDeptIdentify(deptIdentifynew);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -333,9 +333,9 @@ public class SignAward {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取机构认证链接
|
||||
* 获取机构认证&授权页面链接
|
||||
*
|
||||
* @return
|
||||
* @throws EsignDemoException
|
||||
*/
|
||||
public static EsignHttpResponse deptIdentifyUrl(DeptIdentify deptIdentify) throws EsignDemoException {
|
||||
String apiaddr = "/v3/org-auth-url";
|
||||
@@ -351,8 +351,18 @@ public class SignAward {
|
||||
" \"psnName\": \"" + nickName + "\",\n" +
|
||||
" \"psnMobile\": \"" + phonenumber + "\"\n" +
|
||||
" }\n" +
|
||||
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
" \"authorizeConfig\": {\n" +
|
||||
" \"authorizedScopes\": [\n" +
|
||||
" \"get_org_identity_info\",\n" +
|
||||
" \"get_psn_identity_info\",\n" +
|
||||
" \"org_initiate_sign\",\n" +
|
||||
" \"psn_initiate_sign\",\n" +
|
||||
" \"manage_org_resource\",\n" +
|
||||
" \"manage_psn_resource\",\n" +
|
||||
" \"use_org_order\"\n" +
|
||||
" ]\n" +
|
||||
" }\n" +
|
||||
"}";
|
||||
//请求方法
|
||||
@@ -417,7 +427,32 @@ public class SignAward {
|
||||
return EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建机构图片印章
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static EsignHttpResponse createOrgByImage(DeptIdentify deptIdentify) throws EsignDemoException {
|
||||
String apiaddr = "/v3/seals/org-seals/create-by-image";
|
||||
String orgId = deptIdentify.getOrgId();
|
||||
String sealImageFileKey = "";
|
||||
//请求参数body体,json格式。get或者delete请求时jsonString传空json:"{}"或者null
|
||||
String jsonParm = "{\n" +
|
||||
" \"orgId\": \"" + orgId + "\",\n" +
|
||||
" \"sealImageFileKey\": \"" + sealImageFileKey + "\",\n" +
|
||||
" \"sealName\": \"企业公章1\",\n" +
|
||||
" \"sealWidth\": 50,\n" +
|
||||
" \"sealHeight\": 50,\n" +
|
||||
"}";
|
||||
//请求方法
|
||||
EsignRequestType requestType = EsignRequestType.POST;
|
||||
//生成签名鉴权方式的的header
|
||||
Map<String, String> header = EsignHttpHelper.signAndBuildSignAndJsonHeader(eSignAppId, eSignAppSecret, jsonParm, requestType.name(), apiaddr, true);
|
||||
//发起接口请求
|
||||
EsignHttpResponse response = EsignHttpHelper.doCommHttp(eSignHost, apiaddr, requestType, jsonParm, header, true);
|
||||
System.out.println(response);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user