| 
					
				 | 
			
			
				@@ -29,6 +29,7 @@ import java.io.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.security.cert.CertificateException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.security.cert.X509Certificate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.text.DecimalFormat; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.Arrays; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -175,10 +176,6 @@ public class FileSECUtils { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            //String filePath = "C:\\Users\\turbo_i49t4d3\\Downloads\\PMS项目预算编制维度-01.xlsx"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-           // File file = new File(filePath); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            //InputStream inputStream1 = new FileInputStream(filePath); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             CloseableHttpClient httpclient = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             HttpPost post = new HttpPost(url); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             post.addHeader("method~name", "fileDecryptionRest"); //文件解密 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -229,64 +226,23 @@ public class FileSECUtils { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-     * 根据地址获得数据的字节流并转换成大小 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-     * @param originalPath 文件实际地址 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public static long getFileSizeByPath(String originalPath){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        InputStream inStream=null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ByteArrayOutputStream outStream=null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        long size = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            inStream = FileServiceFactory.getAttachmentFileService().getInputStream(originalPath); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            outStream = new ByteArrayOutputStream(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            byte[] buffer = new byte[1024]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            int len = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            while( (len = inStream.read(buffer)) != -1 ){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                outStream.write(buffer, 0, len); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            byte[] bt =  outStream.toByteArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if(null != bt && bt.length > 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                DecimalFormat df = new DecimalFormat("#"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                size = Integer.parseInt(df.format((double) bt.length)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                logger.info("SEC附件 文件大小: " + size); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                logger.info("SEC附件 没有从路径上获得内容"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            inStream.close(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            outStream.close(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            logger.info("SEC附件 文件大小ERR: " + e.getMessage()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        }finally{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            try{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if(inStream !=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    inStream.close(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if(outStream !=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    outStream.close(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } catch (IOException e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                logger.info("SEC附件 文件大小ERR: " + e.getMessage()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return size; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public static InputStream processFileWithSEC(String path,InputStream inputStream) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         File tempFile = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            logger.info("--------------SEC附件 processFileWithSEC1 ----------------"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            logger.info("--------------SEC附件解密 processFileWithSEC1 ----------------"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             String filename = getFileNameWithoutExtension(path); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             String filetype = getFileType(path); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+             * 判断是否是媒体文件,如果是媒体文件,则不进行处理 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+             */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            boolean isMedia = isMediaFile(filetype); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(isMedia){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return inputStream; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             String filepath =  System.getProperty("java.io.tmpdir") + "/" + filename; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 1. 将 InputStream 写入本地临时文件 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             tempFile = File.createTempFile(filepath,"."+filetype); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            logger.info("--------------SEC附件临时路径"+filepath,"."+filetype+" ----------------"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            logger.info("--------------SEC附件临时路径 "+filepath,"."+filetype+" ----------------"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             tempFile.deleteOnExit(); // 确保 JVM 退出时删除临时文件 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             try (FileOutputStream fos = new FileOutputStream(tempFile)) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -368,5 +324,22 @@ public class FileSECUtils { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return fileName.substring(0, dotIndex); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public static boolean isMediaFile(String fileType) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (fileType == null || fileType.isEmpty()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 转换为小写,便于匹配 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String type = fileType.toLowerCase(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<String> mediaTypes = Arrays.asList( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                "mp4", "mkv", "flv", "avi", "mov", "wmv", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                "mpeg", "mpg", "3gp", "webm", "ts", "m4v", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                "jpg", "jpeg", "png", "gif", "bmp", "webp", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                "tiff", "svg", "ico", "heic","pic" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return mediaTypes.contains(type); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |