From 9b615852df5f56eeb67c4dd021a56e72d31a2498 Mon Sep 17 00:00:00 2001 From: tknall Date: Mon, 14 Dec 2009 13:47:48 +0000 Subject: Error code created for protected pdf documents. SettingsReader: Debug message for getInternalResource added (TRACE) multipart/formdata: align multipart charset with data charset added FIXME notes for FileHelper.readFromFile Signature/Verification-Demo updated git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@507 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../egiz/pdfas/api/timestamp/DummyTimeStamper.java | 10 +++++----- .../gv/egiz/pdfas/api/timestamp/TimeStamper.java | 2 +- .../at/gv/egiz/pdfas/exceptions/ErrorCode.java | 1 + .../exceptions/pdf/TextExtractionException.java | 23 ---------------------- .../egiz/pdfas/impl/input/TextDataSourceImpl.java | 8 +++++--- 5 files changed, 12 insertions(+), 32 deletions(-) delete mode 100644 src/main/java/at/gv/egiz/pdfas/exceptions/pdf/TextExtractionException.java (limited to 'src/main/java/at/gv/egiz') diff --git a/src/main/java/at/gv/egiz/pdfas/api/timestamp/DummyTimeStamper.java b/src/main/java/at/gv/egiz/pdfas/api/timestamp/DummyTimeStamper.java index c2532e8..c9c7ae7 100644 --- a/src/main/java/at/gv/egiz/pdfas/api/timestamp/DummyTimeStamper.java +++ b/src/main/java/at/gv/egiz/pdfas/api/timestamp/DummyTimeStamper.java @@ -3,6 +3,7 @@ package at.gv.egiz.pdfas.api.timestamp; import java.util.Date; import org.apache.commons.codec.binary.Base64; +import org.apache.commons.lang.time.DateFormatUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -18,12 +19,11 @@ public class DummyTimeStamper implements TimeStamper { private String lastTimeStamp; public String applyTimeStamp(String b64SignatureValue) { - log.debug("execute dummy timestamp on value: " + b64SignatureValue); - String ts = ("my dummy timestamp " + new Date()); - log.debug("timestamp: " + ts); - + log.debug("Applying dummy timestamp on signature value: " + b64SignatureValue); + String ts = DateFormatUtils.format(new Date(), "yyyy-MM-dd'T'hh:mm:ss.SSSZ"); + log.debug("Timestamp: " + ts); ts = new String(Base64.encodeBase64(ts.getBytes())); - log.debug("timestamp b64: " + ts); + log.debug("Timestamp value (base64): " + ts); this.lastTimeStamp = ts; return ts; } diff --git a/src/main/java/at/gv/egiz/pdfas/api/timestamp/TimeStamper.java b/src/main/java/at/gv/egiz/pdfas/api/timestamp/TimeStamper.java index 7100310..c39d78e 100644 --- a/src/main/java/at/gv/egiz/pdfas/api/timestamp/TimeStamper.java +++ b/src/main/java/at/gv/egiz/pdfas/api/timestamp/TimeStamper.java @@ -11,7 +11,7 @@ public interface TimeStamper { /** * Implement timestamp in this method. * @param b64SignatureValue signature value, base64 encoded - * @return timestamp to be embedded in egiz dict. base64 encoded + * @return timestamp to be embedded in egiz dictionary base64 encoded (following RFC3161). */ public String applyTimeStamp(String b64SignatureValue); diff --git a/src/main/java/at/gv/egiz/pdfas/exceptions/ErrorCode.java b/src/main/java/at/gv/egiz/pdfas/exceptions/ErrorCode.java index 857fc09..04cf779 100644 --- a/src/main/java/at/gv/egiz/pdfas/exceptions/ErrorCode.java +++ b/src/main/java/at/gv/egiz/pdfas/exceptions/ErrorCode.java @@ -28,6 +28,7 @@ public final class ErrorCode public static final int DOCUMENT_NOT_SIGNED = 206; public static final int SIGNATURE_TYPES_EXCEPTION = 223; public static final int FONT_NOT_FOUND = 230; + public static final int DOCUMENT_IS_PROTECTED = 231; public static final int SIGNATURE_COULDNT_BE_CREATED = 300; public static final int SIGNED_TEXT_EMPTY = 301; diff --git a/src/main/java/at/gv/egiz/pdfas/exceptions/pdf/TextExtractionException.java b/src/main/java/at/gv/egiz/pdfas/exceptions/pdf/TextExtractionException.java deleted file mode 100644 index 6586dd0..0000000 --- a/src/main/java/at/gv/egiz/pdfas/exceptions/pdf/TextExtractionException.java +++ /dev/null @@ -1,23 +0,0 @@ -package at.gv.egiz.pdfas.exceptions.pdf; - -import at.gv.egiz.pdfas.exceptions.ErrorCode; -import at.knowcenter.wag.egov.egiz.exceptions.PresentableException; - -public class TextExtractionException extends PresentableException -{ - /** - * SVUID. - */ - private static final long serialVersionUID = 2798763345488999563L; - - public TextExtractionException(Throwable cause) - { - super(ErrorCode.TEXT_EXTRACTION_EXCEPTION, cause); - } - - public TextExtractionException(String message) - { - super(ErrorCode.TEXT_EXTRACTION_EXCEPTION, message); - } - -} diff --git a/src/main/java/at/gv/egiz/pdfas/impl/input/TextDataSourceImpl.java b/src/main/java/at/gv/egiz/pdfas/impl/input/TextDataSourceImpl.java index c983a8a..077ed97 100644 --- a/src/main/java/at/gv/egiz/pdfas/impl/input/TextDataSourceImpl.java +++ b/src/main/java/at/gv/egiz/pdfas/impl/input/TextDataSourceImpl.java @@ -26,6 +26,8 @@ public class TextDataSourceImpl implements TextDataSource * The text. */ protected String text = null; + + private final static String CHARSET = "UTF-8"; /** * Constructor that sets the text. @@ -53,7 +55,7 @@ public class TextDataSourceImpl implements TextDataSource { try { - byte[] data = getText().getBytes("UTF-8"); + byte[] data = getText().getBytes(CHARSET); // PERF: if memory is an issue (e.g. in web), use a FileBased TextDataSource instead. return new ByteArrayInputStream(data); } @@ -70,7 +72,7 @@ public class TextDataSourceImpl implements TextDataSource { try { - byte[] data = getText().getBytes("UTF-8"); + byte[] data = getText().getBytes(CHARSET); return data.length; } catch (UnsupportedEncodingException e) @@ -86,7 +88,7 @@ public class TextDataSourceImpl implements TextDataSource { try { - byte[] data = getText().getBytes("UTF-8"); + byte[] data = getText().getBytes(CHARSET); return data; } catch (UnsupportedEncodingException e) -- cgit v1.2.3