From f379b187f8e65dbb5af3b0d73164bcdaff3e5f45 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Thu, 15 Jul 2010 03:10:10 +0800 Subject: [PATCH] * minor development configuration and build changes. * reduce the usage of non official sun api. --- JasperReports/.classpath | 2 +- .../.settings/org.eclipse.jdt.core.prefs | 3 +- JasperReports/META-INF/MANIFEST.MF | 6 +-- JasperReports/build.properties | 2 +- .../src/org/compiere/utils/DigestOfFile.java | 46 ++++++++----------- 5 files changed, 26 insertions(+), 33 deletions(-) diff --git a/JasperReports/.classpath b/JasperReports/.classpath index 3b5382a9c0..59bd5c5a83 100644 --- a/JasperReports/.classpath +++ b/JasperReports/.classpath @@ -1,7 +1,7 @@ - + diff --git a/JasperReports/.settings/org.eclipse.jdt.core.prefs b/JasperReports/.settings/org.eclipse.jdt.core.prefs index e1100a3f02..dc008494f4 100644 --- a/JasperReports/.settings/org.eclipse.jdt.core.prefs +++ b/JasperReports/.settings/org.eclipse.jdt.core.prefs @@ -1,5 +1,6 @@ -#Wed Mar 24 23:21:11 CET 2010 +#Wed Jul 14 15:38:16 MYT 2010 eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error diff --git a/JasperReports/META-INF/MANIFEST.MF b/JasperReports/META-INF/MANIFEST.MF index 2e3b3a3487..8ff2a25b86 100644 --- a/JasperReports/META-INF/MANIFEST.MF +++ b/JasperReports/META-INF/MANIFEST.MF @@ -7,9 +7,9 @@ Bundle-ClassPath: JasperReports.jar Export-Package: org.compiere.interfaces, org.compiere.report, org.compiere.utils -Require-Bundle: org.adempiere.base;bundle-version="0.0.0", +Require-Bundle: org.adempiere.base;bundle-version="1.0.0", org.adempiere.JasperReportsTools;bundle-version="1.0.0", - org.adempiere.client;bundle-version="0.0.0", + org.adempiere.client;bundle-version="1.0.0", com.springsource.javax.ejb;bundle-version="3.0.0", - org.adempiere.tools;bundle-version="0.0.0" + org.adempiere.tools;bundle-version="1.0.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.6 diff --git a/JasperReports/build.properties b/JasperReports/build.properties index d3413af8c4..fbee266820 100644 --- a/JasperReports/build.properties +++ b/JasperReports/build.properties @@ -1,4 +1,4 @@ source.JasperReports.jar = src/ -output.JasperReports.jar = build +output.JasperReports.jar = build/ bin.includes = META-INF/,\ JasperReports.jar diff --git a/JasperReports/src/org/compiere/utils/DigestOfFile.java b/JasperReports/src/org/compiere/utils/DigestOfFile.java index 0a6d2b3ad1..724b54023c 100644 --- a/JasperReports/src/org/compiere/utils/DigestOfFile.java +++ b/JasperReports/src/org/compiere/utils/DigestOfFile.java @@ -6,10 +6,7 @@ import java.io.FileInputStream; import java.io.InputStream; import java.security.MessageDigest; -import org.apache.commons.codec.binary.Base64; - -import sun.security.provider.Sun; - +import org.apache.commons.codec.binary.Base64; /** * @author rlemeill @@ -19,14 +16,14 @@ import sun.security.provider.Sun; public class DigestOfFile { /** - * @param mode ie MD5 + * @param algorithm ie MD5 * @throws Exception */ - public DigestOfFile(String mode) throws Exception + public DigestOfFile(String algorithm) throws Exception { - digestAgent = MessageDigest.getInstance(mode, "SUN"); + digestAgent = MessageDigest.getInstance(algorithm); } - + /** * @param file to hash * @return hash @@ -44,14 +41,14 @@ public class DigestOfFile byte[] digest = digestAgent.digest(); return digest; } - + public synchronized byte[] digestAsByteArray(byte[] input) throws Exception { digestAgent.reset(); byte[] digest = digestAgent.digest(input); return digest; } - + /** * @author rlemeill * @param file @@ -65,7 +62,7 @@ public class DigestOfFile String digestAsBase64 = new String(encoder.encode(digest),"ASCII"); return digestAsBase64; } - + /** * @param input * @return hash (base64 encoded) @@ -78,15 +75,15 @@ public class DigestOfFile String digestAsBase64 = new String(encoder.encode(digest),"ASCII"); return digestAsBase64; } - - - + + + //private static final char[] HEX_CHARS = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'}; - + private MessageDigest digestAgent; //private Base64 base64Encoder = new Base64(); private byte[] buffer = new byte[4096]; - + /** * @author rlemeill * @param args file @@ -95,10 +92,8 @@ public class DigestOfFile { try { - java.security.Security.addProvider(new Sun()); - DigestOfFile md5DigestAgent = new DigestOfFile("MD5"); - + for (int argIndex = 0; argIndex < args.length; argIndex++) { { @@ -112,8 +107,8 @@ public class DigestOfFile e.printStackTrace(System.out); } } - - + + /** * @param file1 first file to compare * @param file2 second file to compare @@ -124,7 +119,6 @@ public class DigestOfFile //compute Hash of exisiting and downloaded String hashFile1; String hashFile2; - java.security.Security.addProvider(new Sun()); try{ DigestOfFile md5DigestAgent = new DigestOfFile("MD5"); hashFile1 = md5DigestAgent.digestAsBase64(file1); @@ -134,8 +128,8 @@ public class DigestOfFile { return false; //if there is an error during comparison return files are difs } - } - + } + /** * @param file * @return md5 hash null if file is not found or other error @@ -143,7 +137,6 @@ public class DigestOfFile public static String GetLocalMD5Hash(File file) { String hash; - java.security.Security.addProvider(new Sun()); try{ DigestOfFile md5DigestAgent = new DigestOfFile("MD5"); hash = md5DigestAgent.digestAsBase64(file); @@ -153,7 +146,7 @@ public class DigestOfFile return null; //if there is an error during comparison return files are difs } } - + /** * Get md5 hash from byte[] * @param input @@ -162,7 +155,6 @@ public class DigestOfFile public static String getMD5Hash(byte[] input) { String hash; - java.security.Security.addProvider(new Sun()); try{ DigestOfFile md5DigestAgent = new DigestOfFile("MD5"); hash = md5DigestAgent.digestAsBase64(input);