|
|
@@ -6,28 +6,32 @@ import cfca.trustsign.common.vo.cs.*;
|
|
|
import cfca.trustsign.common.vo.request.tx3.*;
|
|
|
import cfca.trustsign.common.vo.response.ErrorResVO;
|
|
|
import cfca.trustsign.common.vo.response.tx3.*;
|
|
|
-
|
|
|
-import cfca.trustsign.constant.Request;
|
|
|
-import cfca.trustsign.converter.JsonObjectMapper;
|
|
|
-import cfca.trustsign.util.PdfUtil;
|
|
|
-import cfca.trustsign.util.SecurityUtil;
|
|
|
-import cfca.trustsign.util.TimeUtil;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import me.zhengjie.application.admin.service.DictDetailService;
|
|
|
+import me.zhengjie.sign.connector.HttpConnector;
|
|
|
+import me.zhengjie.sign.converter.JsonObjectMapper;
|
|
|
+import me.zhengjie.sign.util.PdfUtil;
|
|
|
+import me.zhengjie.sign.util.SecurityUtil;
|
|
|
+import me.zhengjie.sign.util.TimeUtil;
|
|
|
import me.zhengjie.utils.SpringContextHolder;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
import java.io.File;
|
|
|
import java.io.InputStream;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
+@Component
|
|
|
@Slf4j
|
|
|
+@RequiredArgsConstructor
|
|
|
public class CFCACertUtil {
|
|
|
+ private final HttpConnector httpConnector;
|
|
|
private static final int PROXY_SIGN_ON = 1;
|
|
|
private static final String PROJECT_CODE = "005";
|
|
|
private static final String AUTH_MODE = "公安部";
|
|
|
- public static boolean proxySwitchOn = false;
|
|
|
|
|
|
/**
|
|
|
* 注册安心签企业用户
|
|
|
@@ -37,7 +41,7 @@ public class CFCACertUtil {
|
|
|
* @return 安心签用户ID
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- public static String registerCompany(EnterpriseVO enterprise, EnterpriseTransactorVO enterpriseTransactor)
|
|
|
+ public String registerCompany(EnterpriseVO enterprise, EnterpriseTransactorVO enterpriseTransactor)
|
|
|
throws Exception {
|
|
|
|
|
|
enterprise.setAuthenticationTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
|
|
|
@@ -65,7 +69,7 @@ public class CFCACertUtil {
|
|
|
*
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- public static String registerPerson(PersonVO person) throws Exception {
|
|
|
+ public String registerPerson(PersonVO person) throws Exception {
|
|
|
person.setAuthenticationTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
|
|
|
person.setAuthenticationMode(AUTH_MODE);
|
|
|
|
|
|
@@ -90,7 +94,7 @@ public class CFCACertUtil {
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- public static CertVO queryCertificate(CertVO cert) throws Exception {
|
|
|
+ public CertVO queryCertificate(CertVO cert) throws Exception {
|
|
|
Tx3311ReqVO tx3311ReqVO = new Tx3311ReqVO();
|
|
|
tx3311ReqVO.setHead(HeadVO.builder().txTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14)).build());
|
|
|
tx3311ReqVO.setCert(cert);
|
|
|
@@ -105,7 +109,7 @@ public class CFCACertUtil {
|
|
|
}
|
|
|
// 9. 修改印章3012
|
|
|
// 此接口用于客户平台修改某用户的印章图片。客户平台可以调用此接口修改某用户指定印章ID的印章图片。
|
|
|
- public static void updateSealWithContent(String userId, String sealId, String content) throws Exception {
|
|
|
+ public void updateSealWithContent(String userId, String sealId, String content) throws Exception {
|
|
|
|
|
|
HeadVO head = new HeadVO();
|
|
|
head.setTxTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
|
|
|
@@ -138,7 +142,7 @@ public class CFCACertUtil {
|
|
|
* @param b
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- public static void updateSeal(String userId, String sealId, byte[] b) throws Exception {
|
|
|
+ public void updateSeal(String userId, String sealId, byte[] b) throws Exception {
|
|
|
// 这里将图片的路径下载文件
|
|
|
// byte[] b=DownloadUtils.downloadFile(filePath);
|
|
|
String content = Base64.toBase64String(b);
|
|
|
@@ -153,7 +157,7 @@ public class CFCACertUtil {
|
|
|
* @return 返回印章ID
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- public static String addSealWithContent(String userId, String content) throws Exception {
|
|
|
+ public String addSealWithContent(String userId, String content) throws Exception {
|
|
|
|
|
|
HeadVO head = new HeadVO();
|
|
|
head.setTxTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
|
|
|
@@ -186,7 +190,7 @@ public class CFCACertUtil {
|
|
|
* @return 返回印章ID
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- public static String addSeal(String userId, byte[] b) throws Exception {
|
|
|
+ public String addSeal(String userId, byte[] b) throws Exception {
|
|
|
String content = Base64.toBase64String(b);
|
|
|
return addSealWithContent(userId, content);
|
|
|
}
|
|
|
@@ -197,7 +201,7 @@ public class CFCACertUtil {
|
|
|
* @param userId
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- public static boolean sendAuthMessage(String userId) throws Exception {
|
|
|
+ public boolean sendAuthMessage(String userId) throws Exception {
|
|
|
|
|
|
Tx3101ReqVO tx3101ReqVO = new Tx3101ReqVO();
|
|
|
HeadVO head = new HeadVO();
|
|
|
@@ -230,7 +234,7 @@ public class CFCACertUtil {
|
|
|
* @param checkCode
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- public static void confirmAuthMessage(String userId, String checkCode) throws Exception {
|
|
|
+ public void confirmAuthMessage(String userId, String checkCode) throws Exception {
|
|
|
|
|
|
Tx3102ReqVO tx3102ReqVO = new Tx3102ReqVO();
|
|
|
HeadVO head = new HeadVO();
|
|
|
@@ -261,7 +265,7 @@ public class CFCACertUtil {
|
|
|
* @return 返回合同编号
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- public static String uploadSignContract(UploadSignInfoVO notaryUser, UploadSignInfoVO notaryOffice,
|
|
|
+ public String uploadSignContract(UploadSignInfoVO notaryUser, UploadSignInfoVO notaryOffice,
|
|
|
InputStream file, String fileName) throws Exception {
|
|
|
|
|
|
DictDetailService dictDetailService = SpringContextHolder.getBean(DictDetailService.class);
|
|
|
@@ -354,13 +358,11 @@ public class CFCACertUtil {
|
|
|
* @param contractNo
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- public static String download(String filePath, String contractNo) throws Exception {
|
|
|
- HttpConnector httpConnector = new HttpConnector();
|
|
|
- httpConnector.isProxyUsed = proxySwitchOn ? Request.PROXY_IN_USED : Request.PROXY_NO_USED;
|
|
|
+ public String download(String filePath, String contractNo) throws Exception {
|
|
|
httpConnector.init();
|
|
|
|
|
|
byte[] fileBtye = httpConnector
|
|
|
- .getFile("platId/" + Request.AXQ_PLAT_ID + "/contractNo/" + contractNo + "/downloading");
|
|
|
+ .getFile("platId/" + httpConnector.getPlatID() + "/contractNo/" + contractNo + "/downloading");
|
|
|
|
|
|
String contentType;
|
|
|
String suffix;
|
|
|
@@ -387,7 +389,7 @@ public class CFCACertUtil {
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- private static String requestAPI(Object txReqVO, String txCode) throws Exception {
|
|
|
+ private String requestAPI(Object txReqVO, String txCode) throws Exception {
|
|
|
return requestAPI(txReqVO, txCode, null);
|
|
|
}
|
|
|
|
|
|
@@ -398,20 +400,18 @@ public class CFCACertUtil {
|
|
|
* @param txCode
|
|
|
* @throws PKIException
|
|
|
*/
|
|
|
- private static String requestAPI(Object txReqVO, String txCode, File file) throws Exception {
|
|
|
- HttpConnector httpConnector = new HttpConnector();
|
|
|
- httpConnector.isProxyUsed = proxySwitchOn ? Request.PROXY_IN_USED : Request.PROXY_NO_USED;
|
|
|
+ private String requestAPI(Object txReqVO, String txCode, File file) throws Exception {
|
|
|
httpConnector.init();
|
|
|
String req = new JsonObjectMapper().writeValueAsString(txReqVO);
|
|
|
System.out.println("req:" + req);
|
|
|
- String signature = SecurityUtil.p7SignMessageDetach(Request.AXQ_JKS_PATH, Request.AXQ_JKS_PWD,
|
|
|
- Request.AXQ_JKS_ALIAS, req);
|
|
|
+ String signature = SecurityUtil.p7SignMessageDetach(httpConnector.getKeyStorePath(), httpConnector.getKeyStorePassword(),
|
|
|
+ httpConnector.getAlias(), req);
|
|
|
String res = "";
|
|
|
if ("3203".equals(txCode)) {
|
|
|
- res = httpConnector.post("platId/" + Request.AXQ_PLAT_ID + "/txCode/" + txCode + "/transaction", req,
|
|
|
+ res = httpConnector.post("platId/" + httpConnector.getPlatID() + "/txCode/" + txCode + "/transaction", req,
|
|
|
signature, file);
|
|
|
} else {
|
|
|
- res = httpConnector.post("platId/" + Request.AXQ_PLAT_ID + "/txCode/" + txCode + "/transaction", req,
|
|
|
+ res = httpConnector.post("platId/" + httpConnector.getPlatID() + "/txCode/" + txCode + "/transaction", req,
|
|
|
signature);
|
|
|
}
|
|
|
System.out.println("res:" + res);
|
|
|
@@ -425,21 +425,19 @@ public class CFCACertUtil {
|
|
|
* @param txCode
|
|
|
* @throws PKIException
|
|
|
*/
|
|
|
- private static String requestAPI(Object txReqVO, String txCode, InputStream file, String fileName)
|
|
|
+ private String requestAPI(Object txReqVO, String txCode, InputStream file, String fileName)
|
|
|
throws Exception {
|
|
|
- HttpConnector httpConnector = new HttpConnector();
|
|
|
- httpConnector.isProxyUsed = proxySwitchOn ? Request.PROXY_IN_USED : Request.PROXY_NO_USED;
|
|
|
httpConnector.init();
|
|
|
String req = new JsonObjectMapper().writeValueAsString(txReqVO);
|
|
|
System.out.println("req:" + req);
|
|
|
- String signature = SecurityUtil.p7SignMessageDetach(Request.AXQ_JKS_PATH, Request.AXQ_JKS_PWD,
|
|
|
- Request.AXQ_JKS_ALIAS, req);
|
|
|
+ String signature = SecurityUtil.p7SignMessageDetach(httpConnector.getKeyStorePath(), httpConnector.getKeyStorePassword(),
|
|
|
+ httpConnector.getAlias(), req);
|
|
|
String res = "";
|
|
|
if ("3203".equals(txCode)) {
|
|
|
- res = httpConnector.post("platId/" + Request.AXQ_PLAT_ID + "/txCode/" + txCode + "/transaction", req,
|
|
|
+ res = httpConnector.post("platId/" + httpConnector.getPlatID() + "/txCode/" + txCode + "/transaction", req,
|
|
|
signature, file, fileName);
|
|
|
} else {
|
|
|
- res = httpConnector.post("platId/" + Request.AXQ_PLAT_ID + "/txCode/" + txCode + "/transaction", req,
|
|
|
+ res = httpConnector.post("platId/" + httpConnector.getPlatID() + "/txCode/" + txCode + "/transaction", req,
|
|
|
signature);
|
|
|
}
|
|
|
System.out.println("res:" + res);
|
|
|
@@ -457,7 +455,7 @@ public class CFCACertUtil {
|
|
|
* @return 返回合同编号
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- public static String uploadMultiSignContract(List<UploadSignInfoVO> notaryUserInfos, UploadSignInfoVO notaryUser,
|
|
|
+ public String uploadMultiSignContract(List<UploadSignInfoVO> notaryUserInfos, UploadSignInfoVO notaryUser,
|
|
|
UploadSignInfoVO seal, InputStream file, String fileName) throws Exception {
|
|
|
DictDetailService dictDetailService = SpringContextHolder.getBean(DictDetailService.class);
|
|
|
Map<String, String> map = dictDetailService.getValueByName("signed_position");
|
|
|
@@ -532,7 +530,7 @@ public class CFCACertUtil {
|
|
|
* @param signInfo
|
|
|
* @param keyword
|
|
|
*/
|
|
|
- public static void setSignInfoDefault(UploadSignInfoVO signInfo, SignKeywordVO keyword) {
|
|
|
+ public void setSignInfoDefault(UploadSignInfoVO signInfo, SignKeywordVO keyword) {
|
|
|
signInfo.setIsProxySign(PROXY_SIGN_ON);
|
|
|
signInfo.setProjectCode(PROJECT_CODE);
|
|
|
signInfo.setIsCheckProjectCode(0);
|
|
|
@@ -549,7 +547,7 @@ public class CFCACertUtil {
|
|
|
* @param height
|
|
|
* @return
|
|
|
*/
|
|
|
- public static SignKeywordVO getSignKeywork(String keyword, String offsetX, String offsetY, String width,
|
|
|
+ public SignKeywordVO getSignKeywork(String keyword, String offsetX, String offsetY, String width,
|
|
|
String height) {
|
|
|
SignKeywordVO signKeyword = new SignKeywordVO();
|
|
|
signKeyword.setKeyword(keyword);
|
|
|
@@ -566,22 +564,10 @@ public class CFCACertUtil {
|
|
|
* @param response
|
|
|
* @return
|
|
|
*/
|
|
|
- private static boolean isSucess(String response) {
|
|
|
+ private boolean isSucess(String response) {
|
|
|
if (response.indexOf("\"head\"") < 0) {
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
-
|
|
|
- public static void main(String[] args) {
|
|
|
- try {
|
|
|
- PersonVO person = new PersonVO();
|
|
|
- person.setPersonName("姜凤水");
|
|
|
- person.setIdentNo("130821196602045575");
|
|
|
- person.setMobilePhone("13776602160");
|
|
|
- registerPerson(person);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
}
|