Sfoglia il codice sorgente

集成签名模块

sakuya 3 anni fa
parent
commit
2e1a0dd6f1

+ 14 - 83
eladmin-system/src/main/java/me/zhengjie/application/admin/controller/DemoController.java

@@ -1,33 +1,21 @@
 package me.zhengjie.application.admin.controller;
 
-import com.tencentcloudapi.common.exception.TencentCloudSDKException;
 import com.tencentyun.TLSSigAPIv2;
-
-import cfca.trustsign.common.vo.cs.UploadSignInfoVO;
-import cfca.trustsign.constant.Request;
-import cfca.trustsign.util.PdfUtil;
+import lombok.RequiredArgsConstructor;
 import me.zhengjie.annotation.AnonymousAccess;
-import me.zhengjie.annotation.rest.AnonymousPostMapping;
-import me.zhengjie.base.AppBaseResponse;
 import me.zhengjie.base.BaseResponse;
 import me.zhengjie.base.ResultData;
 import me.zhengjie.base.config.AppConfigInfo;
-import me.zhengjie.base.sms.CreateCloudRecording;
-import me.zhengjie.base.sms.TrtcVo;
-import me.zhengjie.base.util.CFCACertUtil;
-import me.zhengjie.base.util.HttpConnector;
 import me.zhengjie.websocket.MsgType;
 import me.zhengjie.websocket.SocketMsg;
 import me.zhengjie.websocket.WebSocketServer;
-import org.apache.commons.io.FileUtils;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.*;
-import java.io.File;
-import java.io.FileInputStream;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
 import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
 import java.util.Map;
 
 /**
@@ -38,11 +26,16 @@ import java.util.Map;
  */
 @Controller
 @RequestMapping("/demo")
+@RequiredArgsConstructor
 public class DemoController {
 
-	@Autowired
-	CreateCloudRecording createCloudRecording;
-
+	/**
+	 * 发送WebSocket信息
+	 *
+	 * @param cid
+	 * @param mesg
+	 * @return
+	 */
 	@ResponseBody
 	@AnonymousAccess
 	@RequestMapping("/socket/push/{cid}")
@@ -72,66 +65,4 @@ public class DemoController {
 		response.setData(new ResultData<String>(s));
 		return response;
 	}
-
-	/**
-	 * 多人签发
-	 *
-	 * @return
-	 * @throws Exception
-	 */
-	@ResponseBody
-	@AnonymousPostMapping("/notarySign")
-	public BaseResponse<?> notarySign(@RequestBody List<UploadSignInfoVO> notaryUserInfos, String fileName)
-			throws Exception {
-
-		BaseResponse<?> response = new BaseResponse<>();
-//    	UploadSignInfoVO notaryUserInfo = new UploadSignInfoVO();
-		// List<UploadSignInfoVO> notaryUserInfos = new ArrayList<>();
-//		notaryUserInfo.setUserId("E06DAAB5F6894542E05312016B0AC8F1");
-//		notaryUserInfo.setSealId("E06DAB4AFAEF4DB7E05311016B0A5154");
-//		notaryUserInfo.setLocation("210.74.41.0");
-//		notaryUserInfo.setAuthorizationTime("20220214171200");
-//		notaryUserInfos.add(notaryUserInfo);
-//		notaryUserInfos.add(notaryUserInfo);
-//		UploadSignInfoVO notaryOfficeInfo = new UploadSignInfoVO();
-//		notaryOfficeInfo.setUserId(notaryOffice.getAxqUserId());
-//		notaryOfficeInfo.setSealId(notaryOffice.getAxqSealId());
-//		notaryOfficeInfo.setLocation("210.74.41.1");
-//		notaryOfficeInfo.setAuthorizationTime("20220214171200");
-		String path = "/home/oss/pdftest/" + fileName;
-		InputStream inputStream = new FileInputStream(path);
-		String contractNO = CFCACertUtil.uploadMultiSignContract(notaryUserInfos, null, null, inputStream, fileName);
-		System.out.println(contractNO);
-		response.setMsg(contractNO);
-		return response;
-	}
-
-	/**
-	 * 多人签发
-	 *
-	 * @return
-	 * @throws Exception
-	 */
-	@ResponseBody
-	@AnonymousPostMapping("/download")
-	public BaseResponse<?> download(@RequestBody Map<String, String> param) throws Exception {
-
-		BaseResponse<?> response = new BaseResponse<>();
-		HttpConnector httpConnector = new HttpConnector();
-		String contractNo = param.get("contractNo");
-		httpConnector.init();
-		String filePath = "platId/" + Request.AXQ_PLAT_ID + "/contractNo/" + contractNo + "/downloading";
-		byte[] fileBtye = httpConnector.getFile(filePath);
-
-		String suffix;
-		if (PdfUtil.isPdf(fileBtye)) {
-			suffix = ".pdf";
-		} else {
-			suffix = ".ofd";
-		}
-		String fullFilePath = "/home/oss/" + contractNo + suffix;
-		FileUtils.writeByteArrayToFile(new File(fullFilePath), fileBtye);
-		return response;
-	}
-
 }

+ 3 - 4
eladmin-system/src/main/java/me/zhengjie/application/admin/job/GenerateNotarizationJob.java

