|
|
@@ -18,449 +18,521 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.io.InputStream;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
|
|
|
@Slf4j
|
|
|
public class CFCACertUtil {
|
|
|
- private static final int PROXY_SIGN_ON = 1;
|
|
|
- private static final String PROJECT_CODE = "004";
|
|
|
- private static final String AUTH_MODE = "公安部";
|
|
|
- public static boolean proxySwitchOn = false;
|
|
|
-
|
|
|
- /**
|
|
|
- * 注册安心签企业用户
|
|
|
- *
|
|
|
- * @param enterprise 企业信息
|
|
|
- * @param enterpriseTransactor 企业经办人信息
|
|
|
- * @return 安心签用户ID
|
|
|
- * @throws Exception
|
|
|
- */
|
|
|
- public static String registerCompany(EnterpriseVO enterprise, EnterpriseTransactorVO enterpriseTransactor) throws Exception {
|
|
|
-
|
|
|
- enterprise.setAuthenticationTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
|
|
|
- enterprise.setAuthenticationMode(AUTH_MODE);
|
|
|
- enterprise.setIdentTypeCode("N");
|
|
|
- enterpriseTransactor.setIdentTypeCode("0");
|
|
|
-
|
|
|
- Tx3002ReqVO tx3002ReqVO = new Tx3002ReqVO();
|
|
|
- tx3002ReqVO.setHead(HeadVO.builder().txTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14)).build());
|
|
|
- tx3002ReqVO.setEnterprise(enterprise);
|
|
|
- tx3002ReqVO.setEnterpriseTransactor(enterpriseTransactor);
|
|
|
-
|
|
|
- String response = requestAPI(tx3002ReqVO, "3002");
|
|
|
- if (!isSucess(response)) {
|
|
|
- ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
|
|
|
- System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
|
|
|
- throw new Exception("安心签服务请求失败");
|
|
|
- }
|
|
|
- Tx3002ResVO tx3002ResVO = new ObjectMapper().readValue(response, Tx3002ResVO.class);
|
|
|
- return tx3002ResVO.getEnterprise().getUserId();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 注册安心签个人用户
|
|
|
- *
|
|
|
- * @throws Exception
|
|
|
- */
|
|
|
- public static String registerPerson(PersonVO person) throws Exception {
|
|
|
- person.setAuthenticationTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
|
|
|
- person.setAuthenticationMode(AUTH_MODE);
|
|
|
-
|
|
|
- Tx3001ReqVO tx3001ReqVO = new Tx3001ReqVO();
|
|
|
- tx3001ReqVO.setHead(HeadVO.builder().txTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14)).build());
|
|
|
- tx3001ReqVO.setPerson(person);
|
|
|
-
|
|
|
- String response = requestAPI(tx3001ReqVO, "3001");
|
|
|
- if (!isSucess(response)) {
|
|
|
- ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
|
|
|
- System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
|
|
|
- throw new Exception("安心签服务请求失败");
|
|
|
- }
|
|
|
- Tx3001ResVO tx3001ResVO = new ObjectMapper().readValue(response, Tx3001ResVO.class);
|
|
|
- return tx3001ResVO.getPerson().getUserId();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 查询证书信息
|
|
|
- * @param cert
|
|
|
- * @return
|
|
|
- * @throws Exception
|
|
|
- */
|
|
|
- public static CertVO queryCertificate(CertVO cert) throws Exception{
|
|
|
- Tx3311ReqVO tx3311ReqVO = new Tx3311ReqVO();
|
|
|
- tx3311ReqVO.setHead(HeadVO.builder().txTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14)).build());
|
|
|
- tx3311ReqVO.setCert(cert);
|
|
|
- String response = requestAPI(tx3311ReqVO, "3311");
|
|
|
- if (!isSucess(response)) {
|
|
|
- ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
|
|
|
- System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
|
|
|
- throw new Exception("安心签服务请求失败");
|
|
|
- }
|
|
|
- Tx3311ResVO tx3311ResVO = new ObjectMapper().readValue(response, Tx3311ResVO.class);
|
|
|
- return tx3311ResVO.getCert();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- public static void updateSealWithContent(String userId, String sealId, String content) throws Exception {
|
|
|
-
|
|
|
- HeadVO head = new HeadVO();
|
|
|
- head.setTxTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
|
|
|
-
|
|
|
- SealVO sealVO = new SealVO();
|
|
|
- sealVO.setSealId(sealId);
|
|
|
- sealVO.setImageData(content);
|
|
|
-
|
|
|
- SealUpdateVO sealUpdateVO = new SealUpdateVO();
|
|
|
- sealUpdateVO.setUserId(userId);
|
|
|
- sealUpdateVO.setSeal(sealVO);
|
|
|
-
|
|
|
- Tx3012ReqVO tx3012ReqVO = new Tx3012ReqVO();
|
|
|
- tx3012ReqVO.setHead(head);
|
|
|
- tx3012ReqVO.setSealUpdate(sealUpdateVO);
|
|
|
-
|
|
|
- String response = requestAPI(tx3012ReqVO, "3012");
|
|
|
- if (!isSucess(response)) {
|
|
|
- ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
|
|
|
- System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
|
|
|
- throw new Exception("安心签服务请求失败");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 修改签章
|
|
|
- * @param userId
|
|
|
- * @param sealId
|
|
|
- * @param filePath
|
|
|
- * @throws Exception
|
|
|
- */
|
|
|
- public static void updateSeal(String userId, String sealId, byte[] b) throws Exception {
|
|
|
- //这里将图片的路径下载文件
|
|
|
+ private static final int PROXY_SIGN_ON = 1;
|
|
|
+ private static final String PROJECT_CODE = "004";
|
|
|
+ private static final String AUTH_MODE = "公安部";
|
|
|
+ public static boolean proxySwitchOn = false;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 注册安心签企业用户
|
|
|
+ *
|
|
|
+ * @param enterprise 企业信息
|
|
|
+ * @param enterpriseTransactor 企业经办人信息
|
|
|
+ * @return 安心签用户ID
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public static String registerCompany(EnterpriseVO enterprise, EnterpriseTransactorVO enterpriseTransactor)
|
|
|
+ throws Exception {
|
|
|
+
|
|
|
+ enterprise.setAuthenticationTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
|
|
|
+ enterprise.setAuthenticationMode(AUTH_MODE);
|
|
|
+ enterprise.setIdentTypeCode("N");
|
|
|
+ enterpriseTransactor.setIdentTypeCode("0");
|
|
|
+
|
|
|
+ Tx3002ReqVO tx3002ReqVO = new Tx3002ReqVO();
|
|
|
+ tx3002ReqVO.setHead(HeadVO.builder().txTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14)).build());
|
|
|
+ tx3002ReqVO.setEnterprise(enterprise);
|
|
|
+ tx3002ReqVO.setEnterpriseTransactor(enterpriseTransactor);
|
|
|
+
|
|
|
+ String response = requestAPI(tx3002ReqVO, "3002");
|
|
|
+ if (!isSucess(response)) {
|
|
|
+ ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
|
|
|
+ System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
|
|
|
+ throw new Exception("安心签服务请求失败");
|
|
|
+ }
|
|
|
+ Tx3002ResVO tx3002ResVO = new ObjectMapper().readValue(response, Tx3002ResVO.class);
|
|
|
+ return tx3002ResVO.getEnterprise().getUserId();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 注册安心签个人用户
|
|
|
+ *
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public static String registerPerson(PersonVO person) throws Exception {
|
|
|
+ person.setAuthenticationTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
|
|
|
+ person.setAuthenticationMode(AUTH_MODE);
|
|
|
+
|
|
|
+ Tx3001ReqVO tx3001ReqVO = new Tx3001ReqVO();
|
|
|
+ tx3001ReqVO.setHead(HeadVO.builder().txTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14)).build());
|
|
|
+ tx3001ReqVO.setPerson(person);
|
|
|
+
|
|
|
+ String response = requestAPI(tx3001ReqVO, "3001");
|
|
|
+ if (!isSucess(response)) {
|
|
|
+ ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
|
|
|
+ System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
|
|
|
+ throw new Exception("安心签服务请求失败");
|
|
|
+ }
|
|
|
+ Tx3001ResVO tx3001ResVO = new ObjectMapper().readValue(response, Tx3001ResVO.class);
|
|
|
+ return tx3001ResVO.getPerson().getUserId();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询证书信息
|
|
|
+ *
|
|
|
+ * @param cert
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public static CertVO queryCertificate(CertVO cert) throws Exception {
|
|
|
+ Tx3311ReqVO tx3311ReqVO = new Tx3311ReqVO();
|
|
|
+ tx3311ReqVO.setHead(HeadVO.builder().txTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14)).build());
|
|
|
+ tx3311ReqVO.setCert(cert);
|
|
|
+ String response = requestAPI(tx3311ReqVO, "3311");
|
|
|
+ if (!isSucess(response)) {
|
|
|
+ ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
|
|
|
+ System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
|
|
|
+ throw new Exception("安心签服务请求失败");
|
|
|
+ }
|
|
|
+ Tx3311ResVO tx3311ResVO = new ObjectMapper().readValue(response, Tx3311ResVO.class);
|
|
|
+ return tx3311ResVO.getCert();
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void updateSealWithContent(String userId, String sealId, String content) throws Exception {
|
|
|
+
|
|
|
+ HeadVO head = new HeadVO();
|
|
|
+ head.setTxTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
|
|
|
+
|
|
|
+ SealVO sealVO = new SealVO();
|
|
|
+ sealVO.setSealId(sealId);
|
|
|
+ sealVO.setImageData(content);
|
|
|
+
|
|
|
+ SealUpdateVO sealUpdateVO = new SealUpdateVO();
|
|
|
+ sealUpdateVO.setUserId(userId);
|
|
|
+ sealUpdateVO.setSeal(sealVO);
|
|
|
+
|
|
|
+ Tx3012ReqVO tx3012ReqVO = new Tx3012ReqVO();
|
|
|
+ tx3012ReqVO.setHead(head);
|
|
|
+ tx3012ReqVO.setSealUpdate(sealUpdateVO);
|
|
|
+
|
|
|
+ String response = requestAPI(tx3012ReqVO, "3012");
|
|
|
+ if (!isSucess(response)) {
|
|
|
+ ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
|
|
|
+ System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
|
|
|
+ throw new Exception("安心签服务请求失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改签章
|
|
|
+ *
|
|
|
+ * @param userId
|
|
|
+ * @param sealId
|
|
|
+ * @param filePath
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public static void updateSeal(String userId, String sealId, byte[] b) throws Exception {
|
|
|
+ // 这里将图片的路径下载文件
|
|
|
// byte[] b=DownloadUtils.downloadFile(filePath);
|
|
|
- String content = Base64.toBase64String(b);
|
|
|
- updateSealWithContent(userId, sealId, content);
|
|
|
- }
|
|
|
- /**
|
|
|
- * 为指定用户添加印章
|
|
|
- *
|
|
|
- * @param userId
|
|
|
- * @param content
|
|
|
- * @return 返回印章ID
|
|
|
- * @throws Exception
|
|
|
- */
|
|
|
- public static String addSealWithContent(String userId, String content) throws Exception {
|
|
|
-
|
|
|
- HeadVO head = new HeadVO();
|
|
|
- head.setTxTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
|
|
|
-
|
|
|
- SealAddVO sealAddVO = new SealAddVO();
|
|
|
- sealAddVO.setUserId(userId);
|
|
|
- SealVO sealVO = new SealVO();
|
|
|
- sealVO.setImageData(content);
|
|
|
- sealAddVO.setSeal(sealVO);
|
|
|
-
|
|
|
- Tx3011ReqVO tx3011ReqVO = new Tx3011ReqVO();
|
|
|
- tx3011ReqVO.setHead(head);
|
|
|
- tx3011ReqVO.setSealAdd(sealAddVO);
|
|
|
-
|
|
|
- String response = requestAPI(tx3011ReqVO, "3011");
|
|
|
- if (!isSucess(response)) {
|
|
|
- ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
|
|
|
- System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
|
|
|
- throw new Exception("安心签服务请求失败");
|
|
|
- }
|
|
|
- Tx3011ResVO tx3011ResVO = new ObjectMapper().readValue(response, Tx3011ResVO.class);
|
|
|
- return tx3011ResVO.getSealAdd().getSeal().getSealId();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 为指定用户添加印章
|
|
|
- *
|
|
|
- * @param userId
|
|
|
- * @param filePath
|
|
|
- * @return 返回印章ID
|
|
|
- * @throws Exception
|
|
|
- */
|
|
|
- public static String addSeal(String userId, byte[] b) throws Exception {
|
|
|
- String content = Base64.toBase64String(b);
|
|
|
- return addSealWithContent(userId, content);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 对指定用户发送授权验证码
|
|
|
- *
|
|
|
- * @param userId
|
|
|
- * @throws Exception
|
|
|
- */
|
|
|
- public static boolean sendAuthMessage(String userId) throws Exception {
|
|
|
-
|
|
|
- Tx3101ReqVO tx3101ReqVO = new Tx3101ReqVO();
|
|
|
- HeadVO head = new HeadVO();
|
|
|
- head.setTxTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
|
|
|
-
|
|
|
- ProxySignVO proxySignVO = new ProxySignVO();
|
|
|
- proxySignVO.setUserId(userId);
|
|
|
- proxySignVO.setProjectCode(PROJECT_CODE);
|
|
|
-
|
|
|
- tx3101ReqVO.setHead(head);
|
|
|
- tx3101ReqVO.setProxySign(proxySignVO);
|
|
|
-
|
|
|
- String response = requestAPI(tx3101ReqVO, "3101");
|
|
|
- if (!isSucess(response)) {
|
|
|
- ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
|
|
|
- System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
|
|
|
- if (!"60030401".equals(errorResVO.getErrorCode())) {
|
|
|
- throw new Exception("安心签服务请求失败");
|
|
|
- }else {
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 确认授权验证码
|
|
|
- *
|
|
|
- * @param userId
|
|
|
- * @param checkCode
|
|
|
- * @throws Exception
|
|
|
- */
|
|
|
- public static void confirmAuthMessage(String userId, String checkCode) throws Exception {
|
|
|
-
|
|
|
- Tx3102ReqVO tx3102ReqVO = new Tx3102ReqVO();
|
|
|
- HeadVO head = new HeadVO();
|
|
|
- head.setTxTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
|
|
|
-
|
|
|
- ProxySignVO proxySignVO = new ProxySignVO();
|
|
|
- proxySignVO.setUserId(userId);
|
|
|
- proxySignVO.setProjectCode(PROJECT_CODE);
|
|
|
- proxySignVO.setCheckCode(checkCode);
|
|
|
-
|
|
|
- tx3102ReqVO.setHead(head);
|
|
|
- tx3102ReqVO.setProxySign(proxySignVO);
|
|
|
-
|
|
|
- String response = requestAPI(tx3102ReqVO, "3102");
|
|
|
- if (!isSucess(response)) {
|
|
|
- ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
|
|
|
- System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
|
|
|
- throw new Exception("安心签服务请求失败");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 上传签署合同
|
|
|
- *
|
|
|
- * @param notaryUser 公证员签名信息
|
|
|
- * @param notaryOffice 公证处签名信息
|
|
|
- * @param file 签名文件
|
|
|
- * @return 返回合同编号
|
|
|
- * @throws Exception
|
|
|
- */
|
|
|
- public static String uploadSignContract(UploadSignInfoVO notaryUser, UploadSignInfoVO notaryOffice, InputStream file,String fileName) throws Exception {
|
|
|
- SignKeywordVO keywordNotaryUser = getSignKeywork("公证员", "70", "0", "160", "60");
|
|
|
- setSignInfoDefault(notaryUser, keywordNotaryUser);
|
|
|
- SignKeywordVO keywordNotaryOffice = getSignKeywork("签章", "0", "0", "150", "150");
|
|
|
- setSignInfoDefault(notaryOffice, keywordNotaryOffice);
|
|
|
-
|
|
|
- UploadSignInfoVO[] signInfos = {notaryUser, notaryOffice};
|
|
|
- UploadContractVO uploadContract = new UploadContractVO();
|
|
|
- uploadContract.setSignInfos(signInfos);
|
|
|
- uploadContract.setContractTypeCode("WT");
|
|
|
- uploadContract.setContractName("赋强公证");
|
|
|
-
|
|
|
- HeadVO head = new HeadVO();
|
|
|
- head.setTxTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
|
|
|
-
|
|
|
- Tx3203ReqVO tx3203ReqVO = new Tx3203ReqVO();
|
|
|
- tx3203ReqVO.setHead(head);
|
|
|
- tx3203ReqVO.setUploadContract(uploadContract);
|
|
|
-
|
|
|
- String response = requestAPI(tx3203ReqVO, "3203", file,fileName);
|
|
|
- if (!isSucess(response)) {
|
|
|
- ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
|
|
|
- System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
|
|
|
- throw new Exception("安心签服务请求失败");
|
|
|
- }
|
|
|
- Tx3203ResVO tx3203ResVO = new ObjectMapper().readValue(response, Tx3203ResVO.class);
|
|
|
- return tx3203ResVO.getContract().getContractNo();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 上传签署合同
|
|
|
- *
|
|
|
- * @param user
|
|
|
- * @param file
|
|
|
- * @return
|
|
|
- * @throws Exception
|
|
|
- */
|
|
|
- public static String uploadSignContract(UploadSignInfoVO user, InputStream file,String fileName) throws Exception {
|
|
|
- SignKeywordVO keywordUser = getSignKeywork("签名:", "70", "0", "160", "60");
|
|
|
- setSignInfoDefault(user, keywordUser);
|
|
|
-
|
|
|
- UploadSignInfoVO[] signInfos = {user};
|
|
|
- UploadContractVO uploadContract = new UploadContractVO();
|
|
|
- uploadContract.setSignInfos(signInfos);
|
|
|
- uploadContract.setContractTypeCode("WT");
|
|
|
- uploadContract.setContractName("赋强公证");
|
|
|
-
|
|
|
- HeadVO head = new HeadVO();
|
|
|
- head.setTxTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
|
|
|
-
|
|
|
- Tx3203ReqVO tx3203ReqVO = new Tx3203ReqVO();
|
|
|
- tx3203ReqVO.setHead(head);
|
|
|
- tx3203ReqVO.setUploadContract(uploadContract);
|
|
|
- //读取文件的流,TODO
|
|
|
- String response = requestAPI(tx3203ReqVO, "3203", file,fileName);
|
|
|
- if (!isSucess(response)) {
|
|
|
- ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
|
|
|
- System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
|
|
|
- throw new Exception("安心签服务请求失败");
|
|
|
- }
|
|
|
- Tx3203ResVO tx3203ResVO = new ObjectMapper().readValue(response, Tx3203ResVO.class);
|
|
|
- return tx3203ResVO.getContract().getContractNo();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 下载签名公证书
|
|
|
- *
|
|
|
- * @param filePath
|
|
|
- * @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;
|
|
|
- httpConnector.init();
|
|
|
-
|
|
|
- byte[] fileBtye = httpConnector.getFile("platId/" + Request.AXQ_PLAT_ID + "/contractNo/" + contractNo + "/downloading");
|
|
|
-
|
|
|
- String contentType;
|
|
|
- String suffix;
|
|
|
- if(PdfUtil.isPdf(fileBtye)) {
|
|
|
- contentType = "application/pdf";
|
|
|
- suffix=".pdf";
|
|
|
- }else {
|
|
|
- contentType = "application/ofd";
|
|
|
- suffix=".ofd";
|
|
|
- }
|
|
|
- String fullFilePath = filePath + contractNo + suffix;
|
|
|
- //上传文件路径
|
|
|
- log.info("上传文件的目录:"+ fullFilePath);
|
|
|
- FileUploadUtil.uploadFile(fullFilePath, contentType, fileBtye);
|
|
|
-
|
|
|
- return fullFilePath;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 发送安心签API请求
|
|
|
- *
|
|
|
- * @param txReqVO
|
|
|
- * @param txCode
|
|
|
- * @return
|
|
|
- * @throws Exception
|
|
|
- */
|
|
|
- private static String requestAPI(Object txReqVO, String txCode) throws Exception {
|
|
|
- return requestAPI(txReqVO, txCode, null);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 发送安心签API请求
|
|
|
- *
|
|
|
- * @param txReqVO
|
|
|
- * @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;
|
|
|
- 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 res = "";
|
|
|
- if ("3203".equals(txCode)) {
|
|
|
- res = httpConnector.post("platId/" + Request.AXQ_PLAT_ID + "/txCode/" + txCode + "/transaction", req, signature, file);
|
|
|
- } else {
|
|
|
- res = httpConnector.post("platId/" + Request.AXQ_PLAT_ID + "/txCode/" + txCode + "/transaction", req, signature);
|
|
|
- }
|
|
|
- System.out.println("res:" + res);
|
|
|
- return res;
|
|
|
- }
|
|
|
- /**
|
|
|
- * 发送安心签API请求
|
|
|
- *
|
|
|
- * @param txReqVO
|
|
|
- * @param txCode
|
|
|
- * @throws PKIException
|
|
|
- */
|
|
|
- private static 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 res = "";
|
|
|
- if ("3203".equals(txCode)) {
|
|
|
- res = httpConnector.post("platId/" + Request.AXQ_PLAT_ID + "/txCode/" + txCode + "/transaction", req, signature, file,fileName);
|
|
|
- } else {
|
|
|
- res = httpConnector.post("platId/" + Request.AXQ_PLAT_ID + "/txCode/" + txCode + "/transaction", req, signature);
|
|
|
- }
|
|
|
- System.out.println("res:" + res);
|
|
|
- return res;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 设置签名默认信息
|
|
|
- *
|
|
|
- * @param signInfo
|
|
|
- * @param keyword
|
|
|
- */
|
|
|
- private static void setSignInfoDefault(UploadSignInfoVO signInfo, SignKeywordVO keyword) {
|
|
|
- signInfo.setIsProxySign(PROXY_SIGN_ON);
|
|
|
- signInfo.setProjectCode(PROJECT_CODE);
|
|
|
- signInfo.setSignKeyword(keyword);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获得签名定位关键词对象
|
|
|
- *
|
|
|
- * @param keyword
|
|
|
- * @param offsetX
|
|
|
- * @param offsetY
|
|
|
- * @param width
|
|
|
- * @param height
|
|
|
- * @return
|
|
|
- */
|
|
|
- private static SignKeywordVO getSignKeywork(String keyword, String offsetX, String offsetY, String width, String height) {
|
|
|
- SignKeywordVO signKeyword = new SignKeywordVO();
|
|
|
- signKeyword.setKeyword(keyword);
|
|
|
- signKeyword.setOffsetCoordX(offsetX);
|
|
|
- signKeyword.setOffsetCoordY(offsetY);
|
|
|
- signKeyword.setImageWidth(width);
|
|
|
- signKeyword.setImageHeight(height);
|
|
|
- return signKeyword;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 判断请求是否成功
|
|
|
- *
|
|
|
- * @param response
|
|
|
- * @return
|
|
|
- */
|
|
|
- private static boolean isSucess(String response) {
|
|
|
- if (response.indexOf("\"head\"") < 0) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- public static void main(String[] args) {
|
|
|
- proxySwitchOn = true;
|
|
|
- CertVO certVO = new CertVO();
|
|
|
- certVO.setUserId("DD25A736C37D345DE05311016B0AB061");
|
|
|
- try {
|
|
|
- queryCertificate(certVO);
|
|
|
- }catch (Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
+ String content = Base64.toBase64String(b);
|
|
|
+ updateSealWithContent(userId, sealId, content);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 为指定用户添加印章
|
|
|
+ *
|
|
|
+ * @param userId
|
|
|
+ * @param content
|
|
|
+ * @return 返回印章ID
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public static String addSealWithContent(String userId, String content) throws Exception {
|
|
|
+
|
|
|
+ HeadVO head = new HeadVO();
|
|
|
+ head.setTxTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
|
|
|
+
|
|
|
+ SealAddVO sealAddVO = new SealAddVO();
|
|
|
+ sealAddVO.setUserId(userId);
|
|
|
+ SealVO sealVO = new SealVO();
|
|
|
+ sealVO.setImageData(content);
|
|
|
+ sealAddVO.setSeal(sealVO);
|
|
|
+
|
|
|
+ Tx3011ReqVO tx3011ReqVO = new Tx3011ReqVO();
|
|
|
+ tx3011ReqVO.setHead(head);
|
|
|
+ tx3011ReqVO.setSealAdd(sealAddVO);
|
|
|
+
|
|
|
+ String response = requestAPI(tx3011ReqVO, "3011");
|
|
|
+ if (!isSucess(response)) {
|
|
|
+ ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
|
|
|
+ System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
|
|
|
+ throw new Exception("安心签服务请求失败");
|
|
|
+ }
|
|
|
+ Tx3011ResVO tx3011ResVO = new ObjectMapper().readValue(response, Tx3011ResVO.class);
|
|
|
+ return tx3011ResVO.getSealAdd().getSeal().getSealId();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 为指定用户添加印章
|
|
|
+ *
|
|
|
+ * @param userId
|
|
|
+ * @param filePath
|
|
|
+ * @return 返回印章ID
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public static String addSeal(String userId, byte[] b) throws Exception {
|
|
|
+ String content = Base64.toBase64String(b);
|
|
|
+ return addSealWithContent(userId, content);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 对指定用户发送授权验证码
|
|
|
+ *
|
|
|
+ * @param userId
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public static boolean sendAuthMessage(String userId) throws Exception {
|
|
|
+
|
|
|
+ Tx3101ReqVO tx3101ReqVO = new Tx3101ReqVO();
|
|
|
+ HeadVO head = new HeadVO();
|
|
|
+ head.setTxTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
|
|
|
+
|
|
|
+ ProxySignVO proxySignVO = new ProxySignVO();
|
|
|
+ proxySignVO.setUserId(userId);
|
|
|
+ proxySignVO.setProjectCode(PROJECT_CODE);
|
|
|
+
|
|
|
+ tx3101ReqVO.setHead(head);
|
|
|
+ tx3101ReqVO.setProxySign(proxySignVO);
|
|
|
+
|
|
|
+ String response = requestAPI(tx3101ReqVO, "3101");
|
|
|
+ if (!isSucess(response)) {
|
|
|
+ ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
|
|
|
+ System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
|
|
|
+ if (!"60030401".equals(errorResVO.getErrorCode())) {
|
|
|
+ throw new Exception("安心签服务请求失败");
|
|
|
+ } else {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 确认授权验证码
|
|
|
+ *
|
|
|
+ * @param userId
|
|
|
+ * @param checkCode
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public static void confirmAuthMessage(String userId, String checkCode) throws Exception {
|
|
|
+
|
|
|
+ Tx3102ReqVO tx3102ReqVO = new Tx3102ReqVO();
|
|
|
+ HeadVO head = new HeadVO();
|
|
|
+ head.setTxTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
|
|
|
+
|
|
|
+ ProxySignVO proxySignVO = new ProxySignVO();
|
|
|
+ proxySignVO.setUserId(userId);
|
|
|
+ proxySignVO.setProjectCode(PROJECT_CODE);
|
|
|
+ proxySignVO.setCheckCode(checkCode);
|
|
|
+
|
|
|
+ tx3102ReqVO.setHead(head);
|
|
|
+ tx3102ReqVO.setProxySign(proxySignVO);
|
|
|
+
|
|
|
+ String response = requestAPI(tx3102ReqVO, "3102");
|
|
|
+ if (!isSucess(response)) {
|
|
|
+ ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
|
|
|
+ System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
|
|
|
+ throw new Exception("安心签服务请求失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 上传签署合同
|
|
|
+ *
|
|
|
+ * @param notaryUser 公证员签名信息
|
|
|
+ * @param notaryOffice 公证处签名信息
|
|
|
+ * @param file 签名文件
|
|
|
+ * @return 返回合同编号
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public static String uploadSignContract(UploadSignInfoVO notaryUser, UploadSignInfoVO notaryOffice,
|
|
|
+ InputStream file, String fileName) throws Exception {
|
|
|
+ SignKeywordVO keywordNotaryUser = getSignKeywork("公证员", "70", "0", "160", "60");
|
|
|
+ setSignInfoDefault(notaryUser, keywordNotaryUser);
|
|
|
+ SignKeywordVO keywordNotaryOffice = getSignKeywork("签章", "0", "0", "150", "150");
|
|
|
+ setSignInfoDefault(notaryOffice, keywordNotaryOffice);
|
|
|
+
|
|
|
+ UploadSignInfoVO[] signInfos = { notaryUser, notaryOffice };
|
|
|
+ UploadContractVO uploadContract = new UploadContractVO();
|
|
|
+ uploadContract.setSignInfos(signInfos);
|
|
|
+ uploadContract.setContractTypeCode("WT");
|
|
|
+ uploadContract.setContractName("赋强公证");
|
|
|
+
|
|
|
+ HeadVO head = new HeadVO();
|
|
|
+ head.setTxTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
|
|
|
+
|
|
|
+ Tx3203ReqVO tx3203ReqVO = new Tx3203ReqVO();
|
|
|
+ tx3203ReqVO.setHead(head);
|
|
|
+ tx3203ReqVO.setUploadContract(uploadContract);
|
|
|
+
|
|
|
+ String response = requestAPI(tx3203ReqVO, "3203", file, fileName);
|
|
|
+ if (!isSucess(response)) {
|
|
|
+ ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
|
|
|
+ System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
|
|
|
+ throw new Exception("安心签服务请求失败");
|
|
|
+ }
|
|
|
+ Tx3203ResVO tx3203ResVO = new ObjectMapper().readValue(response, Tx3203ResVO.class);
|
|
|
+ return tx3203ResVO.getContract().getContractNo();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 上传签署合同
|
|
|
+ *
|
|
|
+ * @param user
|
|
|
+ * @param file
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public static String uploadSignContract(UploadSignInfoVO user, InputStream file, String fileName) throws Exception {
|
|
|
+ SignKeywordVO keywordUser = getSignKeywork("签名:", "70", "0", "160", "60");
|
|
|
+ setSignInfoDefault(user, keywordUser);
|
|
|
+
|
|
|
+ UploadSignInfoVO[] signInfos = { user };
|
|
|
+ UploadContractVO uploadContract = new UploadContractVO();
|
|
|
+ uploadContract.setSignInfos(signInfos);
|
|
|
+ uploadContract.setContractTypeCode("WT");
|
|
|
+ uploadContract.setContractName("赋强公证");
|
|
|
+
|
|
|
+ HeadVO head = new HeadVO();
|
|
|
+ head.setTxTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
|
|
|
+
|
|
|
+ Tx3203ReqVO tx3203ReqVO = new Tx3203ReqVO();
|
|
|
+ tx3203ReqVO.setHead(head);
|
|
|
+ tx3203ReqVO.setUploadContract(uploadContract);
|
|
|
+ // 读取文件的流,TODO
|
|
|
+ String response = requestAPI(tx3203ReqVO, "3203", file, fileName);
|
|
|
+ if (!isSucess(response)) {
|
|
|
+ ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
|
|
|
+ System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
|
|
|
+ throw new Exception("安心签服务请求失败");
|
|
|
+ }
|
|
|
+ Tx3203ResVO tx3203ResVO = new ObjectMapper().readValue(response, Tx3203ResVO.class);
|
|
|
+ return tx3203ResVO.getContract().getContractNo();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 下载签名公证书
|
|
|
+ *
|
|
|
+ * @param filePath
|
|
|
+ * @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;
|
|
|
+ httpConnector.init();
|
|
|
+
|
|
|
+ byte[] fileBtye = httpConnector
|
|
|
+ .getFile("platId/" + Request.AXQ_PLAT_ID + "/contractNo/" + contractNo + "/downloading");
|
|
|
+
|
|
|
+ String contentType;
|
|
|
+ String suffix;
|
|
|
+ if (PdfUtil.isPdf(fileBtye)) {
|
|
|
+ contentType = "application/pdf";
|
|
|
+ suffix = ".pdf";
|
|
|
+ } else {
|
|
|
+ contentType = "application/ofd";
|
|
|
+ suffix = ".ofd";
|
|
|
+ }
|
|
|
+ String fullFilePath = filePath + contractNo + suffix;
|
|
|
+ // 上传文件路径
|
|
|
+ log.info("上传文件的目录:" + fullFilePath);
|
|
|
+ FileUploadUtil.uploadFile(fullFilePath, contentType, fileBtye);
|
|
|
+
|
|
|
+ return fullFilePath;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发送安心签API请求
|
|
|
+ *
|
|
|
+ * @param txReqVO
|
|
|
+ * @param txCode
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ private static String requestAPI(Object txReqVO, String txCode) throws Exception {
|
|
|
+ return requestAPI(txReqVO, txCode, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发送安心签API请求
|
|
|
+ *
|
|
|
+ * @param txReqVO
|
|
|
+ * @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;
|
|
|
+ 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 res = "";
|
|
|
+ if ("3203".equals(txCode)) {
|
|
|
+ res = httpConnector.post("platId/" + Request.AXQ_PLAT_ID + "/txCode/" + txCode + "/transaction", req,
|
|
|
+ signature, file);
|
|
|
+ } else {
|
|
|
+ res = httpConnector.post("platId/" + Request.AXQ_PLAT_ID + "/txCode/" + txCode + "/transaction", req,
|
|
|
+ signature);
|
|
|
+ }
|
|
|
+ System.out.println("res:" + res);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发送安心签API请求
|
|
|
+ *
|
|
|
+ * @param txReqVO
|
|
|
+ * @param txCode
|
|
|
+ * @throws PKIException
|
|
|
+ */
|
|
|
+ private static 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 res = "";
|
|
|
+ if ("3203".equals(txCode)) {
|
|
|
+ res = httpConnector.post("platId/" + Request.AXQ_PLAT_ID + "/txCode/" + txCode + "/transaction", req,
|
|
|
+ signature, file, fileName);
|
|
|
+ } else {
|
|
|
+ res = httpConnector.post("platId/" + Request.AXQ_PLAT_ID + "/txCode/" + txCode + "/transaction", req,
|
|
|
+ signature);
|
|
|
+ }
|
|
|
+ System.out.println("res:" + res);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 多个人签证,最多三个人
|
|
|
+ ** @param notaryUserInfos 签名多个,包含了可能是借款人,抵押人,担保人
|
|
|
+ * @param notaryUser 公证员签名信息
|
|
|
+ * @param seal 盖章的位置
|
|
|
+ * @param file 文件的
|
|
|
+ * @param fileName 文件名称
|
|
|
+ * @return 返回合同编号
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public static String uploadMultiSignContract(List<UploadSignInfoVO> notaryUserInfos, UploadSignInfoVO notaryUser,
|
|
|
+ UploadSignInfoVO seal, InputStream file, String fileName) throws Exception {
|
|
|
+
|
|
|
+
|
|
|
+ int i = 0;
|
|
|
+ for (UploadSignInfoVO user : notaryUserInfos) {
|
|
|
+ String x = String.valueOf(10 + i * 70);
|
|
|
+ i++;
|
|
|
+ SignKeywordVO keywordNotaryUser = CFCACertUtil.getSignKeywork("签章:", x, "0", "80", "40");
|
|
|
+ CFCACertUtil.setSignInfoDefault(user, keywordNotaryUser);
|
|
|
+ }
|
|
|
+ //公证员签名
|
|
|
+ if (notaryUser != null) {
|
|
|
+ SignKeywordVO keywordNotaryUser = getSignKeywork("公证员", "70", "0", "160", "60");
|
|
|
+ setSignInfoDefault(notaryUser, keywordNotaryUser);
|
|
|
+ notaryUserInfos.add(notaryUser);
|
|
|
+ }
|
|
|
+ //盖章
|
|
|
+ if (seal != null) {
|
|
|
+ SignKeywordVO keywordNotaryOffice = getSignKeywork("签章", "0", "0", "150", "150");
|
|
|
+ setSignInfoDefault(seal, keywordNotaryOffice);
|
|
|
+ notaryUserInfos.add(seal);
|
|
|
+ }
|
|
|
+
|
|
|
+ UploadContractVO uploadContract = new UploadContractVO();
|
|
|
+ uploadContract.setSignInfos(notaryUserInfos.toArray(new UploadSignInfoVO[0]));
|
|
|
+ uploadContract.setContractTypeCode("WT");
|
|
|
+ uploadContract.setContractName("赋强公证");
|
|
|
+
|
|
|
+ HeadVO head = new HeadVO();
|
|
|
+ head.setTxTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
|
|
|
+
|
|
|
+ Tx3203ReqVO tx3203ReqVO = new Tx3203ReqVO();
|
|
|
+ tx3203ReqVO.setHead(head);
|
|
|
+ tx3203ReqVO.setUploadContract(uploadContract);
|
|
|
+
|
|
|
+ String response = requestAPI(tx3203ReqVO, "3203", file, fileName);
|
|
|
+ if (!isSucess(response)) {
|
|
|
+ ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
|
|
|
+ System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
|
|
|
+ throw new Exception("安心签服务请求失败");
|
|
|
+ }
|
|
|
+ Tx3203ResVO tx3203ResVO = new ObjectMapper().readValue(response, Tx3203ResVO.class);
|
|
|
+ return tx3203ResVO.getContract().getContractNo();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置签名默认信息
|
|
|
+ *
|
|
|
+ * @param signInfo
|
|
|
+ * @param keyword
|
|
|
+ */
|
|
|
+ public static void setSignInfoDefault(UploadSignInfoVO signInfo, SignKeywordVO keyword) {
|
|
|
+ signInfo.setIsProxySign(PROXY_SIGN_ON);
|
|
|
+ signInfo.setProjectCode(PROJECT_CODE);
|
|
|
+ signInfo.setSignKeyword(keyword);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获得签名定位关键词对象
|
|
|
+ *
|
|
|
+ * @param keyword
|
|
|
+ * @param offsetX
|
|
|
+ * @param offsetY
|
|
|
+ * @param width
|
|
|
+ * @param height
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static SignKeywordVO getSignKeywork(String keyword, String offsetX, String offsetY, String width,
|
|
|
+ String height) {
|
|
|
+ SignKeywordVO signKeyword = new SignKeywordVO();
|
|
|
+ signKeyword.setKeyword(keyword);
|
|
|
+ signKeyword.setOffsetCoordX(offsetX);
|
|
|
+ signKeyword.setOffsetCoordY(offsetY);
|
|
|
+ signKeyword.setImageWidth(width);
|
|
|
+ signKeyword.setImageHeight(height);
|
|
|
+ return signKeyword;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 判断请求是否成功
|
|
|
+ *
|
|
|
+ * @param response
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private static boolean isSucess(String response) {
|
|
|
+ if (response.indexOf("\"head\"") < 0) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ proxySwitchOn = true;
|
|
|
+ CertVO certVO = new CertVO();
|
|
|
+ certVO.setUserId("DD25A736C37D345DE05311016B0AB061");
|
|
|
+ try {
|
|
|
+ queryCertificate(certVO);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|