CFCACertUtil.java 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. package me.zhengjie.base.util;
  2. import cfca.sadk.algorithm.common.PKIException;
  3. import cfca.sadk.util.Base64;
  4. import cfca.trustsign.common.vo.cs.*;
  5. import cfca.trustsign.common.vo.request.tx3.*;
  6. import cfca.trustsign.common.vo.response.ErrorResVO;
  7. import cfca.trustsign.common.vo.response.tx3.*;
  8. import com.alibaba.fastjson.JSONObject;
  9. import com.fasterxml.jackson.databind.ObjectMapper;
  10. import lombok.RequiredArgsConstructor;
  11. import lombok.extern.slf4j.Slf4j;
  12. import me.zhengjie.application.admin.service.DictDetailService;
  13. import me.zhengjie.sign.connector.HttpConnector;
  14. import me.zhengjie.sign.converter.JsonObjectMapper;
  15. import me.zhengjie.sign.util.PdfUtil;
  16. import me.zhengjie.sign.util.SecurityUtil;
  17. import me.zhengjie.sign.util.TimeUtil;
  18. import me.zhengjie.utils.SpringContextHolder;
  19. import org.springframework.stereotype.Component;
  20. import java.io.File;
  21. import java.io.InputStream;
  22. import java.util.List;
  23. import java.util.Map;
  24. @Component
  25. @Slf4j
  26. @RequiredArgsConstructor
  27. public class CFCACertUtil {
  28. private final HttpConnector httpConnector;
  29. private static final int PROXY_SIGN_ON = 1;
  30. private static final String PROJECT_CODE = "005";
  31. private static final String AUTH_MODE = "公安部";
  32. /**
  33. * 注册安心签企业用户
  34. *
  35. * @param enterprise 企业信息
  36. * @param enterpriseTransactor 企业经办人信息
  37. * @return 安心签用户ID
  38. * @throws Exception
  39. */
  40. public String registerCompany(EnterpriseVO enterprise, EnterpriseTransactorVO enterpriseTransactor)
  41. throws Exception {
  42. enterprise.setAuthenticationTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
  43. enterprise.setAuthenticationMode(AUTH_MODE);
  44. enterprise.setIdentTypeCode("N");
  45. enterpriseTransactor.setIdentTypeCode("0");
  46. Tx3002ReqVO tx3002ReqVO = new Tx3002ReqVO();
  47. tx3002ReqVO.setHead(HeadVO.builder().txTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14)).build());
  48. tx3002ReqVO.setEnterprise(enterprise);
  49. tx3002ReqVO.setEnterpriseTransactor(enterpriseTransactor);
  50. String response = requestAPI(tx3002ReqVO, "3002");
  51. if (!isSucess(response)) {
  52. ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
  53. System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
  54. throw new Exception("安心签服务请求失败");
  55. }
  56. Tx3002ResVO tx3002ResVO = new ObjectMapper().readValue(response, Tx3002ResVO.class);
  57. return tx3002ResVO.getEnterprise().getUserId();
  58. }
  59. /**
  60. * 注册安心签个人用户
  61. *
  62. * @throws Exception
  63. */
  64. public String registerPerson(PersonVO person) throws Exception {
  65. person.setAuthenticationTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
  66. person.setAuthenticationMode(AUTH_MODE);
  67. Tx3001ReqVO tx3001ReqVO = new Tx3001ReqVO();
  68. tx3001ReqVO.setHead(HeadVO.builder().txTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14)).build());
  69. tx3001ReqVO.setPerson(person);
  70. String response = requestAPI(tx3001ReqVO, "3001");
  71. if (!isSucess(response)) {
  72. ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
  73. System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
  74. throw new Exception("安心签服务请求失败");
  75. }
  76. Tx3001ResVO tx3001ResVO = new ObjectMapper().readValue(response, Tx3001ResVO.class);
  77. return tx3001ResVO.getPerson().getUserId();
  78. }
  79. /**TODO 暂时没有用到
  80. * 查询证书信息
  81. *
  82. * @param cert
  83. * @return
  84. * @throws Exception
  85. */
  86. public CertVO queryCertificate(CertVO cert) throws Exception {
  87. Tx3311ReqVO tx3311ReqVO = new Tx3311ReqVO();
  88. tx3311ReqVO.setHead(HeadVO.builder().txTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14)).build());
  89. tx3311ReqVO.setCert(cert);
  90. String response = requestAPI(tx3311ReqVO, "3311");
  91. if (!isSucess(response)) {
  92. ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
  93. System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
  94. throw new Exception("安心签服务请求失败");
  95. }
  96. Tx3311ResVO tx3311ResVO = new ObjectMapper().readValue(response, Tx3311ResVO.class);
  97. return tx3311ResVO.getCert();
  98. }
  99. // 9. 修改印章3012
  100. // 此接口用于客户平台修改某用户的印章图片。客户平台可以调用此接口修改某用户指定印章ID的印章图片。
  101. public void updateSealWithContent(String userId, String sealId, String content) throws Exception {
  102. HeadVO head = new HeadVO();
  103. head.setTxTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
  104. SealVO sealVO = new SealVO();
  105. sealVO.setSealId(sealId);
  106. sealVO.setImageData(content);
  107. SealUpdateVO sealUpdateVO = new SealUpdateVO();
  108. sealUpdateVO.setUserId(userId);
  109. sealUpdateVO.setSeal(sealVO);
  110. Tx3012ReqVO tx3012ReqVO = new Tx3012ReqVO();
  111. tx3012ReqVO.setHead(head);
  112. tx3012ReqVO.setSealUpdate(sealUpdateVO);
  113. String response = requestAPI(tx3012ReqVO, "3012");
  114. if (!isSucess(response)) {
  115. ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
  116. System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
  117. throw new Exception("安心签服务请求失败");
  118. }
  119. }
  120. /**
  121. * 修改签章
  122. *
  123. * @param userId
  124. * @param sealId
  125. * @param b
  126. * @throws Exception
  127. */
  128. public void updateSeal(String userId, String sealId, byte[] b) throws Exception {
  129. // 这里将图片的路径下载文件
  130. // byte[] b=DownloadUtils.downloadFile(filePath);
  131. String content = Base64.toBase64String(b);
  132. updateSealWithContent(userId, sealId, content);
  133. }
  134. /**
  135. * 为指定用户添加印章
  136. *
  137. * @param userId
  138. * @param content
  139. * @return 返回印章ID
  140. * @throws Exception
  141. */
  142. public String addSealWithContent(String userId, String content) throws Exception {
  143. HeadVO head = new HeadVO();
  144. head.setTxTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
  145. SealAddVO sealAddVO = new SealAddVO();
  146. sealAddVO.setUserId(userId);
  147. SealVO sealVO = new SealVO();
  148. sealVO.setImageData(content);
  149. sealAddVO.setSeal(sealVO);
  150. Tx3011ReqVO tx3011ReqVO = new Tx3011ReqVO();
  151. tx3011ReqVO.setHead(head);
  152. tx3011ReqVO.setSealAdd(sealAddVO);
  153. String response = requestAPI(tx3011ReqVO, "3011");
  154. if (!isSucess(response)) {
  155. ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
  156. System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
  157. throw new Exception("安心签服务请求失败");
  158. }
  159. Tx3011ResVO tx3011ResVO = new ObjectMapper().readValue(response, Tx3011ResVO.class);
  160. return tx3011ResVO.getSealAdd().getSeal().getSealId();
  161. }
  162. /**
  163. * 为指定用户添加印章
  164. *
  165. * @param userId
  166. * @param b
  167. * @return 返回印章ID
  168. * @throws Exception
  169. */
  170. public String addSeal(String userId, byte[] b) throws Exception {
  171. String content = Base64.toBase64String(b);
  172. return addSealWithContent(userId, content);
  173. }
  174. /**
  175. * 对指定用户发送授权验证码
  176. *
  177. * @param userId
  178. * @throws Exception
  179. */
  180. public boolean sendAuthMessage(String userId) throws Exception {
  181. Tx3101ReqVO tx3101ReqVO = new Tx3101ReqVO();
  182. HeadVO head = new HeadVO();
  183. head.setTxTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
  184. ProxySignVO proxySignVO = new ProxySignVO();
  185. proxySignVO.setUserId(userId);
  186. proxySignVO.setProjectCode(PROJECT_CODE);
  187. tx3101ReqVO.setHead(head);
  188. tx3101ReqVO.setProxySign(proxySignVO);
  189. String response = requestAPI(tx3101ReqVO, "3101");
  190. if (!isSucess(response)) {
  191. ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
  192. System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
  193. if (!"60030401".equals(errorResVO.getErrorCode())) {
  194. throw new Exception("安心签服务请求失败");
  195. } else {
  196. return true;
  197. }
  198. }
  199. return false;
  200. }
  201. /**
  202. * 确认授权验证码
  203. *
  204. * @param userId
  205. * @param checkCode
  206. * @throws Exception
  207. */
  208. public void confirmAuthMessage(String userId, String checkCode) throws Exception {
  209. Tx3102ReqVO tx3102ReqVO = new Tx3102ReqVO();
  210. HeadVO head = new HeadVO();
  211. head.setTxTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
  212. ProxySignVO proxySignVO = new ProxySignVO();
  213. proxySignVO.setUserId(userId);
  214. proxySignVO.setProjectCode(PROJECT_CODE);
  215. proxySignVO.setCheckCode(checkCode);
  216. tx3102ReqVO.setHead(head);
  217. tx3102ReqVO.setProxySign(proxySignVO);
  218. String response = requestAPI(tx3102ReqVO, "3102");
  219. if (!isSucess(response)) {
  220. ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
  221. System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
  222. throw new Exception("安心签服务请求失败");
  223. }
  224. }
  225. /**
  226. * 上传签署合同
  227. *
  228. * @param notaryUser 公证员签名信息
  229. * @param notaryOffice 公证处签名信息
  230. * @param file 签名文件
  231. * @return 返回合同编号
  232. * @throws Exception
  233. */
  234. public String uploadSignContract(UploadSignInfoVO notaryUser, UploadSignInfoVO notaryOffice,
  235. InputStream file, String fileName) throws Exception {
  236. DictDetailService dictDetailService = SpringContextHolder.getBean(DictDetailService.class);
  237. Map<String, String> map = dictDetailService.getValueByName("signed_position");
  238. // signed 公证员签名
  239. // 公证员签名
  240. String signed = map.get("signed");
  241. JSONObject json = JSONObject.parseObject(signed);
  242. String keyword = json.getString("keyword");
  243. String offsetX = json.getString("offsetX");
  244. String offsetY = json.getString("offsetY");
  245. String width = json.getString("width");
  246. String height = json.getString("height");
  247. SignKeywordVO keywordNotaryUser = getSignKeywork(keyword, offsetX, offsetY, width, height);
  248. setSignInfoDefault(notaryUser, keywordNotaryUser);
  249. // 盖章
  250. String stamp = map.get("stamp");
  251. json = JSONObject.parseObject(stamp);
  252. keyword = json.getString("keyword");
  253. offsetX = json.getString("offsetX");
  254. offsetY = json.getString("offsetY");
  255. width = json.getString("width");
  256. height = json.getString("height");
  257. SignKeywordVO keywordNotaryOffice = getSignKeywork(keyword, offsetX, offsetY, width, height);
  258. setSignInfoDefault(notaryOffice, keywordNotaryOffice);
  259. UploadSignInfoVO[] signInfos = { notaryUser, notaryOffice };
  260. UploadContractVO uploadContract = new UploadContractVO();
  261. uploadContract.setSignInfos(signInfos);
  262. uploadContract.setContractTypeCode("WT");
  263. uploadContract.setContractName("赋强公证");
  264. HeadVO head = new HeadVO();
  265. head.setTxTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
  266. Tx3203ReqVO tx3203ReqVO = new Tx3203ReqVO();
  267. tx3203ReqVO.setHead(head);
  268. tx3203ReqVO.setUploadContract(uploadContract);
  269. String response = requestAPI(tx3203ReqVO, "3203", file, fileName);
  270. if (!isSucess(response)) {
  271. ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
  272. System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
  273. throw new Exception("安心签服务请求失败");
  274. }
  275. Tx3203ResVO tx3203ResVO = new ObjectMapper().readValue(response, Tx3203ResVO.class);
  276. return tx3203ResVO.getContract().getContractNo();
  277. }
  278. // /**
  279. // * 上传签署合同
  280. // *
  281. // * @param user
  282. // * @param file
  283. // * @return
  284. // * @throws Exception
  285. // */
  286. // public static String uploadSignContract(UploadSignInfoVO user, InputStream file, String fileName) throws Exception {
  287. //
  288. // SignKeywordVO keywordUser = getSignKeywork(Constants.signed, "70", "0", "160", "60");
  289. // setSignInfoDefault(user, keywordUser);
  290. //
  291. // UploadSignInfoVO[] signInfos = { user };
  292. // UploadContractVO uploadContract = new UploadContractVO();
  293. // uploadContract.setSignInfos(signInfos);
  294. // uploadContract.setContractTypeCode("WT");
  295. // uploadContract.setContractName("赋强公证");
  296. //
  297. // HeadVO head = new HeadVO();
  298. // head.setTxTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
  299. //
  300. // Tx3203ReqVO tx3203ReqVO = new Tx3203ReqVO();
  301. // tx3203ReqVO.setHead(head);
  302. // tx3203ReqVO.setUploadContract(uploadContract);
  303. // // 读取文件的流,TODO
  304. // String response = requestAPI(tx3203ReqVO, "3203", file, fileName);
  305. // if (!isSucess(response)) {
  306. // ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
  307. // System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
  308. // throw new Exception("安心签服务请求失败");
  309. // }
  310. // Tx3203ResVO tx3203ResVO = new ObjectMapper().readValue(response, Tx3203ResVO.class);
  311. // return tx3203ResVO.getContract().getContractNo();
  312. // }
  313. /**
  314. * 下载签名公证书
  315. *
  316. * @param filePath
  317. * @param contractNo
  318. * @throws Exception
  319. */
  320. public String download(String filePath, String contractNo) throws Exception {
  321. byte[] fileBtye = httpConnector
  322. .getFile("platId/" + httpConnector.getPlatID() + "/contractNo/" + contractNo + "/downloading");
  323. String contentType;
  324. String suffix;
  325. if (PdfUtil.isPdf(fileBtye)) {
  326. contentType = "application/pdf";
  327. suffix = ".pdf";
  328. } else {
  329. contentType = "application/ofd";
  330. suffix = ".ofd";
  331. }
  332. String fullFilePath = filePath + contractNo + suffix;
  333. // 上传文件路径
  334. log.info("上传文件的目录:" + fullFilePath);
  335. FileUploadUtil.uploadFile(fullFilePath, contentType, fileBtye);
  336. return fullFilePath;
  337. }
  338. /**
  339. * 发送安心签API请求
  340. *
  341. * @param txReqVO
  342. * @param txCode
  343. * @return
  344. * @throws Exception
  345. */
  346. private String requestAPI(Object txReqVO, String txCode) throws Exception {
  347. return requestAPI(txReqVO, txCode, null);
  348. }
  349. /**
  350. * 发送安心签API请求
  351. *
  352. * @param txReqVO
  353. * @param txCode
  354. * @throws PKIException
  355. */
  356. private String requestAPI(Object txReqVO, String txCode, File file) throws Exception {
  357. String req = new JsonObjectMapper().writeValueAsString(txReqVO);
  358. System.out.println("req:" + req);
  359. String signature = SecurityUtil.p7SignMessageDetach(httpConnector.getKeyStorePath(), httpConnector.getKeyStorePassword(),
  360. httpConnector.getAlias(), req);
  361. String res = "";
  362. if ("3203".equals(txCode)) {
  363. res = httpConnector.post("platId/" + httpConnector.getPlatID() + "/txCode/" + txCode + "/transaction", req,
  364. signature, file);
  365. } else {
  366. res = httpConnector.post("platId/" + httpConnector.getPlatID() + "/txCode/" + txCode + "/transaction", req,
  367. signature);
  368. }
  369. System.out.println("res:" + res);
  370. return res;
  371. }
  372. /**
  373. * 发送安心签API请求
  374. *
  375. * @param txReqVO
  376. * @param txCode
  377. * @throws PKIException
  378. */
  379. private String requestAPI(Object txReqVO, String txCode, InputStream file, String fileName)
  380. throws Exception {
  381. String req = new JsonObjectMapper().writeValueAsString(txReqVO);
  382. System.out.println("req:" + req);
  383. String signature = SecurityUtil.p7SignMessageDetach(httpConnector.getKeyStorePath(), httpConnector.getKeyStorePassword(),
  384. httpConnector.getAlias(), req);
  385. String res = "";
  386. if ("3203".equals(txCode)) {
  387. res = httpConnector.post("platId/" + httpConnector.getPlatID() + "/txCode/" + txCode + "/transaction", req,
  388. signature, file, fileName);
  389. } else {
  390. res = httpConnector.post("platId/" + httpConnector.getPlatID() + "/txCode/" + txCode + "/transaction", req,
  391. signature);
  392. }
  393. System.out.println("res:" + res);
  394. return res;
  395. }
  396. /**
  397. * 多个人签证,最多三个人
  398. **
  399. * @param notaryUserInfos 签名多个,包含了可能是借款人,抵押人,担保人
  400. * @param notaryUser 公证员签名信息
  401. * @param seal 盖章的位置
  402. * @param file 文件的
  403. * @param fileName 文件名称
  404. * @return 返回合同编号
  405. * @throws Exception
  406. */
  407. public String uploadMultiSignContract(List<UploadSignInfoVO> notaryUserInfos, UploadSignInfoVO notaryUser,
  408. UploadSignInfoVO seal, InputStream file, String fileName) throws Exception {
  409. DictDetailService dictDetailService = SpringContextHolder.getBean(DictDetailService.class);
  410. Map<String, String> map = dictDetailService.getValueByName("signed_position");
  411. int i = 0;
  412. String signature = map.get("signature");
  413. JSONObject json = JSONObject.parseObject(signature);
  414. int start = json.getIntValue("start");
  415. int step = json.getIntValue("step");
  416. String keyword = json.getString("keyword");
  417. String offsetY = json.getString("offsetY");
  418. String width = json.getString("width");
  419. String height = json.getString("height");
  420. for (UploadSignInfoVO user : notaryUserInfos) {
  421. String x = String.valueOf(start + i * step);
  422. i++;
  423. SignKeywordVO keywordNotaryUser = getSignKeywork(keyword, x, offsetY, width, height);
  424. setSignInfoDefault(user, keywordNotaryUser);
  425. }
  426. // 公证员签名
  427. String signed = map.get("signed");
  428. json = JSONObject.parseObject(signed);
  429. keyword = json.getString("keyword");
  430. String offsetX = json.getString("offsetX");
  431. offsetY = json.getString("offsetY");
  432. width = json.getString("width");
  433. height = json.getString("height");
  434. // 公证员签名
  435. if (notaryUser != null) {
  436. SignKeywordVO keywordNotaryUser = getSignKeywork(keyword, offsetX, offsetY, width, height);
  437. setSignInfoDefault(notaryUser, keywordNotaryUser);
  438. notaryUserInfos.add(notaryUser);
  439. }
  440. // 盖章
  441. String stamp = map.get("stamp");
  442. json = JSONObject.parseObject(stamp);
  443. keyword = json.getString("keyword");
  444. offsetX = json.getString("offsetX");
  445. offsetY = json.getString("offsetY");
  446. width = json.getString("width");
  447. height = json.getString("height");
  448. if (seal != null) {
  449. SignKeywordVO keywordNotaryOffice = getSignKeywork(keyword, offsetX, offsetY, width, height);
  450. setSignInfoDefault(seal, keywordNotaryOffice);
  451. notaryUserInfos.add(seal);
  452. }
  453. UploadContractVO uploadContract = new UploadContractVO();
  454. uploadContract.setSignInfos(notaryUserInfos.toArray(new UploadSignInfoVO[0]));
  455. uploadContract.setContractTypeCode("WT");
  456. uploadContract.setContractName("赋强公证");
  457. HeadVO head = new HeadVO();
  458. head.setTxTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
  459. Tx3203ReqVO tx3203ReqVO = new Tx3203ReqVO();
  460. tx3203ReqVO.setHead(head);
  461. tx3203ReqVO.setUploadContract(uploadContract);
  462. String response = requestAPI(tx3203ReqVO, "3203", file, fileName);
  463. if (!isSucess(response)) {
  464. ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
  465. System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
  466. throw new Exception("安心签服务请求失败");
  467. }
  468. Tx3203ResVO tx3203ResVO = new ObjectMapper().readValue(response, Tx3203ResVO.class);
  469. return tx3203ResVO.getContract().getContractNo();
  470. }
  471. /**
  472. * 设置签名默认信息
  473. *
  474. * @param signInfo
  475. * @param keyword
  476. */
  477. public void setSignInfoDefault(UploadSignInfoVO signInfo, SignKeywordVO keyword) {
  478. signInfo.setIsProxySign(PROXY_SIGN_ON);
  479. signInfo.setProjectCode(PROJECT_CODE);
  480. signInfo.setIsCheckProjectCode(0);
  481. signInfo.setSignKeyword(keyword);
  482. }
  483. /**
  484. * 获得签名定位关键词对象
  485. *
  486. * @param keyword
  487. * @param offsetX
  488. * @param offsetY
  489. * @param width
  490. * @param height
  491. * @return
  492. */
  493. public SignKeywordVO getSignKeywork(String keyword, String offsetX, String offsetY, String width,
  494. String height) {
  495. SignKeywordVO signKeyword = new SignKeywordVO();
  496. signKeyword.setKeyword(keyword);
  497. signKeyword.setOffsetCoordX(offsetX);
  498. signKeyword.setOffsetCoordY(offsetY);
  499. signKeyword.setImageWidth(width);
  500. signKeyword.setImageHeight(height);
  501. return signKeyword;
  502. }
  503. /**
  504. * 判断请求是否成功
  505. *
  506. * @param response
  507. * @return
  508. */
  509. private boolean isSucess(String response) {
  510. if (response.indexOf("\"head\"") < 0) {
  511. return false;
  512. }
  513. return true;
  514. }
  515. }