Commit 4e786607 authored by o2wwx's avatar o2wwx

'修改'

parent 211943a0
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- Generated by Apache Maven Doxia Site Renderer 1.7 at 2021-05-17 -->
<!-- Generated by Apache Maven Doxia Site Renderer 1.7 at 2021-05-28 -->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh" lang="zh">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
......@@ -10,7 +10,7 @@
@import url("./css/site.css");
</style>
<link rel="stylesheet" href="./css/print.css" type="text/css" media="print" />
<meta name="Date-Revision-yyyymmdd" content="20210517" />
<meta name="Date-Revision-yyyymmdd" content="20210528" />
<meta http-equiv="Content-Language" content="zh" />
</head>
......@@ -23,7 +23,7 @@
<div id="breadcrumbs">
<div class="xleft">
<span id="publishDate">最近更新: 2021-05-17</span>
<span id="publishDate">最近更新: 2021-05-28</span>
&nbsp;| <span id="projectVersion">版本: 5.3</span>
</div>
<div class="xright">
......
package com.x.custom.secretcontrol.assemble.control.entities;
public class FilecryptDigestModel {
public String appId;
public String cryptType;
public String file;
public String digest;
public FilecryptInfo fileInfo;
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public String getCryptType() {
return cryptType;
}
public void setCryptType(String cryptType) {
this.cryptType = cryptType;
}
public String getFile() {
return file;
}
public void setFile(String file) {
this.file = file;
}
public String getDigest() {
return digest;
}
public void setDigest(String digest) {
this.digest = digest;
}
public FilecryptInfo getFileInfo() {
return fileInfo;
}
public void setFileInfo(FilecryptInfo fileInfo) {
this.fileInfo = fileInfo;
}
}
......@@ -171,7 +171,6 @@ public class FilecryptFactory {
emc.beginTransaction(SecretControlFile.class);
emc.persist(secretControlFile, CheckPersistType.all);
emc.commit();
logger.print("saveFilecryptContent save");
StorageMapping mapping = ThisApplication.context().storageMappings().get(SecretControlFile.class,
secretControlFile.getStorage());
......
package com.x.custom.secretcontrol.assemble.control.factory.utility;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
public class JsonUtility {
private static final ObjectMapper MAPPER = new ObjectMapper();
public static String objectToJson(Object data) {
try {
String string = MAPPER.writeValueAsString(data);
return string ;
}catch(JsonProcessingException e) {
e.printStackTrace();
}
return null;
}
}
......@@ -4,6 +4,7 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.apache.commons.codec.binary.StringUtils;
import org.apache.commons.codec.digest.DigestUtils;
public class Md5Utility {
......@@ -15,7 +16,7 @@ public class Md5Utility {
* @return Hash 结果
*/
public static String md5(String original) {
return DigestUtils.md5Hex(original);
return DigestUtils.md5Hex(StringUtils.getBytesUtf8(original));
}
/**
......
......@@ -9,10 +9,12 @@ import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.custom.secretcontrol.assemble.control.Business;
import com.x.custom.secretcontrol.assemble.control.entities.FilecryptDigestModel;
import com.x.custom.secretcontrol.assemble.control.entities.FilecryptInfo;
import com.x.custom.secretcontrol.assemble.control.entities.FilecryptModel;
import com.x.custom.secretcontrol.assemble.control.entities.FilecryptResult;
import com.x.custom.secretcontrol.assemble.control.factory.FilecryptFactory;
import com.x.custom.secretcontrol.assemble.control.factory.utility.JsonUtility;
import com.x.custom.secretcontrol.assemble.control.factory.utility.Md5Utility;
import java.util.Base64;
import javax.servlet.http.HttpServletRequest;
......@@ -44,7 +46,7 @@ class ActionCrypt extends BaseAction {
FilecryptFactory filecryptFactory = new FilecryptFactory();
byte[] fileContent = filecryptFactory.getFileContent(wi.getFileId());
String strFileContent = Base64.getEncoder().encodeToString(fileContent);
//fileInfo消息体说明
FilecryptInfo filecryptInfo = new FilecryptInfo();
filecryptInfo.setOaDocId(wi.getJobId()); //OA系统中的docId(如果是解密不必填)
......@@ -64,16 +66,28 @@ class ActionCrypt extends BaseAction {
filecryptModel.setFileInfo(filecryptInfo); //文件信息
filecryptModel.setFile(strFileContent); //文件内容
Gson gson = new Gson();
String json = gson.toJson(filecryptModel);
String secret = this.getBusiness().readConfigByString("secret");
//Gson gson = new Gson();
//String json = gson.toJson(filecryptModel);
String json = JsonUtility.objectToJson(filecryptModel);
String secret = this.getBusiness().readConfigByString("secret");
String digest = Md5Utility.md5(json + secret);
//生成摘要
FilecryptDigestModel filecryptDigestModel = new FilecryptDigestModel();
filecryptDigestModel.setAppId(OAId); //OA系统id(由商密系统定义)
filecryptDigestModel.setCryptType("1"); //0:解密 1:加密
filecryptDigestModel.setFileInfo(filecryptInfo); //文件信息
filecryptDigestModel.setFile(strFileContent); //文件内容
filecryptDigestModel.setDigest(digest);
/*
JsonElement jsonFilecryptModel = gson.toJsonTree(filecryptModel);
logger.print("jsonFilecryptModel=" + jsonFilecryptModel);
jsonFilecryptModel.getAsJsonObject().addProperty("digest", digest); //设置摘要
String StrFilecryptModel = gson.toJson(jsonFilecryptModel);
logger.print("StrFilecryptModel=" + StrFilecryptModel);
*/
String StrFilecryptModel = JsonUtility.objectToJson(filecryptDigestModel);
//logger.print("StrFilecryptModel=" + StrFilecryptModel);
FilecryptResult filecryptResult = filecryptFactory.filePost(StrFilecryptModel);
/*
......@@ -81,15 +95,14 @@ class ActionCrypt extends BaseAction {
filecryptResult.setResultCode("1");
filecryptResult.setResultData(fileContent.toString());
*/
logger.print("filecryptResult=" + filecryptResult.toString());
//logger.print("filecryptResult=" + filecryptResult.toString());
if(filecryptResult != null){
final Wo wo = new Wo();
String resultCode = filecryptResult.getResultCode();
if(resultCode.equalsIgnoreCase("1")) {
String resultData = filecryptResult.getResultData();
//fileContent = Base64.getEncoder().encode(resultData.getBytes("UTF-8")); //base64解码
fileContent =resultData.getBytes("UTF-8");
logger.print("saveFilecryptContent start");
String attId = filecryptFactory.saveFilecryptContent(wi.getFileId(), fileContent);
wo.setType(Wo.SUCC_TYPE);
wo.setData(attId);
......@@ -107,7 +120,6 @@ class ActionCrypt extends BaseAction {
result.setData(wo);
result.setMessage("操作失败,请查询具体日志");
}
return result;
}
......
......@@ -11,10 +11,12 @@ import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.custom.secretcontrol.assemble.control.Business;
import com.x.custom.secretcontrol.assemble.control.ThisApplication;
import com.x.custom.secretcontrol.assemble.control.entities.FilecryptDigestModel;
import com.x.custom.secretcontrol.assemble.control.entities.FilecryptInfo;
import com.x.custom.secretcontrol.assemble.control.entities.FilecryptModel;
import com.x.custom.secretcontrol.assemble.control.entities.FilecryptResult;
import com.x.custom.secretcontrol.assemble.control.factory.FilecryptFactory;
import com.x.custom.secretcontrol.assemble.control.factory.utility.JsonUtility;
import com.x.custom.secretcontrol.assemble.control.factory.utility.Md5Utility;
import com.x.custom.secretcontrol.core.entity.SecretControlFile;
import java.util.Base64;
......@@ -74,26 +76,39 @@ class ActionDecode extends BaseAction {
filecryptModel.setFileInfo(filecryptInfo);
filecryptModel.setFile(strFileContent);
Gson gson = new Gson();
String json = gson.toJson(filecryptModel);
// Gson gson = new Gson();
// String json = gson.toJson(filecryptModel);
String json = JsonUtility.objectToJson(filecryptModel);
String secret = this.getBusiness().readConfigByString("secret");
String digest = Md5Utility.md5(json + secret);
//生成摘要
FilecryptDigestModel filecryptDigestModel = new FilecryptDigestModel();
filecryptDigestModel.setAppId(OAId); //OA系统id(由商密系统定义)
filecryptDigestModel.setCryptType("0"); //0:解密 1:加密
filecryptDigestModel.setFileInfo(filecryptInfo); //文件信息
filecryptDigestModel.setFile(strFileContent); //文件内容
filecryptDigestModel.setDigest(digest);
/*
JsonElement jsonFilecryptModel = gson.toJsonTree(filecryptModel);
jsonFilecryptModel.getAsJsonObject().addProperty("digest", digest);
String StrFilecryptModel = gson.toJson(jsonFilecryptModel);
*/
String StrFilecryptModel = JsonUtility.objectToJson(filecryptDigestModel);
//logger.print("ActionDecode StrFilecryptModel=" + StrFilecryptModel);
FilecryptFactory filecryptFactory = new FilecryptFactory();
FilecryptResult filecryptResult = filecryptFactory.filePost(StrFilecryptModel);
// logger.print("ActionDecode filecryptResult=" + filecryptResult.toString());
String base64FileConent = filecryptResult.getResultData();
bytes = Base64.getDecoder().decode(base64FileConent.getBytes("UTF-8"));
logger.print("saveFileDecodeContent start");
SecretControlFile secretControlFile = filecryptFactory.saveFileContent(wi.getFileId(), bytes);
logger.print("saveFileDecodeContent end");
Wo wo = new Wo();
wo.setType(Wo.SUCC_TYPE);
wo.setData(secretControlFile.getId());
......
......@@ -21,7 +21,7 @@ import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
/**
* 创建流程
* 文件加密解密
**/
@Path("filecrypt")
@JaxrsDescribe("文件加密解密")
......
......@@ -4,10 +4,5 @@
"authenticateUrls":"xmis://smap.uatbj.cmcc:80",
"filecrypt_url":"http://10.253.10.146:8080/file/filecrypt",
"secret":"TEST_SECRET_KEY",
"OAId":"appId002",
"server":"127.0.0.1",
"port": "20020",
"sso_key": "12345678",
"sso_client": "sso",
"storageFolder": "E:/test"
"OAId":"YOA-WRDP@HQ.CMCC"
}
\ No newline at end of file
......@@ -3,16 +3,16 @@
{
"name": "CacheAction",
"methods": [
{
"name": "configFlush",
"uri": "jaxrs/cache/config/flush",
"method": "GET"
},
{
"name": "receive",
"uri": "jaxrs/cache",
"method": "PUT",
"enctype": "application/json"
},
{
"name": "configFlush",
"uri": "jaxrs/cache/config/flush",
"method": "GET"
}
]
},
......@@ -35,6 +35,11 @@
"method": "POST",
"enctype": "application/json"
},
{
"name": "download",
"uri": "jaxrs/filecrypt/download/{id}/stream",
"method": "GET"
},
{
"name": "crypt",
"uri": "jaxrs/filecrypt/crypt",
......@@ -46,11 +51,6 @@
"uri": "jaxrs/filecrypt/list/{page}/size/{size}",
"method": "POST",
"enctype": "application/json"
},
{
"name": "download",
"uri": "jaxrs/filecrypt/download/{id}/stream",
"method": "GET"
}
]
},
......@@ -114,16 +114,16 @@
{
"name": "SysResourceAction",
"methods": [
{
"name": "listResource",
"uri": "jaxrs/sysresource/filePath/{filePath}",
"method": "GET"
},
{
"name": "uploadResource",
"uri": "jaxrs/sysresource/upload/resource/as/new/{asNew}",
"method": "POST",
"enctype": "formData"
},
{
"name": "listResource",
"uri": "jaxrs/sysresource/filePath/{filePath}",
"method": "GET"
}
]
},
......
package com.x.custom.secretcontrol.assemble.control.entities;
public class FilecryptDigestModel {
public String appId;
public String cryptType;
public String file;
public String digest;
public FilecryptInfo fileInfo;
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public String getCryptType() {
return cryptType;
}
public void setCryptType(String cryptType) {
this.cryptType = cryptType;
}
public String getFile() {
return file;
}
public void setFile(String file) {
this.file = file;
}
public String getDigest() {
return digest;
}
public void setDigest(String digest) {
this.digest = digest;
}
public FilecryptInfo getFileInfo() {
return fileInfo;
}
public void setFileInfo(FilecryptInfo fileInfo) {
this.fileInfo = fileInfo;
}
}
......@@ -171,7 +171,6 @@ public class FilecryptFactory {
emc.beginTransaction(SecretControlFile.class);
emc.persist(secretControlFile, CheckPersistType.all);
emc.commit();
logger.print("saveFilecryptContent save");
StorageMapping mapping = ThisApplication.context().storageMappings().get(SecretControlFile.class,
secretControlFile.getStorage());
......
package com.x.custom.secretcontrol.assemble.control.factory.utility;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
public class JsonUtility {
private static final ObjectMapper MAPPER = new ObjectMapper();
public static String objectToJson(Object data) {
try {
String string = MAPPER.writeValueAsString(data);
return string ;
}catch(JsonProcessingException e) {
e.printStackTrace();
}
return null;
}
}
......@@ -4,6 +4,7 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.apache.commons.codec.binary.StringUtils;
import org.apache.commons.codec.digest.DigestUtils;
public class Md5Utility {
......@@ -15,7 +16,7 @@ public class Md5Utility {
* @return Hash 结果
*/
public static String md5(String original) {
return DigestUtils.md5Hex(original);
return DigestUtils.md5Hex(StringUtils.getBytesUtf8(original));
}
/**
......
......@@ -9,10 +9,12 @@ import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.custom.secretcontrol.assemble.control.Business;
import com.x.custom.secretcontrol.assemble.control.entities.FilecryptDigestModel;
import com.x.custom.secretcontrol.assemble.control.entities.FilecryptInfo;
import com.x.custom.secretcontrol.assemble.control.entities.FilecryptModel;
import com.x.custom.secretcontrol.assemble.control.entities.FilecryptResult;
import com.x.custom.secretcontrol.assemble.control.factory.FilecryptFactory;
import com.x.custom.secretcontrol.assemble.control.factory.utility.JsonUtility;
import com.x.custom.secretcontrol.assemble.control.factory.utility.Md5Utility;
import java.util.Base64;
import javax.servlet.http.HttpServletRequest;
......@@ -44,7 +46,7 @@ class ActionCrypt extends BaseAction {
FilecryptFactory filecryptFactory = new FilecryptFactory();
byte[] fileContent = filecryptFactory.getFileContent(wi.getFileId());
String strFileContent = Base64.getEncoder().encodeToString(fileContent);
//fileInfo消息体说明
FilecryptInfo filecryptInfo = new FilecryptInfo();
filecryptInfo.setOaDocId(wi.getJobId()); //OA系统中的docId(如果是解密不必填)
......@@ -64,16 +66,28 @@ class ActionCrypt extends BaseAction {
filecryptModel.setFileInfo(filecryptInfo); //文件信息
filecryptModel.setFile(strFileContent); //文件内容
Gson gson = new Gson();
String json = gson.toJson(filecryptModel);
String secret = this.getBusiness().readConfigByString("secret");
//Gson gson = new Gson();
//String json = gson.toJson(filecryptModel);
String json = JsonUtility.objectToJson(filecryptModel);
String secret = this.getBusiness().readConfigByString("secret");
String digest = Md5Utility.md5(json + secret);
//生成摘要
FilecryptDigestModel filecryptDigestModel = new FilecryptDigestModel();
filecryptDigestModel.setAppId(OAId); //OA系统id(由商密系统定义)
filecryptDigestModel.setCryptType("1"); //0:解密 1:加密
filecryptDigestModel.setFileInfo(filecryptInfo); //文件信息
filecryptDigestModel.setFile(strFileContent); //文件内容
filecryptDigestModel.setDigest(digest);
/*
JsonElement jsonFilecryptModel = gson.toJsonTree(filecryptModel);
logger.print("jsonFilecryptModel=" + jsonFilecryptModel);
jsonFilecryptModel.getAsJsonObject().addProperty("digest", digest); //设置摘要
String StrFilecryptModel = gson.toJson(jsonFilecryptModel);
logger.print("StrFilecryptModel=" + StrFilecryptModel);
*/
String StrFilecryptModel = JsonUtility.objectToJson(filecryptDigestModel);
//logger.print("StrFilecryptModel=" + StrFilecryptModel);
FilecryptResult filecryptResult = filecryptFactory.filePost(StrFilecryptModel);
/*
......@@ -81,15 +95,14 @@ class ActionCrypt extends BaseAction {
filecryptResult.setResultCode("1");
filecryptResult.setResultData(fileContent.toString());
*/
logger.print("filecryptResult=" + filecryptResult.toString());
//logger.print("filecryptResult=" + filecryptResult.toString());
if(filecryptResult != null){
final Wo wo = new Wo();
String resultCode = filecryptResult.getResultCode();
if(resultCode.equalsIgnoreCase("1")) {
String resultData = filecryptResult.getResultData();
//fileContent = Base64.getEncoder().encode(resultData.getBytes("UTF-8")); //base64解码
fileContent =resultData.getBytes("UTF-8");
logger.print("saveFilecryptContent start");
String attId = filecryptFactory.saveFilecryptContent(wi.getFileId(), fileContent);
wo.setType(Wo.SUCC_TYPE);
wo.setData(attId);
......@@ -107,7 +120,6 @@ class ActionCrypt extends BaseAction {
result.setData(wo);
result.setMessage("操作失败,请查询具体日志");
}
return result;
}
......
......@@ -11,10 +11,12 @@ import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.custom.secretcontrol.assemble.control.Business;
import com.x.custom.secretcontrol.assemble.control.ThisApplication;
import com.x.custom.secretcontrol.assemble.control.entities.FilecryptDigestModel;
import com.x.custom.secretcontrol.assemble.control.entities.FilecryptInfo;
import com.x.custom.secretcontrol.assemble.control.entities.FilecryptModel;
import com.x.custom.secretcontrol.assemble.control.entities.FilecryptResult;
import com.x.custom.secretcontrol.assemble.control.factory.FilecryptFactory;
import com.x.custom.secretcontrol.assemble.control.factory.utility.JsonUtility;
import com.x.custom.secretcontrol.assemble.control.factory.utility.Md5Utility;
import com.x.custom.secretcontrol.core.entity.SecretControlFile;
import java.util.Base64;
......@@ -74,26 +76,39 @@ class ActionDecode extends BaseAction {
filecryptModel.setFileInfo(filecryptInfo);
filecryptModel.setFile(strFileContent);
Gson gson = new Gson();
String json = gson.toJson(filecryptModel);
// Gson gson = new Gson();
// String json = gson.toJson(filecryptModel);
String json = JsonUtility.objectToJson(filecryptModel);
String secret = this.getBusiness().readConfigByString("secret");
String digest = Md5Utility.md5(json + secret);
//生成摘要
FilecryptDigestModel filecryptDigestModel = new FilecryptDigestModel();
filecryptDigestModel.setAppId(OAId); //OA系统id(由商密系统定义)
filecryptDigestModel.setCryptType("0"); //0:解密 1:加密
filecryptDigestModel.setFileInfo(filecryptInfo); //文件信息
filecryptDigestModel.setFile(strFileContent); //文件内容
filecryptDigestModel.setDigest(digest);
/*
JsonElement jsonFilecryptModel = gson.toJsonTree(filecryptModel);
jsonFilecryptModel.getAsJsonObject().addProperty("digest", digest);
String StrFilecryptModel = gson.toJson(jsonFilecryptModel);
*/
String StrFilecryptModel = JsonUtility.objectToJson(filecryptDigestModel);
//logger.print("ActionDecode StrFilecryptModel=" + StrFilecryptModel);
FilecryptFactory filecryptFactory = new FilecryptFactory();
FilecryptResult filecryptResult = filecryptFactory.filePost(StrFilecryptModel);
// logger.print("ActionDecode filecryptResult=" + filecryptResult.toString());
String base64FileConent = filecryptResult.getResultData();
bytes = Base64.getDecoder().decode(base64FileConent.getBytes("UTF-8"));
logger.print("saveFileDecodeContent start");
SecretControlFile secretControlFile = filecryptFactory.saveFileContent(wi.getFileId(), bytes);
logger.print("saveFileDecodeContent end");
Wo wo = new Wo();
wo.setType(Wo.SUCC_TYPE);
wo.setData(secretControlFile.getId());
......
......@@ -21,7 +21,7 @@ import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
/**
* 创建流程
* 文件加密解密
**/
@Path("filecrypt")
@JaxrsDescribe("文件加密解密")
......
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