从OA中将加密文件解密并保存本地,或者保存到共享盘
1、根据requestid 找出对应docid
select * from formtable_main_291 where requestid=869869
2、 利用这个id继续查询
select top 10 * from docimagefile where docid = 46539
找到对应的imagefileid
3、select t1.imagefilename,t1.filerealpath,t1.iszip,t1.isencrypt,t1.imagefiletype , t1.imagefileid, t1.imagefile,t1.isaesencrypt,t1.aescode,t2.imagefilename as realname,t1.TokenKey,t1.StorageStatus,t1.comefrom from ImageFile t1 left join DocImageFile t2 on t1.imagefileid = t2.imagefileid where t1.imagefileid = 206023
其中filerealpath 为加密文件存放路径
aescode 为加密秘钥
然后在代码里使用这个imagefileid
package com.test; import weaver.file.ImageFileManager; import weaver.general.BaseBean; import weaver.interfaces.workflow.action.Action; import weaver.soa.workflow.request.RequestInfo; import java.io.*; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; public class RfcTest extends BaseBean implements Action{ @Override public String execute(RequestInfo request) { ImageFileManager imageFileManager = new ImageFileManager(); imageFileManager.getImageFileInfoById(206023); InputStream inputStream = imageFileManager.getInputStream(); File file = new File("F:\\files\\123456.pdf"); copyInputStreamToFile(inputStream,file); request.getRequestManager().setMessageid("90001"); request.getRequestManager().setMessagecontent("SAP系统业务处理失败或者网络问题,请稍后重试!错误信息:"); return Action.FAILURE_AND_CONTINUE; } private void copyInputStreamToFile( InputStream in, File file ) { try { OutputStream out = new FileOutputStream(file); byte[] buf = new byte[1024]; int len; while((len=in.read(buf))>0){ out.write(buf,0,len); } out.close(); in.close(); } catch (Exception e) { e.printStackTrace(); } } }
具体关键类是两个类:
weaver.file.ImageFileManager
这是一个利用自己对象生成解密,解zip压缩后的inputstream
weaver.file.AESCoder
这是一个加密解密工具类