feat: 企标带文件导出PDF文件先解密后加水印再加密

This commit is contained in:
2024-05-11 14:21:26 +08:00
parent a985191bdc
commit aad080b900
4 changed files with 68 additions and 7 deletions
@@ -29,6 +29,10 @@ public class IntekeyUtils {
public static String DECRYPT_URL;
public static String DECRYPT_APP_CODE;
public static String DECRYPT_SECRET_KEY;
public static Integer SCOPE_DEV;
public static String ENCRYPT_URL;
public static String ENCRYPT_APP_CODE;
public static String ENCRYPT_SECRET_KEY;
@Value("${download.enable}")
public void setEnable(boolean enable) {
@@ -50,6 +54,23 @@ public class IntekeyUtils {
DECRYPT_SECRET_KEY = decryptSecretKey;
}
@Value("${download.scope_dev}")
public void setScopeDev(Integer scopeDev) {
SCOPE_DEV = scopeDev;
}
@Value("#{'${download.encrypt.url}'}")
public void setEncryptUrl(String encryptUrl) {
ENCRYPT_URL = encryptUrl;
}
@Value("#{'${download.encrypt.app_code}'}")
public void setEncryptAppCode(String encryptAppCode) {
ENCRYPT_APP_CODE = encryptAppCode;
}
@Value("#{'${download.encrypt.secret_key}'}")
public void setEncryptSecretKey(String encryptSecretKey) {
ENCRYPT_SECRET_KEY = encryptSecretKey;
}
public static MultipartFile autoDecryptFile(MultipartFile file) {
if (!ENABLE || file == null) {
return file;
@@ -84,6 +105,11 @@ public class IntekeyUtils {
}
}
public static InputStream autoEncryptInputStreamFile(InputStream is, String fileName) throws IOException {
MultipartFile file = IntekeyUtils.convertMultipart(is, fileName);
return IntekeyUtils.decryptFile(ENCRYPT_URL, ENCRYPT_APP_CODE, ENCRYPT_SECRET_KEY, SCOPE_DEV, file);
}
public static MultipartFile convertMultipart(InputStream is, String fileName) throws IOException {
// 假定文件名和内容类型已知
String contentType = "application/octet-stream"; // 或其他类型