From af90012c848711a4c9010dbcf71694dbfbca0e86 Mon Sep 17 00:00:00 2001 From: Andreas Fitzek Date: Thu, 10 Jul 2014 12:09:05 +0200 Subject: Integrity verification of Signature after Signature creation to ensure correct signed Document --- .../at/gv/egiz/pdfas/common/utils/StreamUtils.java | 44 ++++++++++++++-------- 1 file changed, 28 insertions(+), 16 deletions(-) (limited to 'pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/StreamUtils.java') diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/StreamUtils.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/StreamUtils.java index 579099f0..50ec444c 100644 --- a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/StreamUtils.java +++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/StreamUtils.java @@ -28,24 +28,36 @@ import java.io.IOException; import java.io.InputStream; /** - * Created with IntelliJ IDEA. - * User: afitzek - * Date: 8/29/13 - * Time: 9:54 AM - * To change this template use File | Settings | File Templates. + * Created with IntelliJ IDEA. User: afitzek Date: 8/29/13 Time: 9:54 AM To + * change this template use File | Settings | File Templates. */ public class StreamUtils { - public static byte[] inputStreamToByteArray(InputStream stream) throws IOException { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - byte[] buffer = new byte[4096]; - int readBytes = 0; + public static byte[] inputStreamToByteArray(InputStream stream) + throws IOException { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + byte[] buffer = new byte[4096]; + int readBytes = 0; - while((readBytes = stream.read(buffer)) != -1) { - bos.write(buffer, 0, readBytes); - } - stream.close(); - bos.close(); - return bos.toByteArray(); - } + while ((readBytes = stream.read(buffer)) != -1) { + bos.write(buffer, 0, readBytes); + } + stream.close(); + bos.close(); + return bos.toByteArray(); + } + + public static boolean dataCompare(byte[] a, byte[] b) { + if (a != null && b != null) { + if (a.length == b.length) { + for(int i = 0; i < a.length; i++) { + if(a[i] != b[i]) { + return false; + } + } + return true; + } + } + return false; + } } -- cgit v1.2.3