diff options
author | ferbas <ferbas@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c> | 2009-11-13 12:48:33 +0000 |
---|---|---|
committer | ferbas <ferbas@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c> | 2009-11-13 12:48:33 +0000 |
commit | d9df79b2e2f72415c11dde46b09d4db5d5833f81 (patch) | |
tree | 5d7b27a0897add9c7f31629cc8bcf2045f264c0d /src/main/java/at/gv/egiz/pdfas/impl | |
parent | 21adbe038b228646e269f3c0578c9510aa32c955 (diff) | |
download | pdf-as-3-d9df79b2e2f72415c11dde46b09d4db5d5833f81.tar.gz pdf-as-3-d9df79b2e2f72415c11dde46b09d4db5d5833f81.tar.bz2 pdf-as-3-d9df79b2e2f72415c11dde46b09d4db5d5833f81.zip |
baik support
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@399 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
Diffstat (limited to 'src/main/java/at/gv/egiz/pdfas/impl')
-rw-r--r-- | src/main/java/at/gv/egiz/pdfas/impl/verificator/binary/BinaryVerificator_1_0_0.java | 65 |
1 files changed, 55 insertions, 10 deletions
diff --git a/src/main/java/at/gv/egiz/pdfas/impl/verificator/binary/BinaryVerificator_1_0_0.java b/src/main/java/at/gv/egiz/pdfas/impl/verificator/binary/BinaryVerificator_1_0_0.java index 3107368..9ca2246 100644 --- a/src/main/java/at/gv/egiz/pdfas/impl/verificator/binary/BinaryVerificator_1_0_0.java +++ b/src/main/java/at/gv/egiz/pdfas/impl/verificator/binary/BinaryVerificator_1_0_0.java @@ -109,6 +109,12 @@ public class BinaryVerificator_1_0_0 implements Verificator * The /Cert key in the EGIZ Dict.
*/
public static final byte[] EGIZ_CERT_NAME = new byte[] { 'C', 'e', 'r', 't' };
+
+ /**
+ * The /TimeStamp key in the EGIZ Dict.
+ */
+ public static final byte[] EGIZ_TIMESTAMP_NAME = new byte[] { 'T', 'i', 'm', 'e', 'S', 't', 'a', 'm', 'p' };
+
/**
* The logger definition.
@@ -152,7 +158,8 @@ public class BinaryVerificator_1_0_0 implements Verificator ArrayParseResult kz_apr = (ArrayParseResult) getRequiredValueOfKey(pdf, egiz_dict, EGIZ_KZ_NAME);
PdfASID kz = null;
// String kz_string = VerificationFilter.restoreKZ(pdf, kz_apr);
- String kz_string = VerificationFilterBinaryHelper.restoreKZ(pdf, kz_apr);
+ String kz_string = VerificationFilterBinaryHelper.restoreKZ(pdf, kz_apr); // dferbas hack baik test
+ // TODO baik hack kz_string = "urn:pdfsigfilter:bka.gv.at:binaer:v1.0.0";
kz = new PdfASID(kz_string);
if (!kz_string.equals(getMyId().toString()))
{
@@ -176,6 +183,25 @@ public class BinaryVerificator_1_0_0 implements Verificator cert = Placeholder.unescapePDFString(encoded);
}
+
+ //timestamp
+ ArrayParseResult timestamp_apr = (ArrayParseResult) getValueOfKey(pdf, egiz_dict, EGIZ_TIMESTAMP_NAME);
+ byte[] timestamp = null;
+ if (timestamp_apr != null) {
+ logger_.debug("found /TimeStamp in egiz dict. Extracting...");
+
+ if (timestamp_apr != null && !timestamp_apr.elements.isEmpty())
+ {
+ LiteralStringParseResult lspr = (LiteralStringParseResult) timestamp_apr.elements.get(0);
+ int str_length = lspr.content_end_index - lspr.content_start_index;
+ byte[] encoded = new byte[str_length];
+ System.arraycopy(pdf, lspr.content_start_index, encoded, 0, encoded.length);
+
+ timestamp = Placeholder.unescapePDFString(encoded);
+
+ }
+ }
+
int num_byte_ranges = byte_ranges_apr.elements.size() / 2;
List byte_ranges = new ArrayList();
@@ -247,6 +273,14 @@ public class BinaryVerificator_1_0_0 implements Verificator signature_object.initByType();
signature_object.setKZ(kz);
+
+ if (timestamp != null) {
+ String ts = new String(trimZeroBytes(timestamp));
+ signature_object.setTimeStamp(ts);
+ if (logger_.isDebugEnabled()) {
+ logger_.debug("extracted timestamp " + ts);
+ }
+ }
if (cert != null)
{
@@ -258,15 +292,7 @@ public class BinaryVerificator_1_0_0 implements Verificator // cf.generateCertificate(bais);
// trim zero bytes. - the base 64 cert must not have zero bytes.
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- for (int i = 0; i < cert.length; i++)
- {
- if (cert[i] != 0)
- {
- baos.write(cert[i]);
- }
- }
- byte[] b64 = baos.toByteArray();
+ byte[] b64 = trimZeroBytes(cert);
signature_object.storeNewCertificateInLocalStore(b64);
}
@@ -314,6 +340,12 @@ public class BinaryVerificator_1_0_0 implements Verificator signature_object.setSignationIDs(ri.value);
continue;
}
+
+ if (type.equals(SignatureTypes.SIG_ALG))
+ {
+ signature_object.setSigAlg(ri.value);
+ continue;
+ }
}
int iu_length = signed_pdf.length - start_of_whole_block;
@@ -332,6 +364,19 @@ public class BinaryVerificator_1_0_0 implements Verificator return holders;
}
+ private byte[] trimZeroBytes(byte[] arr) {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ for (int i = 0; i < arr.length; i++)
+ {
+ if (arr[i] != 0)
+ {
+ baos.write(arr[i]);
+ }
+ }
+ byte[] b64 = baos.toByteArray();
+ return b64;
+ }
+
/**
* Retrieves the value of the key from the dictionary.
*
|