@@ -34,6 +34,7 @@ public class GenerateNotarizationJob {
     private final NotaryOfficeMapper notaryOfficeMapper;
     private final SysUserMapper userDao;
     private final ContractOrderRepository contractOrderRepository;
+    private final CFCACertUtil cfcaCertUtil;
 
     /**
      * 生成签名公证书
@@ -85,11 +86,10 @@ public class GenerateNotarizationJob {
         notaryOfficeInfo.setLocation("210.74.41.1");
         notaryOfficeInfo.setAuthorizationTime("20220214171200");
 
-        CFCACertUtil.proxySwitchOn = "dev".equals(AppConfigInfo.APP_ENV_TYPE);
         String path = orderFile.getPdfUrl();
         InputStream inputStream = FileUploadUtil.getInputStream(path);
         String fileName=FileUploadUtil.getFileName(path);
-        String contractNO = CFCACertUtil.uploadSignContract(notaryUserInfo, notaryOfficeInfo, inputStream,fileName);
+        String contractNO = cfcaCertUtil.uploadSignContract(notaryUserInfo, notaryOfficeInfo, inputStream,fileName);
         orderFile.setAxqContractNo(contractNO);
         // 保存合同编号
         inputStream.close();
@@ -101,10 +101,9 @@ public class GenerateNotarizationJob {
      * @param orderFile
      */
     private void downloadNotarization(OrderFileEntity orderFile) throws Exception {
-        CFCACertUtil.proxySwitchOn = "dev".equals(AppConfigInfo.APP_ENV_TYPE);
         String uplaodPath = orderFile.getBusinessNo() + "/";
         String path = uplaodPath + "notary-signed-" + orderFile.getBusinessNo() + "/";
-        String filePath = CFCACertUtil.download(path, orderFile.getAxqContractNo());
+        String filePath = cfcaCertUtil.download(path, orderFile.getAxqContractNo());
         saveAuthNorizationUrlById(filePath, orderFile.getId());
     }
 

+ 10 - 22
eladmin-system/src/main/java/me/zhengjie/application/admin/service/impl/NotaryOfficeServiceImpl.java

@@ -64,18 +64,14 @@ public class NotaryOfficeServiceImpl extends ServiceImpl<NotaryOfficeMapper, Not
 	private OfficeXbankMapper officeXbankMapper;
 	@Autowired
 	private BankMapper bankMapper;
-	@Value("${app.upload.path}")
-	private String uplaodPath;
-//	@Value("${app.image.url}")
-//	private String imageURL;
-	@Value("${spring.profiles.active}")
-	private String systemEnv;
 	@Autowired
 	private FileInfoMapper fileInfoMapper;
 	@Autowired
 	private FileInfoService fileInfoService;
 	@Autowired
 	private ApplicationContextUtil contextUtil;
+	@Autowired
+	private CFCACertUtil cfcaCertUtil;
 
 	/**
 	 * 查询公证处信息
@@ -189,8 +185,7 @@ public class NotaryOfficeServiceImpl extends ServiceImpl<NotaryOfficeMapper, Not
 	public AppBaseResponse verifyAuthMessage(NotaryOfficeCreateReq req) {
 		AppBaseResponse response = new AppBaseResponse();
 		try {
-			CFCACertUtil.proxySwitchOn = "dev".equals(systemEnv);
-			CFCACertUtil.confirmAuthMessage(req.getAxqUserId(), req.getCheckCode());
+			cfcaCertUtil.confirmAuthMessage(req.getAxqUserId(), req.getCheckCode());
 		} catch (Exception e) {
 			e.printStackTrace();
 			response.fail(ResultCode.AXQ_AUTH_FAIL);
@@ -214,10 +209,8 @@ public class NotaryOfficeServiceImpl extends ServiceImpl<NotaryOfficeMapper, Not
 	public AppBaseResponse sendAuthMessage(String userId) {
 		AppBaseResponse response = new AppBaseResponse();
 		try {
-			CFCACertUtil.proxySwitchOn = "dev".equals(systemEnv);
-			log.info(CFCACertUtil.proxySwitchOn + "");
 			// 发送授权验证码
-			CFCACertUtil.sendAuthMessage(userId);
+			cfcaCertUtil.sendAuthMessage(userId);
 		} catch (Exception e) {
 			e.printStackTrace();
 			response.fail(ResultCode.AXQ_AUTH_MESSAGE_FAIL);
@@ -269,11 +262,10 @@ public class NotaryOfficeServiceImpl extends ServiceImpl<NotaryOfficeMapper, Not
 				userQw.isNull("axq_user_id");
 				List<SysUserEntity> userList = userMapper.selectList(userQw);
 				for (SysUserEntity user : userList) {
-					CFCACertUtil.proxySwitchOn = "dev".equals(systemEnv);
 					// 安心签注册个人用户
 					PersonVO person = PersonVO.builder().personName(user.getNickName()).identNo(user.getIdCard())
 							.mobilePhone(user.getPhone()).build();
-					String userId = CFCACertUtil.registerPerson(person);
+					String userId = cfcaCertUtil.registerPerson(person);
 					//
 					SysUserEntity updateUser = new SysUserEntity();
 					updateUser.setUserId(user.getUserId());
@@ -281,14 +273,13 @@ public class NotaryOfficeServiceImpl extends ServiceImpl<NotaryOfficeMapper, Not
 					userMapper.updateById(updateUser);
 				}
 				if (StringUtils.isEmpty(currentOffice.getAxqUserId())) {
-					CFCACertUtil.proxySwitchOn = "dev".equals(systemEnv);
 					// 注册安心签企业用户
 					EnterpriseVO enterpriseVO = EnterpriseVO.builder().enterpriseName(currentOffice.getName())
 							.identNo(req.getIdentNo()).mobilePhone(req.getAgtMobile())
 							.landlinePhone(currentOffice.getPhone()).build();
 					EnterpriseTransactorVO enterpriseTransactorVO = EnterpriseTransactorVO.builder()
 							.transactorName(req.getAgtName()).identNo(req.getAgtIdentNo()).build();
-					String userId = CFCACertUtil.registerCompany(enterpriseVO, enterpriseTransactorVO);
+					String userId = cfcaCertUtil.registerCompany(enterpriseVO, enterpriseTransactorVO);
 					//
 					NotaryOfficeEntity saveOffice = new NotaryOfficeEntity();
 					saveOffice.setId(req.getId());
@@ -363,16 +354,15 @@ public class NotaryOfficeServiceImpl extends ServiceImpl<NotaryOfficeMapper, Not
 		if (NotaryOfficeConstant.NOTARY_AUTO_GENERATE.equals(entity.getAutoGenerate())) {
 			try {
 				NotaryOfficeEntity saveEntity = new NotaryOfficeEntity();
-				CFCACertUtil.proxySwitchOn = "dev".equals(systemEnv);
 				if (me.zhengjie.utils.StringUtils.isEmpty(entity.getAxqSealId())) {
 					// 上传公证处签章
 					byte[] b = FileUploadUtil.getByte(req.getImageId());
-					String sealId = CFCACertUtil.addSeal(entity.getAxqUserId(), b);
+					String sealId = cfcaCertUtil.addSeal(entity.getAxqUserId(), b);
 					saveEntity.setAxqSealId(sealId);
 				} else {
 					// 修改公证员签章
 					byte[] b = FileUploadUtil.getByte(req.getImageId());
-					CFCACertUtil.updateSeal(entity.getAxqUserId(), entity.getAxqSealId(), b);
+					cfcaCertUtil.updateSeal(entity.getAxqUserId(), entity.getAxqSealId(), b);
 				}
 				saveEntity.setId(req.getId());
 				saveEntity.setSealImg(req.getImageId());
@@ -396,10 +386,9 @@ public class NotaryOfficeServiceImpl extends ServiceImpl<NotaryOfficeMapper, Not
 		NotaryOfficeEntity entity = notaryOfficeMapper.selectById(req.getId());
 		try {
 			if (!me.zhengjie.utils.StringUtils.isEmpty(entity.getAxqUserId())) {
-				CFCACertUtil.proxySwitchOn = "dev".equals(systemEnv);
 				CertVO paramCertVO = new CertVO();
 				paramCertVO.setUserId(entity.getAxqUserId());
-				CertVO returnCertVO = CFCACertUtil.queryCertificate(paramCertVO);
+				CertVO returnCertVO = cfcaCertUtil.queryCertificate(paramCertVO);
 				//
 				SimpleDateFormat inDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
 				Date beginDate = inDateFormat.parse(returnCertVO.getStartTime());
@@ -431,10 +420,9 @@ public class NotaryOfficeServiceImpl extends ServiceImpl<NotaryOfficeMapper, Not
 		NotaryOfficeEntity notaryOffice = notaryOfficeMapper.selectById(req.getId());
 		String authStatus = StringUtils.isEmpty(notaryOffice.getAxqIsAuth())  ? "0" : notaryOffice.getAxqIsAuth();
 		if ("0".equals(authStatus)) {
-			CFCACertUtil.proxySwitchOn = "dev".equals(systemEnv);
 			try {
 				// 发送授权验证码
-				boolean isAuthed = CFCACertUtil.sendAuthMessage(notaryOffice.getAxqUserId());
+				boolean isAuthed = cfcaCertUtil.sendAuthMessage(notaryOffice.getAxqUserId());
 				if (isAuthed) {
 					authStatus = "1";
 					NotaryOfficeEntity saveOffice = new NotaryOfficeEntity();

+ 11 - 23
eladmin-system/src/main/java/me/zhengjie/application/admin/service/impl/UserServiceImpl.java

@@ -71,6 +71,7 @@ public class UserServiceImpl implements UserService {
     private final RedisUtils redisUtils;
     private final OnlineUserService onlineUserService;
     private final ApplicationContextUtil contextUtil;
+    private final CFCACertUtil cfcaCertUtil;
     @Autowired
     private NotaryOfficeMapper notaryOfficeMapper;
     @Autowired
@@ -87,12 +88,6 @@ public class UserServiceImpl implements UserService {
     private ISysJobDao jobDao;
     @Autowired
     private ISysDeptDao deptDao;
-    @Value("${app.upload.path}")
-    private String uplaodPath;
-//    @Value("${app.image.url}")
-//    private String imageURL;
-    @Value("${spring.profiles.active}")
-    private String systemEnv;
     @Autowired
     private UserDomain userDomain;
 
@@ -276,11 +271,10 @@ public class UserServiceImpl implements UserService {
             NotaryOfficeEntity entity = notaryOfficeMapper.selectById(resources.getComId());
             if (NotaryOfficeConstant.NOTARY_AUTO_GENERATE.equals(entity.getAutoGenerate())) {
                 try {
-                    CFCACertUtil.proxySwitchOn = "dev".equals(systemEnv);
                     // 安心签注册个人用户
                     PersonVO person = PersonVO.builder().personName(resources.getNickName())
                             .identNo(resources.getIdCard()).mobilePhone(resources.getPhone()).build();
-                    String userId = CFCACertUtil.registerPerson(person);
+                    String userId = cfcaCertUtil.registerPerson(person);
                     resources.setAxqUserId(userId);
                 } catch (Exception e) {
                     e.printStackTrace();
@@ -292,7 +286,7 @@ public class UserServiceImpl implements UserService {
                 // 安心签注册个人用户
                 PersonVO person = PersonVO.builder().personName(resources.getNickName())
                         .identNo(resources.getIdCard()).mobilePhone(resources.getPhone()).build();
-                String userId = CFCACertUtil.registerPerson(person);
+                String userId = cfcaCertUtil.registerPerson(person);
                 resources.setAxqUserId(userId);
             } catch (Exception e) {
                 e.printStackTrace();
@@ -317,16 +311,15 @@ public class UserServiceImpl implements UserService {
             if (NotaryOfficeConstant.NOTARY_AUTO_GENERATE.equals(entity.getAutoGenerate())) {
                 try {
                     SysUserEntity saveEntity = new SysUserEntity();
-                    CFCACertUtil.proxySwitchOn = "dev".equals(systemEnv);
                     if(StringUtils.isEmpty(user.getAxqSealId())) {
                         // 上传公证员签章,修改通过统一方式得到文件的流
                         byte[] b = FileUploadUtil.getByte(resources.getSignImgId());
-                        String sealId = CFCACertUtil.addSeal(user.getAxqUserId(), b);
+                        String sealId = cfcaCertUtil.addSeal(user.getAxqUserId(), b);
                         saveEntity.setAxqSealId(sealId);
                     } else {
                         // 修改公证员签章
                     	byte[] b = FileUploadUtil.getByte(resources.getSignImgId());  
-                        CFCACertUtil.updateSeal(user.getAxqUserId(), user.getAxqSealId(), b);
+                        cfcaCertUtil.updateSeal(user.getAxqUserId(), user.getAxqSealId(), b);
                     }
                     saveEntity.setUserId(user.getUserId());
                     saveEntity.setSignImgId(resources.getSignImgId());
@@ -339,16 +332,15 @@ public class UserServiceImpl implements UserService {
         }else if(UserConstant.USER_TYPE_BANK.equals(user.getOrgId().split("_")[0])){
         	try {
                 SysUserEntity saveEntity = new SysUserEntity();
-                CFCACertUtil.proxySwitchOn = "dev".equals(systemEnv);
                 if(StringUtils.isEmpty(user.getAxqSealId())) {
                     // 上传公证员签章,修改通过统一方式得到文件的流
                     byte[] b = FileUploadUtil.getByte(resources.getSignImgId());
-                    String sealId = CFCACertUtil.addSeal(user.getAxqUserId(), b);
+                    String sealId = cfcaCertUtil.addSeal(user.getAxqUserId(), b);
                     saveEntity.setAxqSealId(sealId);
                 } else {
                     // 修改公证员签章
                 	byte[] b = FileUploadUtil.getByte(resources.getSignImgId());  
-                    CFCACertUtil.updateSeal(user.getAxqUserId(), user.getAxqSealId(), b);
+                    cfcaCertUtil.updateSeal(user.getAxqUserId(), user.getAxqSealId(), b);
                 }
                 saveEntity.setUserId(user.getUserId());
                 saveEntity.setSignImgId(resources.getSignImgId());
@@ -388,11 +380,10 @@ public class UserServiceImpl implements UserService {
             if (NotaryOfficeConstant.NOTARY_AUTO_GENERATE.equals(entity.getAutoGenerate())) {
                 if (StringUtils.isEmpty(user.getAxqUserId())) {
                     try {
-                        CFCACertUtil.proxySwitchOn = "dev".equals(systemEnv);
                         // 安心签注册个人用户
                         PersonVO person = PersonVO.builder().personName(resources.getNickName())
                                 .identNo(resources.getIdCard()).mobilePhone(resources.getPhone()).build();
-                        String userId = CFCACertUtil.registerPerson(person);
+                        String userId = cfcaCertUtil.registerPerson(person);
                         user.setAxqUserId(userId);
                     } catch (Exception e) {
                         e.printStackTrace();
@@ -522,9 +513,8 @@ public class UserServiceImpl implements UserService {
     @Override
     public void sendAuthMessage(String userId) {
         try {
-            CFCACertUtil.proxySwitchOn = "dev".equals(systemEnv);
             // 发送授权验证码
-            CFCACertUtil.sendAuthMessage(userId);
+            cfcaCertUtil.sendAuthMessage(userId);
         }catch (Exception e){
             e.printStackTrace();
             throw new EntityNotFoundException(User.class, "安心签接口错误", "发送授权验证码出错");
@@ -534,8 +524,7 @@ public class UserServiceImpl implements UserService {
     @Override
     public void verifyAuthMessage(User user) {
         try {
-            CFCACertUtil.proxySwitchOn = "dev".equals(systemEnv);
-            CFCACertUtil.confirmAuthMessage(user.getAxqUserId(), user.getCheckCode());
+            cfcaCertUtil.confirmAuthMessage(user.getAxqUserId(), user.getCheckCode());
         }catch (Exception e){
             e.printStackTrace();
             throw new EntityNotFoundException(User.class, "安心签接口错误", "验证授权验证码出错");
@@ -558,10 +547,9 @@ public class UserServiceImpl implements UserService {
         System.out.println(contextUtil.getCurrentUserId());
         String authStatus = StringUtils.isEmpty(userEntity.getAxqIsAuth()) ? "0" : userEntity.getAxqIsAuth();
         if ("0".equals(authStatus)) {
-            CFCACertUtil.proxySwitchOn = "dev".equals(systemEnv);
             try {
                 // 发送授权验证码
-                boolean isAuthed = CFCACertUtil.sendAuthMessage(userEntity.getAxqUserId());
+                boolean isAuthed = cfcaCertUtil.sendAuthMessage(userEntity.getAxqUserId());
                 if (isAuthed) {
                     authStatus = "1";
                     SysUserEntity saveUser = new SysUserEntity();

+ 9 - 15
eladmin-system/src/main/java/me/zhengjie/application/bank/service/impl/UserAXQInfoServiceImpl.java

@@ -38,8 +38,6 @@ import java.util.List;
 @RequiredArgsConstructor
 public class UserAXQInfoServiceImpl implements UserAXQInfoService {
 
-	@Value("${spring.profiles.active}")
-	private String systemEnv;
 	private final UserAXQInfoRepository userAXQInfoRepository;
 	private final UserAXQInfoMapper userAXQInfoMapper;
 	private final OrderFileRepository orderFileRepository;
@@ -47,16 +45,16 @@ public class UserAXQInfoServiceImpl implements UserAXQInfoService {
 	private final FileInfoMapper fileInfoMapper;
 	private final ContractOrderRepository contractOrderRepository;
 	private final SysUserMapper sysUserMapper;
+	private final CFCACertUtil cfcaCertUtil;
 
 	@Override
 	public ResponseDTO<?> registAXQUser(String idCard, String phone, String name) {
 		try {
 			UserAXQInfoEntity entity = userAXQInfoRepository.getUserAXQInfoWithIdcard(idCard);
 			if (entity == null) {
-				CFCACertUtil.proxySwitchOn = "dev".equals(systemEnv);
 				// 安心签注册个人用户
 				PersonVO person = PersonVO.builder().personName(name).identNo(idCard).mobilePhone(phone).build();
-				String userId = CFCACertUtil.registerPerson(person);
+				String userId = cfcaCertUtil.registerPerson(person);
 				UserAXQInfoEntity userAXQInfoEntity = new UserAXQInfoEntity();
 				userAXQInfoEntity.setIdCard(idCard);
 				userAXQInfoEntity.setUserName(name);
@@ -85,11 +83,10 @@ public class UserAXQInfoServiceImpl implements UserAXQInfoService {
 				FileInfoEntity fileInfo = fileInfoMapper.selectById(imageId);
 				String content = inputStream2Base64(FileUploadUtil.getInputStream(fileInfo.getPath()));
 				UserAXQInfoEntity entity = userAXQInfoRepository.getUserAXQInfoWithIdcard(idCard);
-				CFCACertUtil.proxySwitchOn = "dev".equals(systemEnv);
 				if (!StringUtils.isEmpty(entity.getAxqSealId())) {
-					CFCACertUtil.updateSealWithContent(entity.getAxqUserId(), entity.getAxqSealId(), content);
+					cfcaCertUtil.updateSealWithContent(entity.getAxqUserId(), entity.getAxqSealId(), content);
 				} else {
-					String sealId = CFCACertUtil.addSealWithContent(entity.getAxqUserId(), content);
+					String sealId = cfcaCertUtil.addSealWithContent(entity.getAxqUserId(), content);
 					entity.setAxqSealId(sealId);
 					UserAXQInfoEntity updateEntity = new UserAXQInfoEntity();
 					updateEntity.setId(entity.getId());
@@ -130,9 +127,8 @@ public class UserAXQInfoServiceImpl implements UserAXQInfoService {
 			qw.eq("id_card", idCard);
 			qw.eq("user_status", "1");
 			UserAXQInfoEntity entity = userAXQInfoMapper.selectOne(qw);
-			CFCACertUtil.proxySwitchOn = "dev".equals(systemEnv);
 			// 发送授权验证码
-			CFCACertUtil.sendAuthMessage(entity.getAxqUserId());
+			cfcaCertUtil.sendAuthMessage(entity.getAxqUserId());
 		} catch (Exception e) {
 			e.printStackTrace();
 			return ResponseDTO.error(ResultCode.AXQ_AUTH_MESSAGE_FAIL);
@@ -147,8 +143,7 @@ public class UserAXQInfoServiceImpl implements UserAXQInfoService {
 			qw.eq("id_card", idCard);
 			qw.eq("user_status", "1");
 			UserAXQInfoEntity entity = userAXQInfoMapper.selectOne(qw);
-			CFCACertUtil.proxySwitchOn = "dev".equals(systemEnv);
-			CFCACertUtil.confirmAuthMessage(entity.getAxqUserId(), checkCode);
+			cfcaCertUtil.confirmAuthMessage(entity.getAxqUserId(), checkCode);
 			//
 			UserAXQInfoEntity saveEntiy = new UserAXQInfoEntity();
 			saveEntiy.setId(entity.getId());
@@ -184,9 +179,9 @@ public class UserAXQInfoServiceImpl implements UserAXQInfoService {
 		byte[] b = PdfUtils.mergePdf(list);
 		//将所有需要签名的pdf进行合并
 		InputStream input = new ByteArrayInputStream(b);
-		String axqContractNo = CFCACertUtil.uploadMultiSignContract(signInfoList, null, null, input, fileName);
+		String axqContractNo = cfcaCertUtil.uploadMultiSignContract(signInfoList, null, null, input, fileName);
 		String path = businessNo + "/signed-doc/";
-		String filePath = CFCACertUtil.download(path, axqContractNo);
+		String filePath = cfcaCertUtil.download(path, axqContractNo);
 		for (OrderFileEntity orderFile : orderFileList) {
 			OrderFileEntity updateOrderFile = new OrderFileEntity();
 			updateOrderFile.setId(orderFile.getId());
@@ -237,10 +232,9 @@ public class UserAXQInfoServiceImpl implements UserAXQInfoService {
 				: userAXQInfoEntity.getAxqIsAuth();
 		System.out.println("身份证号:" + idCard + ";授权状态:" + authStatus);
 		if ("0".equals(authStatus)) {
-			CFCACertUtil.proxySwitchOn = "dev".equals(systemEnv);
 			try {
 				// 发送授权验证码
-				boolean isAuthed = CFCACertUtil.sendAuthMessage(userAXQInfoEntity.getAxqUserId());
+				boolean isAuthed = cfcaCertUtil.sendAuthMessage(userAXQInfoEntity.getAxqUserId());
 				if (isAuthed) {
 					authStatus = "1";
 					UserAXQInfoEntity saveEntiy = new UserAXQInfoEntity();

+ 40 - 54
eladmin-system/src/main/java/me/zhengjie/base/util/CFCACertUtil.java

@@ -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();
-		}
-	}
 }

+ 7 - 35
eladmin-system/src/main/java/me/zhengjie/base/util/EQBServiceUtil.java

@@ -1,8 +1,7 @@
 package me.zhengjie.base.util;
 
-import cfca.trustsign.connector.HttpClient;
+import com.alibaba.fastjson.JSONObject;
 import me.zhengjie.utils.FileUtil;
-import net.sf.json.JSONObject;
 import org.apache.commons.codec.binary.Base64;
 
 import javax.crypto.Mac;
@@ -214,31 +213,16 @@ public class EQBServiceUtil {
      * @throws Exception
      */
     public static void downloadSignedContract(String flowId) throws Exception {
-        HttpURLConnection connection = null;
-        HttpClient httpClient = new HttpClient();
         try {
             String accessUrl = "/v1/signflows/" + flowId + "/documents";
             String signature = generateSignature(accessUrl, "", "", "GET");
             LinkedHashMap<String, String> header = getHeaderParam(signature, "");
             System.out.println(header.toString());
             String fullUrl = SERVER_HOST + accessUrl;
-            connection = httpClient.connect(fullUrl, "GET");
-            if (null != header) {
-                for (String key : header.keySet()) {
-                    connection.setRequestProperty(key, header.get(key));
-                }
-            }
-            int responseCode = httpClient.send(connection, (byte[]) null);
-            System.out.println("responseCode:" + responseCode);
-            byte[] fileBytes = null;
-            if (responseCode == 200) {
-                fileBytes = httpClient.receive(connection);
-            }
-            System.out.println(new String(fileBytes));
+            JSONObject jsonObject = HttpUtil.doGetWithHeader(fullUrl, header);
+            System.out.println(jsonObject.toJSONString());
         } catch (Exception e) {
             e.printStackTrace();
-        } finally {
-            httpClient.disconnect(connection);
         }
     }
 
@@ -250,24 +234,12 @@ public class EQBServiceUtil {
      */
     public static void startFolw(String flowId) throws Exception {
         HttpURLConnection connection = null;
-        HttpClient httpClient = new HttpClient();
         String accessUrl = "/v1/signflows/" + flowId + "/start";
         String signature = generateSignature(accessUrl, "", "", "PUT");
         LinkedHashMap<String, String> header = getHeaderParam(signature, "");
         String fullUrl = SERVER_HOST + accessUrl;
-        connection = httpClient.connect(fullUrl, "PUT");
-        if (null != header) {
-            for (String key : header.keySet()) {
-                connection.setRequestProperty(key, header.get(key));
-            }
-        }
-        int responseCode = httpClient.send(connection, (byte[]) null);
-        System.out.println("responseCode:" + responseCode);
-        byte[] fileBytes = null;
-        if (responseCode == 200) {
-            fileBytes = httpClient.receive(connection);
-        }
-        System.out.println(new String(fileBytes));
+        JSONObject jsonObject = HttpUtil.doGetWithHeader(fullUrl, header);
+        System.out.println(jsonObject.toJSONString());
     }
 
     /**
@@ -322,7 +294,7 @@ public class EQBServiceUtil {
         header.put("contentType", "application/octet-stream");
         header.put("contentMD5", getStringContentMD5(filePath));
         String result = HttpUtil.postFile(url, header, filePath);
-        JSONObject resultObj = JSONObject.fromObject(result);
+        JSONObject resultObj = JSONObject.parseObject(result);
         System.out.println(resultObj);
     }
 
@@ -419,7 +391,7 @@ public class EQBServiceUtil {
         // 发送POST请求
         String data = reqBodyObj == null ? null : reqBodyObj.toString();
         String result = HttpUtil.sendPOST(fullAccessUrl, data, getHeaderParam(signature, contentMD5), "UTF-8");
-        JSONObject resultObj = JSONObject.fromObject(result);
+        JSONObject resultObj = JSONObject.parseObject(result);
         System.out.println("请求返回信息: " + resultObj.toString());
         return resultObj;
     }

+ 0 - 242
eladmin-system/src/main/java/me/zhengjie/base/util/HttpConnector.java

@@ -1,242 +0,0 @@
-package me.zhengjie.base.util;
-
-import cfca.trustsign.constant.Request;
-import cfca.trustsign.util.CommonUtil;
-import cn.hutool.core.io.IoUtil;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.net.HttpURLConnection;
-import java.net.URLEncoder;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Map.Entry;
-import cfca.trustsign.connector.HttpClient;
-
-public class HttpConnector {
-	private int connectTimeout;
-	private int readTimeout;
-	private boolean isSSL;
-	private String keyStorePath;
-	private String keyStorePassword;
-	private String trustStorePath;
-	private String trustStorePassword;
-	private String url;
-	private String channel;
-	private HttpClient httpClient;
-	public String isProxyUsed = "0";
-
-	public void init() {
-		this.connectTimeout = Request.AXQ_CONNECT_TIMEOUT;
-		this.readTimeout = Request.AXQ_READ_TIMEOUT;
-		this.isSSL = Request.AXQ_IS_SSL;
-		this.keyStorePath = Request.AXQ_JKS_PATH;
-		this.keyStorePassword = Request.AXQ_JKS_PWD;
-		this.trustStorePath = Request.AXQ_JKS_PATH;
-		this.trustStorePassword = Request.AXQ_JKS_PWD;
-		this.url = Request.AXQ_URL;
-		this.channel = Request.AXQ_CHANNEL;
-		this.httpClient = new HttpClient();
-		this.httpClient.config.connectTimeout = this.connectTimeout;
-		this.httpClient.config.readTimeout = this.readTimeout;
-		this.httpClient.httpConfig.userAgent = "TrustSign FEP";
-		this.httpClient.httpConfig.contentType = "application/x-www-form-urlencoded";
-		this.httpClient.httpConfig.accept = "application/json";
-		this.httpClient.isProxyUsed = this.isProxyUsed;
-
-		try {
-			if (this.isSSL) {
-				this.httpClient.initSSL(this.keyStorePath, this.keyStorePassword.toCharArray(), this.trustStorePath,
-						this.trustStorePassword.toCharArray());
-			}
-		} catch (Exception var2) {
-			var2.printStackTrace();
-		}
-
-		if (!this.url.endsWith("/")) {
-			this.url = this.url + "/";
-		}
-
-	}
-
-	public String post(String uri, String data, String signature) {
-		return this.deal(uri, "POST", this.prepare(data, signature, (Map) null));
-	}
-
-	public String post(String uri, String data, String signature, Map<String, String> map) {
-		return this.deal(uri, "POST", this.prepare(data, signature, map));
-	}
-
-	public String post(String uri, String data, String signature, File file) {
-		return this.dealFile(uri, "POST", data, file, signature);
-	}
-
-	public String post(String uri, String data, String signature, InputStream file,String fileName) {
-		return this.dealFile(uri, "POST", data, file,fileName, signature);
-	}
-
-	public byte[] getFile(String uri) {
-		HttpURLConnection connection = null;
-
-		Object var4;
-		try {
-			connection = this.httpClient.connect(this.url + uri, "GET");
-			int responseCode = this.httpClient.send(connection, (byte[]) null);
-			System.out.println("responseCode:" + responseCode);
-			if (responseCode == 200) {
-				byte[] var10 = this.httpClient.receive(connection);
-				return var10;
-			}
-
-			System.out.println(CommonUtil.getString(this.httpClient.receive(connection)));
-			var4 = null;
-		} catch (Exception var8) {
-			var8.printStackTrace();
-			var4 = null;
-			return (byte[]) var4;
-		} finally {
-			this.httpClient.disconnect(connection);
-		}
-
-		return (byte[]) var4;
-	}
-
-	private String prepare(String data, String signature, Map<String, String> map) {
-		try {
-			StringBuilder request = new StringBuilder();
-			request.append("channel").append("=").append(URLEncoder.encode(this.channel, "UTF-8"));
-			if (CommonUtil.isNotEmpty(data)) {
-				request.append("&").append("data").append("=").append(URLEncoder.encode(data, "UTF-8"));
-			}
-
-			if (CommonUtil.isNotEmpty(signature)) {
-				request.append("&").append("signature").append("=").append(URLEncoder.encode(signature, "UTF-8"));
-			}
-
-			if (CommonUtil.isNotEmpty(map)) {
-				Iterator var5 = map.entrySet().iterator();
-
-				while (var5.hasNext()) {
-					Entry<String, String> pair = (Entry) var5.next();
-					request.append("&").append((String) pair.getKey()).append("=").append(
-							pair.getValue() == null ? "" : URLEncoder.encode((String) pair.getValue(), "UTF-8"));
-				}
-			}
-
-			return request.toString();
-		} catch (UnsupportedEncodingException var7) {
-			return null;
-		}
-	}
-
-	private String deal(String uri, String method, String request) {
-		HttpURLConnection connection = null;
-
-		String var6;
-		try {
-			connection = this.httpClient.connect(this.url + uri, method);
-			int responseCode = this.httpClient.send(connection, request == null ? null : CommonUtil.getBytes(request));
-			System.out.println("responseCode:" + responseCode);
-			var6 = CommonUtil.getString(this.httpClient.receive(connection));
-			return var6;
-		} catch (Exception var10) {
-			var10.printStackTrace();
-			var6 = var10.getMessage();
-		} finally {
-			this.httpClient.disconnect(connection);
-		}
-
-		return var6;
-	}
-
-	private String dealFile(String uri, String method, String request, File file, String signature) {
-		HttpURLConnection connection = null;
-
-		String var8;
-		try {
-			FileInputStream is = new FileInputStream(file);
-			Throwable var33 = null;
-
-			try {
-				connection = this.httpClient.connect(this.url + uri, method);
-				Map<String, String> paramMap = new HashMap(4);
-				paramMap.put("data", request);
-				paramMap.put("signature", signature);
-				int responseCode = this.httpClient.sendFile(connection, paramMap, is, file.getName(),
-						"application/pdf");
-				System.out.println("responseCode:" + responseCode);
-				String var11 = CommonUtil.getString(this.httpClient.receive(connection));
-				return var11;
-			} catch (Throwable var29) {
-				var33 = var29;
-				throw var29;
-			} finally {
-				if (is != null) {
-					if (var33 != null) {
-						try {
-							is.close();
-						} catch (Throwable var28) {
-							var33.addSuppressed(var28);
-						}
-					} else {
-						is.close();
-					}
-				}
-
-			}
-		} catch (Exception var31) {
-			var31.printStackTrace();
-			var8 = var31.getMessage();
-		} finally {
-			this.httpClient.disconnect(connection);
-		}
-
-		return var8;
-	}
-
-	/**
-	 * 处理文件流
-	 * 
-	 * @param uri
-	 * @param method
-	 * @param request
-	 * @param file
-	 * @param signature
-	 * @return
-	 */
-	private String dealFile(String uri, String method, String request, InputStream is, String fileName,
-			String signature) {
-		HttpURLConnection connection = null;
-
-		String var8;
-		try {
-
-			try {
-				connection = this.httpClient.connect(this.url + uri, method);
-				Map<String, String> paramMap = new HashMap<>(4);
-				paramMap.put("data", request);
-				paramMap.put("signature", signature);
-				int responseCode = this.httpClient.sendFile(connection, paramMap, is, fileName, "application/pdf");
-				System.out.println("responseCode:" + responseCode);
-				String var11 = CommonUtil.getString(this.httpClient.receive(connection));
-				return var11;
-			} catch (Throwable var29) {
-
-				throw var29;
-			} finally {
-				IoUtil.close(is);
-
-			}
-		} catch (Exception var31) {
-
-			var8 = var31.getMessage();
-		} finally {
-			this.httpClient.disconnect(connection);
-		}
-
-		return var8;
-	}
-}

+ 54 - 81
eladmin-system/src/main/java/me/zhengjie/base/util/HttpUtil.java

@@ -1,16 +1,12 @@
 package me.zhengjie.base.util;
 
-import java.io.*;
+import com.alibaba.fastjson.JSONObject;
 
+import java.io.*;
 import java.net.*;
 import java.text.MessageFormat;
-import java.util.*;
-
-import cfca.trustsign.connector.HttpClient;
-import com.alibaba.fastjson.JSONObject;
-
-import cfca.trustsign.common.vo.cs.SignKeywordVO;
-import cfca.trustsign.common.vo.cs.UploadSignInfoVO;
+import java.util.LinkedHashMap;
+import java.util.Map;
 
 public class HttpUtil {
 
@@ -314,59 +310,6 @@ public class HttpUtil {
 		return respContent;
 	}
 
-	public static void main(String[] args) throws Exception {
-
-		int i = 0;
-		String pdf = "gzs.pdf";
-
-		String localUrl = "https://flowbb.show.xjrkj.com/demo";
-		// String localUrl = "http://localhost:8000/demo";
-
-		List<UploadSignInfoVO> notaryUserInfos = new ArrayList<>();
-		// --------------------------------------------------------------------------------------
-		UploadSignInfoVO xj = new UploadSignInfoVO();
-		xj.setUserId("E06DAAB5F6894542E05312016B0AC8F1");
-		xj.setSealId("E06DAB4AFAEF4DB7E05311016B0A5154");
-		xj.setLocation("210.74.41.0");
-		xj.setAuthorizationTime("20220214171200");
-		notaryUserInfos.add(xj);
-//		UploadSignInfoVO ttt = new UploadSignInfoVO();
-//		ttt.setUserId("E658B207485F141AE05311016B0A5F19");
-//		ttt.setSealId("E658C5DBBAF1340DE05311016B0A3C4D");
-//		ttt.setLocation("210.74.41.0");
-//		ttt.setAuthorizationTime("20220214171200");
-//		notaryUserInfos.add(ttt);
-		UploadSignInfoVO wcc = new UploadSignInfoVO();
-		wcc.setUserId("E150B42F789F53D8E05311016B0A24B0");
-		wcc.setSealId("E150B90286FA6E31E05312016B0A03F2");
-		wcc.setLocation("210.74.41.0");
-		wcc.setAuthorizationTime("20220214171200");
-		notaryUserInfos.add(wcc);
-		for (UploadSignInfoVO user : notaryUserInfos) {
-			String x = String.valueOf(10 + i * 70);
-			i++;
-			SignKeywordVO keywordNotaryUser = CFCACertUtil.getSignKeywork("签章:", x, "0", "80", "40");
-			CFCACertUtil.setSignInfoDefault(user, keywordNotaryUser);
-		}
-		// --------------------------------------------------------------------------------------
-//		SignKeywordVO keywordNotaryOffice = CFCACertUtil.getSignKeywork("签章", "0", "0", "150", "150");
-//		if (notaryOffice != null) {
-//			setSignInfoDefault(notaryOffice, keywordNotaryOffice);
-//			signInfos.add(notaryOffice);
-//		}
-
-		String result = HttpUtil.sendPost(localUrl + "/notarySign?fileName=" + pdf,
-				JSONObject.toJSONString(notaryUserInfos));
-		JSONObject jsonObj = JSONObject.parseObject(result);
-		System.out.println(jsonObj.getString("msg") + ".pdf");
-		Map<String, String> param = new HashMap<String, String>();
-		param.put("contractNo", jsonObj.getString("msg"));
-		result = HttpUtil.sendPost(localUrl + "/download", JSONObject.toJSONString(param));
-		System.out.println(result);
-//		System.out.println("用户近6个月平均话费评分:" + result);
-
-	}
-
 	/**
 	 * 发送带Header信息的Get请求
 	 *
@@ -376,56 +319,86 @@ public class HttpUtil {
 	 */
 	public static JSONObject doGetWithHeader(String url, Map<String, String> header) {
 		HttpURLConnection connection = null;
-		HttpClient httpClient = new HttpClient();
 		JSONObject returnMsg = null;
 		try {
-			connection = httpClient.connect(url, "GET");
+			URL realUrl = new URL(url);
+			// 打开和URL之间的连接
+			connection = (HttpURLConnection) realUrl.openConnection();
 			if (null != header) {
 				for (String key : header.keySet()) {
 					connection.setRequestProperty(key, header.get(key));
 				}
 			}
-			int responseCode = httpClient.send(connection, (byte[]) null);
-			System.out.println("responseCode:" + responseCode);
-			byte[] fileBytes = null;
-			if (responseCode == 200) {
-				fileBytes = httpClient.receive(connection);
+			connection.setRequestMethod("GET");
+			connection.connect();
+			// 获取返回信息
+			int statusCode = connection.getResponseCode();
+			String respMessage = connection.getResponseMessage();
+			String respContent = "";
+			// 获得响应内容
+			if (HttpURLConnection.HTTP_OK == statusCode) {
+				// 返回响应结果
+				respContent = getResponseContent(connection);
+			} else {
+				// 返回非200状态时响应结果
+				respContent = getErrorResponseContent(connection);
+				String msg = MessageFormat.format("请求失败: Http状态码 = {0} , {1}", statusCode, respMessage);
+				System.out.println(msg);
 			}
-			String message = new String(fileBytes);
-			returnMsg = JSONObject.parseObject(message);
+			returnMsg = JSONObject.parseObject(respContent);
 			System.out.println(returnMsg);
 		} catch (Exception e) {
 			e.printStackTrace();
 		} finally {
-			httpClient.disconnect(connection);
+			connection.disconnect();
 		}
 		return returnMsg;
 	}
 
 	public static JSONObject doPostWithHeaderAndBody(String url, Map<String, String> header, JSONObject body) {
 		HttpURLConnection connection = null;
-		HttpClient httpClient = new HttpClient();
 		JSONObject returnMsg = null;
+		OutputStream out = null;
 		try {
-			connection = httpClient.connect(url, "POST");
+			URL realUrl = new URL(url);
+			// 打开和URL之间的连接
+			connection = (HttpURLConnection) realUrl.openConnection();
 			if (null != header) {
 				for (String key : header.keySet()) {
 					connection.setRequestProperty(key, header.get(key));
 				}
 			}
-			int responseCode = httpClient.send(connection, body.toString().getBytes());
-			System.out.println("responseCode:" + responseCode);
-			byte[] fileBytes = null;
-			if (responseCode == 200) {
-				fileBytes = httpClient.receive(connection);
+			// 发送POST请求必须设置如下两行
+			connection.setDoOutput(true);
+			connection.setDoInput(true);
+			connection.setRequestMethod("POST");
+			connection.connect();
+			// 发送请求内容
+			out = new DataOutputStream(connection.getOutputStream());
+			byte[] bufferOut = body.toString().getBytes();
+			out.write(bufferOut);
+			out.flush();
+			out.close();
+			// 获取返回信息
+			int statusCode = connection.getResponseCode();
+			String respMessage = connection.getResponseMessage();
+			String respContent="";
+			// 获得响应内容
+			if (HttpURLConnection.HTTP_OK == statusCode) {
+				// 返回响应结果
+				respContent = getResponseContent(connection);
+			} else {
+				// 返回非200状态时响应结果
+				respContent = getErrorResponseContent(connection);
+				String msg = MessageFormat.format("请求失败: Http状态码 = {0} , {1}", statusCode, respMessage);
+				System.out.println(msg);
 			}
-			String message = new String(fileBytes);
-			returnMsg = JSONObject.parseObject(message);
+			returnMsg = JSONObject.parseObject(respContent);
 			System.out.println(returnMsg);
 		} catch (Exception e) {
 			e.printStackTrace();
 		} finally {
-			httpClient.disconnect(connection);
+			connection.disconnect();
 		}
 		return returnMsg;
 	}