Commit 385fd353 authored by 杨郁彬's avatar 杨郁彬

增加CIS文件jiajiemi方法

parent bc5a37e8
...@@ -14,6 +14,7 @@ import javax.servlet.http.HttpServletRequest; ...@@ -14,6 +14,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import com.cesgroup.bdc.cis.service.CisService;
import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -25,7 +26,6 @@ import org.springframework.web.bind.annotation.RequestParam; ...@@ -25,7 +26,6 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest; import org.springframework.web.multipart.MultipartHttpServletRequest;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cesgroup.bdc.attachment.dto.FileUploaderResponseDto; import com.cesgroup.bdc.attachment.dto.FileUploaderResponseDto;
import com.cesgroup.bdc.attachment.entity.Attachment; import com.cesgroup.bdc.attachment.entity.Attachment;
...@@ -38,7 +38,6 @@ import com.cesgroup.bdc.util.DownloadUtil; ...@@ -38,7 +38,6 @@ import com.cesgroup.bdc.util.DownloadUtil;
import com.cesgroup.kingkong.core.security.model.IOrganization; import com.cesgroup.kingkong.core.security.model.IOrganization;
import com.cesgroup.kingkong.core.security.model.IUser; import com.cesgroup.kingkong.core.security.model.IUser;
import com.cesgroup.kingkong.web.BaseServiceController; import com.cesgroup.kingkong.web.BaseServiceController;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.IoUtil; import cn.hutool.core.io.IoUtil;
...@@ -60,6 +59,9 @@ public class AttachmentController extends BaseServiceController<Attachment, IAtt ...@@ -60,6 +59,9 @@ public class AttachmentController extends BaseServiceController<Attachment, IAtt
@Autowired @Autowired
private ILogsService logsService; private ILogsService logsService;
@Autowired
private CisService cisService;
/** /**
* 默认文件存储路径 * 默认文件存储路径
*/ */
...@@ -307,6 +309,8 @@ public class AttachmentController extends BaseServiceController<Attachment, IAtt ...@@ -307,6 +309,8 @@ public class AttachmentController extends BaseServiceController<Attachment, IAtt
mFile.transferTo(newFile); mFile.transferTo(newFile);
//文件加密
cisService.encryptedFile(newFile);
DiskFile diskFile = diskFileService.getById(attachment.getDiskFileId()); DiskFile diskFile = diskFileService.getById(attachment.getDiskFileId());
// 更新文件大小 // 更新文件大小
......
...@@ -81,4 +81,8 @@ public interface IAttachmentService extends IService<Attachment> { ...@@ -81,4 +81,8 @@ public interface IAttachmentService extends IService<Attachment> {
void addNewOfd(Attachment attachment); void addNewOfd(Attachment attachment);
File getFile(Attachment attachment); File getFile(Attachment attachment);
String getEncryptedPath(String plainPath);
boolean guessDecrytedFile(File plainFile);
} }
...@@ -10,6 +10,7 @@ import com.cesgroup.bdc.attachment.entity.DiskFile; ...@@ -10,6 +10,7 @@ import com.cesgroup.bdc.attachment.entity.DiskFile;
import com.cesgroup.bdc.attachment.mapper.AttachmentMapper; import com.cesgroup.bdc.attachment.mapper.AttachmentMapper;
import com.cesgroup.bdc.attachment.service.IAttachmentService; import com.cesgroup.bdc.attachment.service.IAttachmentService;
import com.cesgroup.bdc.attachment.service.IDiskFileService; import com.cesgroup.bdc.attachment.service.IDiskFileService;
import com.cesgroup.bdc.cis.service.CisService;
import com.cesgroup.bdc.suwell.service.SuwellService; import com.cesgroup.bdc.suwell.service.SuwellService;
import com.cesgroup.bdc.util.FileReadUtil; import com.cesgroup.bdc.util.FileReadUtil;
import com.cesgroup.bdc.util.PrimaryKey; import com.cesgroup.bdc.util.PrimaryKey;
...@@ -47,6 +48,9 @@ public class AttachmentServiceImpl extends ServiceImpl<AttachmentMapper, Attachm ...@@ -47,6 +48,9 @@ public class AttachmentServiceImpl extends ServiceImpl<AttachmentMapper, Attachm
@Autowired @Autowired
private SuwellService suwellService; private SuwellService suwellService;
@Autowired
private CisService cisService;
/** /**
* 默认文件存储路径 * 默认文件存储路径
*/ */
...@@ -179,6 +183,9 @@ public class AttachmentServiceImpl extends ServiceImpl<AttachmentMapper, Attachm ...@@ -179,6 +183,9 @@ public class AttachmentServiceImpl extends ServiceImpl<AttachmentMapper, Attachm
destFile = new File(fileBasePath + relativePath + fileName); destFile = new File(fileBasePath + relativePath + fileName);
mFile.transferTo(destFile);//保存到目标位置 mFile.transferTo(destFile);//保存到目标位置
//文件加密
cisService.encryptedFile(destFile);
DiskFile diskFile = new DiskFile(); DiskFile diskFile = new DiskFile();
diskFile.setId(PrimaryKey.generateId()); diskFile.setId(PrimaryKey.generateId());
diskFile.setFileName(fileName); diskFile.setFileName(fileName);
...@@ -253,7 +260,9 @@ public class AttachmentServiceImpl extends ServiceImpl<AttachmentMapper, Attachm ...@@ -253,7 +260,9 @@ public class AttachmentServiceImpl extends ServiceImpl<AttachmentMapper, Attachm
String destPath = fileBasePath + diskFile.getPath(); String destPath = fileBasePath + diskFile.getPath();
String ofdFilePath = destPath.substring(0, destPath.lastIndexOf('.')) + ".ofd"; String ofdFilePath = destPath.substring(0, destPath.lastIndexOf('.')) + ".ofd";
FileUtil.del(destPath); FileUtil.del(destPath);
FileUtil.del(this.getEncryptedPath(destPath));
FileUtil.del(ofdFilePath); FileUtil.del(ofdFilePath);
FileUtil.del(this.getEncryptedPath(ofdFilePath));
diskFileService.removeById(diskFile.getId()); diskFileService.removeById(diskFile.getId());
} }
this.removeById(id); this.removeById(id);
...@@ -292,6 +301,7 @@ public class AttachmentServiceImpl extends ServiceImpl<AttachmentMapper, Attachm ...@@ -292,6 +301,7 @@ public class AttachmentServiceImpl extends ServiceImpl<AttachmentMapper, Attachm
String diskId = attachment.getDiskFileId(); String diskId = attachment.getDiskFileId();
DiskFile diskFile = diskFileService.getById(diskId); DiskFile diskFile = diskFileService.getById(diskId);
File file = getFileByDiskFile(diskFile); File file = getFileByDiskFile(diskFile);
this.guessDecrytedFile(file);
return file; return file;
} }
...@@ -322,6 +332,7 @@ public class AttachmentServiceImpl extends ServiceImpl<AttachmentMapper, Attachm ...@@ -322,6 +332,7 @@ public class AttachmentServiceImpl extends ServiceImpl<AttachmentMapper, Attachm
String path = sourceFile.getAbsolutePath(); String path = sourceFile.getAbsolutePath();
path = path.substring(0, path.lastIndexOf('.')) + ".ofd"; path = path.substring(0, path.lastIndexOf('.')) + ".ofd";
File ofdFile = new File(path); File ofdFile = new File(path);
this.guessDecrytedFile(ofdFile);
return ofdFile; return ofdFile;
} }
...@@ -338,6 +349,7 @@ public class AttachmentServiceImpl extends ServiceImpl<AttachmentMapper, Attachm ...@@ -338,6 +349,7 @@ public class AttachmentServiceImpl extends ServiceImpl<AttachmentMapper, Attachm
String path = sourceFile.getAbsolutePath(); String path = sourceFile.getAbsolutePath();
path = path.substring(0, path.lastIndexOf('.')) + ".ofd"; path = path.substring(0, path.lastIndexOf('.')) + ".ofd";
File ofdFile = new File(path); File ofdFile = new File(path);
this.guessDecrytedFile(ofdFile);
return ofdFile; return ofdFile;
} }
...@@ -460,6 +472,7 @@ public class AttachmentServiceImpl extends ServiceImpl<AttachmentMapper, Attachm ...@@ -460,6 +472,7 @@ public class AttachmentServiceImpl extends ServiceImpl<AttachmentMapper, Attachm
} }
String path = getFilePath(attachment); String path = getFilePath(attachment);
File f = new File(path); File f = new File(path);
this.guessDecrytedFile(f);
return f; return f;
} }
/** /**
...@@ -486,4 +499,32 @@ public class AttachmentServiceImpl extends ServiceImpl<AttachmentMapper, Attachm ...@@ -486,4 +499,32 @@ public class AttachmentServiceImpl extends ServiceImpl<AttachmentMapper, Attachm
path = fileBasePath + path; path = fileBasePath + path;
return path; return path;
} }
/**
* 猜测是否jiem 假如明文文件不存在则进行jiem
* @param plainFile
* @return
*/
public boolean guessDecrytedFile(File plainFile){
boolean success = false;
if(!plainFile.exists()){
String plainPath = plainFile.getAbsolutePath();
String encryptedPath = this.getEncryptedPath(plainPath);
success = cisService.decryptedFile(new File(encryptedPath));
}
return success;
}
/**
* 获取jm文件路径
* @param plainPath
* @return
*/
public String getEncryptedPath(String plainPath){
File rootPath = new File(fileBasePath);
String rootAbsoulutePath = rootPath.getAbsolutePath();
String encryptedPath = plainPath.replace(rootAbsoulutePath,rootAbsoulutePath+File.separator+"jmdir");
return encryptedPath;
}
} }
package com.cesgroup.bdc.cis.controller;
import com.cesgroup.bdc.cis.service.CisService;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.HandlerMapping;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.util.*;
/**
* @author: YYB
* @description: CIS文件加密控制类
* @date: 2024/2/8.
* @modified by:
*/
@Slf4j
@Controller
@RequestMapping("/cis")
public class CisController {
@Autowired
private CisService cisService;
@Value("${file.upload.path}")
private String fileBasePath;
/**
* 目录(文件)加密调试
* @param dir 目录(文件)路径 如:20240304 或者 20240304/123.ofd
* @param request
* @return
*/
@RequestMapping("/encrypted/{dir}/**")
@ResponseBody
public Map<String, String> encrypted(@PathVariable String dir, HttpServletRequest request) {
Map<String, String> mm = new HashMap<>();
boolean success = false;
String path =
request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE).toString();
path = path.replace("/cis/encrypted/","");
path = path.replace("\\","/");
String filePath = fileBasePath + path;
List<String> failFiles = new ArrayList<>();
this.recursiveEncrypted(new File(filePath),failFiles);
if(failFiles.size()>0){
mm.put("status", "fail");
ObjectMapper objectMapper = new ObjectMapper();
String jsonString = null;
try {
jsonString = objectMapper.writeValueAsString(failFiles);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
mm.put("failFiles", jsonString);
}else{
mm.put("status", "success");
}
return mm;
}
/**
* 递归调用加密
* @param file 文件
* @param failFiles 加密错误文件路径信息
*/
private void recursiveEncrypted(File file,List<String> failFiles){
if (file != null && file.exists()) {
if (file.isDirectory()) {
for (File child : file.listFiles()) {
recursiveEncrypted(child,failFiles); // 递归调用自身处理子目录
}
} else {
// System.out.println("文件名:"+file.getName());
boolean success = cisService.encryptedFile(file);
if(!success){
failFiles.add(file.getAbsolutePath());
}
}
}
}
/**
* 目录(文件)解密调试
* @param dir 目录(文件)路径 如:jmdir/20240304 或者 jmdir/20240304/123.ofd
* @param request
* @return
*/
@RequestMapping("/decrypted/{dir}/**")
@ResponseBody
public Map<String, String> decrypted(@PathVariable String dir, HttpServletRequest request) {
Map<String, String> mm = new HashMap<>();
String path =
request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE).toString();
path = path.replace("/cis/decrypted/","");
path = path.replace("\\","/");
String filePath = fileBasePath + path;
List<String> failFiles = new ArrayList<>();
this.recursiveDecrypted(new File(filePath),failFiles);
if(failFiles.size()>0){
mm.put("status", "fail");
ObjectMapper objectMapper = new ObjectMapper();
String jsonString = null;
try {
jsonString = objectMapper.writeValueAsString(failFiles);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
mm.put("failFiles", jsonString);
}else{
mm.put("status", "success");
}
return mm;
}
/**
* 递归调用解密方法
* @param file 已加密文件
* @param failFiles
*/
private void recursiveDecrypted(File file,List<String> failFiles){
if (file != null && file.exists()) {
if (file.isDirectory()) {
for (File child : file.listFiles()) {
recursiveDecrypted(child,failFiles); // 递归调用自身处理子目录
}
} else {
// System.out.println("文件名:"+file.getName());
boolean success = cisService.decryptedFile(file);
if(!success){
failFiles.add(file.getAbsolutePath());
}
}
}
}
}
package com.cesgroup.bdc.cis.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
* @author: YYB
* @description: CIS处理结果表
* @date: 2024/3/14.
* @modified by:
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("CIS_DEAL_RESULT")
public class CisDealResult implements Serializable {
@TableId("ID")
private String id;
/**
* 处理时间
*/
@TableField("DEAL_TIME")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date dealTime;
@TableId("PLAIN_PATH")
private String plainPath;
}
package com.cesgroup.bdc.cis.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cesgroup.bdc.cis.entity.CisDealResult;
/**
* @author: YYB
* @description:
* @date: 2024/3/14.
* @modified by:
*/
public interface CisMapper extends BaseMapper<CisDealResult> {
}
package com.cesgroup.bdc.cis.service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cesgroup.bdc.cis.entity.CisDealResult;
import com.cesgroup.bdc.cis.mapper.CisMapper;
import com.cesgroup.bdc.util.PrimaryKey;
import com.cesgroup.kingkong.core.ApplicationContextUtils;
import com.sdt.cipherApi.tool.PkiCipher.CipherAPI;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* @author: YYB
* @description: CIS加密存储服务
* @date: 2024/2/8.
* @modified by:
*/
@Service
public class CisService extends ServiceImpl<CisMapper, CisDealResult> {
private Log logger = LogFactory.getLog(getClass());
/**
* 算法类型 参数:10(电子政务) 5(内网认证)
*/
@Value("${cis.algType}")
private String algType;
@Value("${file.upload.path}")
private String fileBasePath;
/**
* 明文文件加密
* @param plainFile 明文文件
* @return
*/
public boolean encryptedFile(File plainFile){
boolean success = false;
File rootPath = new File(fileBasePath);
String rootAbsoulutePath = rootPath.getAbsolutePath();
String plainPath = plainFile.getAbsolutePath();
String encryptedPath = plainPath.replace(rootAbsoulutePath,rootAbsoulutePath+File.separator+"jmdir");
//String ext = plainPath.substring(plainPath.lastIndexOf('.'));
//String encryptedPath = plainPath.substring(0,plainPath.lastIndexOf('.')) + "_m" + ext;
CipherAPI cipherAPI = ApplicationContextUtils.getBean(CipherAPI.class);
List<String> recvCerts = new ArrayList<>();
recvCerts.add("MIICbzCCAfygAwIBAgIKEAEDICMAAAAAAjAKBggqgRzPVQGENDBaMSQwIgYDVQQDDBvkuK3lhbHkuIrmtbfluILlp5TmnLropoHlsYAxEjAQBgNVBAgMCeS4iua1t+W4gjEeMBwGA1UEBgwV5Lit5Y2O5Lq65rCR5YWx5ZKM5Zu9MB4XDTI0MDMxMjE2MDAwMFoXDTM0MDMxMzE1NTk1OVowgckxFzAVBgNVBAMMDjU2Mzc0NDlfRU5DS18xMSAwHgYKCZImiZPyLGQBAQwQMTAwMTAzMDAwMDAwMDA0MjEbMBkGA1UECwwS6K+B5Lmm5rOo5YaM57O757ufMSQwIgYDVQQKDBvkuK3lhbHkuIrmtbfluILlp5TmnLropoHlsYAxFTATBgsJkiaJk/IsgUgBCgwEMDAwMTESMBAGCwmSJomT8iyBSAEEDAEwMR4wHAYDVQQGDBXkuK3ljY7kurrmsJHlhbHlkozlm70weTATBgcqhkjOPQIBBggqgRzPVQGDUANiAASZUv/tLg8W7+63DfG2+PgTbMzVIGdRV0t0geozJj2SUDScAzc459V2/jrfv+wQR9+18mbXXXVjbVuwhMfjaWwgrgfBwfswY25jY8x4z2N5lU3tYjNHQ+imsKcB1OWiCzmjGjAYMAkGA1UdEwQCMAAwCwYDVR0PBAQDAgM4MAoGCCqBHM9VAYQ0A2EAWD8f98kS8sVy/AWBKpnL+NuoYvMQHL+Tty9CERznZ2WaMLmQoqf8d53ReOIAcK/gYQ164ZFM/3hfJq7yN4sVDDw5t1gopryaRZM6ec9KG/rsnUdTljG+k+Nu/9+XbfX/");
try {
File encryptedFile = new File(encryptedPath);
if(!encryptedFile.exists() && plainFile.exists()){
if(!encryptedFile.getParentFile().exists()){
encryptedFile.getParentFile().mkdirs();
}
success = cipherAPI.singleStorageEncrypt(plainPath,encryptedPath,recvCerts,algType);
if(success){
//加密成功往加密信息表里新增一条信息
CisDealResult result = new CisDealResult();
result.setId(PrimaryKey.generateId());
result.setPlainPath(plainPath);
result.setDealTime(new Date());
this.save(result);
//plainFile.delete();
}
}
} catch (Exception e) {
e.printStackTrace();
}
return success;
}
/**
* 密文文件解密
* @param encrytedFile 密文文件
* @return
*/
public boolean decryptedFile(File encrytedFile){
boolean success = false;
File rootPath = new File(fileBasePath);
String rootAbsoulutePath = rootPath.getAbsolutePath();
String encrytedPath = encrytedFile.getAbsolutePath();
String plainPath = encrytedPath.replace(rootAbsoulutePath+File.separator+"jmdir",rootAbsoulutePath);
CipherAPI cipherAPI = ApplicationContextUtils.getBean(CipherAPI.class);
try {
File decryptedFile = new File(plainPath);
if(!decryptedFile.exists() && encrytedFile.exists()){
if(!decryptedFile.getParentFile().exists()){
decryptedFile.getParentFile().mkdirs();
}
success = cipherAPI.singleStorageDecrypt(encrytedPath,plainPath,algType);
if(success){
//解密成功往结果表里加一条记录
CisDealResult result = new CisDealResult();
result.setId(PrimaryKey.generateId());
result.setPlainPath(plainPath);
result.setDealTime(new Date());
this.save(result);
//decryptedFile.delete();
}
}
} catch (Exception e) {
e.printStackTrace();
}
return success;
}
}
package com.cesgroup.bdc.suwell.service; package com.cesgroup.bdc.suwell.service;
import com.cesgroup.bdc.cis.service.CisService;
import com.suwell.ofd.custom.agent.HTTPAgent; import com.suwell.ofd.custom.agent.HTTPAgent;
import com.suwell.ofd.custom.wrapper.model.MarkPosition; import com.suwell.ofd.custom.wrapper.model.MarkPosition;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
...@@ -24,6 +25,9 @@ import java.io.InputStream; ...@@ -24,6 +25,9 @@ import java.io.InputStream;
public class SuwellService { public class SuwellService {
private Log logger = LogFactory.getLog(getClass()); private Log logger = LogFactory.getLog(getClass());
@Autowired
private CisService cisService;
/** /**
* 数科ofd服务url * 数科ofd服务url
*/ */
...@@ -54,6 +58,8 @@ public class SuwellService { ...@@ -54,6 +58,8 @@ public class SuwellService {
HTTPAgent ha = getHttpAgent(); HTTPAgent ha = getHttpAgent();
ha.officeToOFD(new File(sourcePath), new FileOutputStream(targetPath)); ha.officeToOFD(new File(sourcePath), new FileOutputStream(targetPath));
b = true; b = true;
//文件加密
cisService.encryptedFile(new File(targetPath));
logger.info("ofd转换成功"); logger.info("ofd转换成功");
} catch (Exception e) { } catch (Exception e) {
logger.error("ofd转换失败:" + e.getMessage()); logger.error("ofd转换失败:" + e.getMessage());
...@@ -77,6 +83,8 @@ public class SuwellService { ...@@ -77,6 +83,8 @@ public class SuwellService {
HTTPAgent ha = getHttpAgent(); HTTPAgent ha = getHttpAgent();
ha.OFDToPDF(new File(sourcePath), new FileOutputStream(targetPath)); ha.OFDToPDF(new File(sourcePath), new FileOutputStream(targetPath));
b = true; b = true;
//文件加密
cisService.encryptedFile(new File(targetPath));
logger.info("pdf转换成功"); logger.info("pdf转换成功");
} catch (Exception e) { } catch (Exception e) {
logger.error("pdf转换失败:" + e.getMessage()); logger.error("pdf转换失败:" + e.getMessage());
...@@ -136,6 +144,8 @@ public class SuwellService { ...@@ -136,6 +144,8 @@ public class SuwellService {
MarkPosition mk = new MarkPosition(x, y, 210F, 297F, pageindex); MarkPosition mk = new MarkPosition(x, y, 210F, 297F, pageindex);
ha.addImageMark(srcFile, targetFileOut, imge, imageType, mk, true, true); ha.addImageMark(srcFile, targetFileOut, imge, imageType, mk, true, true);
b = true; b = true;
//文件加密
cisService.encryptedFile(new File(targetFilePath));
logger.info("ofd添加图片水印成功"); logger.info("ofd添加图片水印成功");
} catch (Exception e) { } catch (Exception e) {
logger.error("ofd添加图片水印失败:" + e.toString()); logger.error("ofd添加图片水印失败:" + e.toString());
......
package com.cesgroup.kingkong.autoconfigure.cis;
import cis.enums.EEncSuit;
import com.sdt.cipherApi.tool.PkiCipher.CipherAPI;
import com.sdt.cipherApi.tool.PkiCipher.CipherParams;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
/**
* @author: YYB
* @description: 加密存储配置
* @date: 2024/2/5.
* @modified by:
*/
@Configuration
@ComponentScan(basePackages = { "cis.enums"})
public class CipherConfiguration {
/**
* 配置唯一编号不可大于五个字符
*/
@Value("${cis.cipherId}")
private String cipherId;
/**
* mm机应用名
*/
@Value("${cis.devAppId}")
private String devAppId;
/**
* mm机类型 参数:DEVICE_FJ DEVICE_311
*/
@Value("${cis.devType}")
private String devType;
/**
* mm机IP
*/
@Value("${cis.devIp}")
private String devIp;
/**
* mm机端口
*/
@Value("${cis.devPort}")
private String devPort;
/**
* 签名私钥名
*/
@Value("${cis.keyNameSsk}")
private String keyNameSsk;
/**
* 本地保护私钥名
*/
@Value("${cis.keyNameLpk}")
private String keyNameLpk;
/**
* 加密私钥名
*/
@Value("${cis.keyNameEsk}")
private String keyNameEsk;
/**
* mm方案 合法值: gw_311 gw_fj
*/
private EEncSuit encSuit;
/**
* 签名证书名
*/
@Value("${cis.certName_sign}")
private String certName_sign;
/**
* 加密证书名
*/
@Value("${cis.certName_enc}")
private String certName_enc;
/**
* 算法类型 参数:10(电子政务) 5(内网认证)
*/
@Value("${cis.algType}")
private String algType;
@Bean
public CipherAPI cipherAPI(){
CipherAPI cipherAPI = CipherAPI.getInstance();
CipherParams cipherParams = new CipherParams(cipherId,devAppId,devType,devIp,devPort,keyNameSsk,keyNameLpk,keyNameEsk, EEncSuit.gw_311_fj, certName_sign, certName_enc, algType);
try {
cipherAPI.gwSetCisAppConf(cipherParams,algType);
cipherAPI.setParams(algType, cipherParams);
} catch (Exception e) {
e.printStackTrace();
}
return cipherAPI;
}
}
...@@ -60,3 +60,16 @@ suwell: ...@@ -60,3 +60,16 @@ suwell:
HTTPAgent: HTTPAgent:
#数科ofd服务url #数科ofd服务url
url: http://127.0.0.1:9090/convert-issuer/ url: http://127.0.0.1:9090/convert-issuer/
cis:
cipherId:
devAppId:
devType: DEVICE_311
devIp:
devPort:
keyNameSsk:
keyNameLpk:
keyNameEsk:
certName_sign:
certName_enc:
algType: 5
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment