From 3231b0d2c665d5493e3a1e63106b8bc934d9094b Mon Sep 17 00:00:00 2001 From: tknall Date: Thu, 14 Jan 2010 17:03:02 +0000 Subject: - Errorcode for unsupported signature method introduced - Errorcode for unknown (internal error) introduced - Fixed issue: in case of unexpected error (RunTimeException for instance) the output file was not deleted - Some System.out.println commands replaced by log.debug messages - Typos fixed - "can-break-after" character list extended: "." added - Configuration updated - DefaultConfiguration updated - internal version set to 3.1 in preparation for release - maven2-repository updated (pdfbox-0.7.2-pdfas-2 compiled for log4j) - pdfbox-0.7.2-pdfas-2 updated (some debug messages) git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@552 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- external/pdfbox-0.7.2-pdfas-2.zip | Bin 6959391 -> 6959105 bytes external/pdfbox-0.7.2.utf8-pdfas.zip | Bin 6747179 -> 0 bytes maven2-repository/maven2-repository.zip | Bin 24460724 -> 24266686 bytes pom.xml | 2 +- .../commandline/CommandlineConnectorChooser.java | 3 ++- .../java/at/gv/egiz/pdfas/commandline/Main.java | 23 +++++++++++++++++++-- .../at/gv/egiz/pdfas/exceptions/ErrorCode.java | 2 ++ .../java/at/knowcenter/wag/egov/egiz/PdfAS.java | 2 +- .../knowcenter/wag/egov/egiz/commandline/Main.java | 23 +++++++++++++++++++-- .../wag/egov/egiz/pdf/BinarySignature.java | 2 +- .../wag/egov/egiz/pdf/PDFSignatureObjectIText.java | 2 +- .../knowcenter/wag/egov/egiz/pdf/Placeholder.java | 2 +- .../wag/egov/egiz/sig/SignatureObject.java | 2 +- .../at/knowcenter/wag/egov/egiz/sig/X509Cert.java | 4 ---- .../egov/egiz/sig/connectors/ConnectorChooser.java | 5 +++-- .../wag/exactparser/parsing/PDFUtils.java | 2 +- src/main/resources/DefaultConfiguration.zip | Bin 635349 -> 635287 bytes src/main/resources/config/help_text.properties | 6 ++++-- work/cfg/config.properties | 5 +---- work/cfg/log4j.properties | 8 +++---- 20 files changed, 64 insertions(+), 29 deletions(-) delete mode 100644 external/pdfbox-0.7.2.utf8-pdfas.zip diff --git a/external/pdfbox-0.7.2-pdfas-2.zip b/external/pdfbox-0.7.2-pdfas-2.zip index 95dfc9b..46b88dc 100644 Binary files a/external/pdfbox-0.7.2-pdfas-2.zip and b/external/pdfbox-0.7.2-pdfas-2.zip differ diff --git a/external/pdfbox-0.7.2.utf8-pdfas.zip b/external/pdfbox-0.7.2.utf8-pdfas.zip deleted file mode 100644 index f31e81d..0000000 Binary files a/external/pdfbox-0.7.2.utf8-pdfas.zip and /dev/null differ diff --git a/maven2-repository/maven2-repository.zip b/maven2-repository/maven2-repository.zip index a2b8842..18650fc 100644 Binary files a/maven2-repository/maven2-repository.zip and b/maven2-repository/maven2-repository.zip differ diff --git a/pom.xml b/pom.xml index a6ec5d7..d70b2bc 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ knowcenter pdf-as PDF-AS - 3.1-snapshot + 3.1 Amtssignatur fuer elektronische Aktenfuehrung diff --git a/src/main/java/at/gv/egiz/pdfas/commandline/CommandlineConnectorChooser.java b/src/main/java/at/gv/egiz/pdfas/commandline/CommandlineConnectorChooser.java index c0532a4..50678db 100644 --- a/src/main/java/at/gv/egiz/pdfas/commandline/CommandlineConnectorChooser.java +++ b/src/main/java/at/gv/egiz/pdfas/commandline/CommandlineConnectorChooser.java @@ -3,6 +3,7 @@ */ package at.gv.egiz.pdfas.commandline; +import at.gv.egiz.pdfas.exceptions.ErrorCode; import at.gv.egiz.pdfas.framework.ConnectorFactory; import org.apache.commons.logging.Log; @@ -118,7 +119,7 @@ public class CommandlineConnectorChooser return chooseDetachedMultipartConnector(connectorType); } - throw new ConnectorException(310, "The SIG_KZ version '" + sig_kz.getVersion() + "' is unknown."); + throw new ConnectorException(ErrorCode.UNSUPPORTED_SIGNATURE_METHOD, "The SIG_KZ version '" + sig_kz.getVersion() + "' is unknown."); } protected static String chooseEnvelopingBase64ConnectorOld(String sig_app) throws ConnectorException diff --git a/src/main/java/at/gv/egiz/pdfas/commandline/Main.java b/src/main/java/at/gv/egiz/pdfas/commandline/Main.java index c4895c0..2e0e674 100644 --- a/src/main/java/at/gv/egiz/pdfas/commandline/Main.java +++ b/src/main/java/at/gv/egiz/pdfas/commandline/Main.java @@ -519,9 +519,10 @@ public abstract class Main } DataSink dataSink = null; + File outputFile = null; try { - File outputFile = new File(output); + outputFile = new File(output); dataSink = new FileBasedDataSink(outputFile); } @@ -530,7 +531,25 @@ public abstract class Main throw new PDFDocumentException(ErrorCode.CANNOT_WRITE_PDF, e); } - processSign(dataSource, connector, signature_mode, signature_type, pos_string, dataSink); + try { + processSign(dataSource, connector, signature_mode, signature_type, pos_string, dataSink); + } catch (Exception e) { + // Exception caught in order to delete file based datasink + if (outputFile != null && outputFile.exists()) + { + logger_.debug("Deleting output file on error."); + boolean deleted = outputFile.delete(); + if (!deleted) + { + logger_.error("Couldn't delete output file " + output); + } + } + if (e instanceof PresentableException) { + throw (PresentableException)e; + } else { + throw new PresentableException(ErrorCode.UNKNOWN_ERROR, e); + } + } // for performance measurement if (logger_.isInfoEnabled()) 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 f9616cf..c53151f 100644 --- a/src/main/java/at/gv/egiz/pdfas/exceptions/ErrorCode.java +++ b/src/main/java/at/gv/egiz/pdfas/exceptions/ErrorCode.java @@ -15,6 +15,7 @@ package at.gv.egiz.pdfas.exceptions; public final class ErrorCode { public static final int EXTERNAL_ERROR = 0; + public static final int UNKNOWN_ERROR = 6; public static final int SETTING_NOT_FOUND = 100; public static final int SETTINGS_EXCEPTION = 101; @@ -46,6 +47,7 @@ public final class ErrorCode public static final int NON_BINARY_SIGNATURES_PRESENT = 317; public static final int UNSUPPORTED_REPLACES_NAME = 318; + public static final int UNSUPPORTED_SIGNATURE_METHOD = 319; public static final int SIGNATURE_VERIFICATION_NOT_SUPPORTED = 371; public static final int INVALID_SIGNING_TIME = 372; diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java b/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java index 57e003a..59a6220 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java @@ -99,7 +99,7 @@ public abstract class PdfAS * The current version of the pdf-as library. This version string is logged on every invocation * of the api or the web application. */ - public static final String PDFAS_VERSION = "3.1-snapshot (20091221)"; + public static final String PDFAS_VERSION = "3.1 (20100114)"; /** * The key of the strict mode setting. diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/commandline/Main.java b/src/main/java/at/knowcenter/wag/egov/egiz/commandline/Main.java index 21dd5bf..a746612 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/commandline/Main.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/commandline/Main.java @@ -482,9 +482,10 @@ public abstract class Main } FileBasedDataSink dataSink = null; + File outputFile = null; try { - File outputFile = new File(output); + outputFile = new File(output); dataSink = new FileBasedDataSink(outputFile); } @@ -493,7 +494,25 @@ public abstract class Main throw new PDFDocumentException(ErrorCode.CANNOT_WRITE_PDF, e); } - processSign(pdfDataSource, connector, signature_mode, signature_type, pos_string, dataSink); + try { + processSign(pdfDataSource, connector, signature_mode, signature_type, pos_string, dataSink); + } catch (Exception e) { + // Exception caught in order to delete file based datasink + if (outputFile != null && outputFile.exists()) + { + logger_.debug("Deleting output file on error."); + boolean deleted = outputFile.delete(); + if (!deleted) + { + logger_.error("Couldn't delete output file " + output); + } + } + if (e instanceof PresentableException) { + throw (PresentableException)e; + } else { + throw new PresentableException(ErrorCode.UNKNOWN_ERROR, e); + } + } // for performance measurement if (logger_.isInfoEnabled()) { diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/BinarySignature.java b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/BinarySignature.java index 4672cc5..ef4e1c2 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/BinarySignature.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/BinarySignature.java @@ -1556,7 +1556,7 @@ public abstract class BinarySignature if (!value.equals(restored_value)) { // debug: - System.out.println("WinAnsiEncoding doesn't fit - using URL instead!"); + logger.warn("WinAnsiEncoding doesn't fit - using URL instead!"); // /debug! replace_bytes = Placeholder.applyURLEncoding(value); diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFSignatureObjectIText.java b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFSignatureObjectIText.java index dc85a4f..a843369 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFSignatureObjectIText.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFSignatureObjectIText.java @@ -323,7 +323,7 @@ public class PDFSignatureObjectIText implements PDFSignatureObject String pdfa = SettingsReader.getInstance().getSetting("sig_obj." +profileid+".key."+SIG_PDFA1_B_VALID, "default."+SIG_PDFA1_B_VALID, "false"); pdfaValid= "true".equalsIgnoreCase(pdfa); SubsetLocal.set(!pdfaValid); - logger_.trace("Sign PDF/A complient:"+pdfa); + logger_.trace("Sign PDF/A compliant:"+pdfa); } catch (SettingsException e1) { logger_.error(e1); diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/Placeholder.java b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/Placeholder.java index 31b5945..643eff7 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/Placeholder.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/Placeholder.java @@ -354,7 +354,7 @@ public abstract class Placeholder */ protected static boolean canBreakAfter(byte character) { - return (character == ' ' || character == ',' || character == ';' || character == '-' || character == '\n') ; + return (character == ' ' || character == '.' || character == ',' || character == ';' || character == '-' || character == '\n') ; } /** diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureObject.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureObject.java index 1581047..d628fdb 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureObject.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureObject.java @@ -1133,7 +1133,7 @@ public class SignatureObject implements Serializable boolean deleted = cert_file.delete(); if (deleted == false) { - System.err.println("couldn't delete:" + cert_file.getAbsolutePath()); + logger_.error("couldn't delete:" + cert_file.getAbsolutePath()); } } } diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/X509Cert.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/X509Cert.java index 1a2ccbc..b18b7ac 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/X509Cert.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/X509Cert.java @@ -449,10 +449,6 @@ public class X509Cert implements Serializable try { list = x509Cert_.getExtendedKeyUsage(); - if (list == null) - { - System.err.println("is realy null"); - } } catch (CertificateParsingException e) { diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/ConnectorChooser.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/ConnectorChooser.java index 7188273..96f2311 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/ConnectorChooser.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/ConnectorChooser.java @@ -7,6 +7,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import at.gv.egiz.pdfas.api.commons.Constants; +import at.gv.egiz.pdfas.exceptions.ErrorCode; import at.gv.egiz.pdfas.framework.ConnectorParameters; import at.knowcenter.wag.egov.egiz.PdfASID; import at.knowcenter.wag.egov.egiz.exceptions.ConnectorException; @@ -164,7 +165,7 @@ public final class ConnectorChooser return new LocRefDetachedBKUConnector(cp, loc_ref_url); } - throw new ConnectorException(310, "The SIG_KZ version '" + sig_kz.getVersion() + "' is unknown."); + throw new ConnectorException(ErrorCode.UNSUPPORTED_SIGNATURE_METHOD, "The SIG_KZ version '" + sig_kz.getVersion() + "' is unknown."); } public static Connector chooseWebConnectorForVerify(String connector, @@ -204,7 +205,7 @@ public final class ConnectorChooser return new MOASoapWithAttachmentConnector(cp); } - throw new ConnectorException(310, "The SIG_KZ version '" + sig_kz.getVersion() + "' is unknown."); + throw new ConnectorException(ErrorCode.UNSUPPORTED_SIGNATURE_METHOD, "The SIG_KZ version '" + sig_kz.getVersion() + "' is unknown."); } // public static Connector chooseCommandlineConnectorForVerify(String connector, diff --git a/src/main/java/at/knowcenter/wag/exactparser/parsing/PDFUtils.java b/src/main/java/at/knowcenter/wag/exactparser/parsing/PDFUtils.java index f126365..0ec1a88 100644 --- a/src/main/java/at/knowcenter/wag/exactparser/parsing/PDFUtils.java +++ b/src/main/java/at/knowcenter/wag/exactparser/parsing/PDFUtils.java @@ -1263,7 +1263,7 @@ public abstract class PDFUtils NumberParseResult npr = null; if (pr instanceof IndirectObjectReferenceParseResult) { - System.out.println("An object stream with indirect length - cannot parse this instantly - parse later again."); + log.debug("An object stream with indirect length - cannot parse this instantly - parse later again."); spr.content_end_index = -1; spr.next_index = -1; return spr; diff --git a/src/main/resources/DefaultConfiguration.zip b/src/main/resources/DefaultConfiguration.zip index b5cc858..74aac6c 100644 Binary files a/src/main/resources/DefaultConfiguration.zip and b/src/main/resources/DefaultConfiguration.zip differ diff --git a/src/main/resources/config/help_text.properties b/src/main/resources/config/help_text.properties index 0a0c793..290e59f 100644 --- a/src/main/resources/config/help_text.properties +++ b/src/main/resources/config/help_text.properties @@ -1,10 +1,11 @@ #ErrorCodeException -error.code.0=Externer Fehler. +error.code.0=Externer Fehler error.code.1=Das Dokument kann nicht signiert werden. error.code.2=Die Signatur für das Dokument kann nicht überprüft werden. error.code.3=Es wurde kein Dokument zur Signierung angegeben oder das Dokument konnte nicht gespeichert werden. error.code.4=Es wurde kein Dokument zur Überprüfung angegeben oder das Dokument konnte nicht gespeichert werden. error.code.5=Zum Signieren eines Dokmentes müssen Sie authentifiziert sein. +error.code.6=Unbekannter Fehler error.code.10=Das System kann nicht initialisiert werden. Bitte wenden Sie sich an einen Systemadministrator. @@ -47,7 +48,7 @@ error.code.303=Die Signatur kann nicht erstellt werden. Die Seriennummer ist ung error.code.304=Die Signatur kann nicht erstellt werden. Das Signatur Zertifikat kann nicht gelesen werden. error.code.305=Die Signatur kann nicht erstellt werden. Das gewählte Signaturprofil ist nicht für die Textsignatur geeignet, da es nicht alle notwendigen Signaturfelder sichtbar definiert. Bitte wählen Sie ein anderes Signaturprofil oder führen Sie eine Binärsignatur durch. -error.code.310=Die Signatur kann nicht überprüft werden. +error.code.310=Die Signatur konnte nicht verifiziert werden. error.code.311=Der zu prüfende Text ist nicht definiert. error.code.312=Die zu prüfende Signatur ist nicht definiert. error.code.313=Das Zertifikat (Seriennummer oder Aussteller) ist unbekannt oder kann nicht zugeordnet werden. @@ -59,6 +60,7 @@ error.code.316=Das Dokument wurde nach erfolgter Signierung ver error.code.317=Das Dokument enthält nicht-binäre Signaturen. error.code.318=Die binäre Signatur kann nicht geprüft werden. Die Signatur enthält nicht unterstützte /replaces-Namen. +error.code.319=Die Signatur konnte nicht verifiziert werden, da diese auf einer nicht unterstützten Signaturmethode basiert. Bitte aktualisieren Sie Ihre PDF-AS Software. error.code.320=Es kann keine Verbindung zur Bürgerkartenumgebung hergestellt werden. error.code.330=Es kann keine Verbindung zu MOA hergestellt werden oder MOA hat den Request zurückgewiesen. diff --git a/work/cfg/config.properties b/work/cfg/config.properties index e6d5d44..cb50888 100644 --- a/work/cfg/config.properties +++ b/work/cfg/config.properties @@ -68,9 +68,6 @@ check_old_textual_sigs=true # MOA Detached Signieren aus Konsole möglich - zurzeit möglich nur mit BKU moa.sign.console.detached.enabled=false -# MOA Kennzeichnungsfeld anzeigen -# moa.id.field.visible=false -> depracated not used anymore, use signatureprofile to enable/disable - ############################################# # Signaturdienste @@ -666,7 +663,7 @@ sig_obj.BAIK_URKUNDE_SIGNATUR.value.SIG_TITLE=ELEKTRONISCHE BEURKUNDUNGSSIGNATUR sig_obj.BAIK_URKUNDE_SIGNATUR.phlength.SIG_META=50 sig_obj.BAIK_URKUNDE_SIGNATUR.phlength.SIG_SIG_LABEL=200 -sig_obj.BAIK_URKUNDE_SIGNATUR.value.SIG_SIG_LABEL=${sso.certSubjectDNPart("CN")}, ${sso.certSubjectDNPart("O")}${sso.certSubjectDNPart("L") != null ? (", Kanzleisitz: " + sso.certSubjectDNPart("L")) : ""} +sig_obj.BAIK_URKUNDE_SIGNATUR.value.SIG_SIG_LABEL=${sso.certSubjectDNPart("CN")}${sso.certSubjectDNPart("O") != null ? ("\n" + sso.certSubjectDNPart("O")) : ""}${sso.certSubjectDNPart("L") != null ? ("\nKanzleisitz: " + sso.certSubjectDNPart("L")) : ""} #---------------------- MAIN TABLE ------------------------- sig_obj.BAIK_URKUNDE_SIGNATUR.table.main.1=SIG_TITLE-v diff --git a/work/cfg/log4j.properties b/work/cfg/log4j.properties index 8bb0c67..f4e00e6 100644 --- a/work/cfg/log4j.properties +++ b/work/cfg/log4j.properties @@ -1,12 +1,10 @@ log4j.rootLogger = WARN, CONSOLE, ROLLINGFILE # DETAIL LEVELS -log4j.logger.at.gv.egiz.pdfas = DEBUG -log4j.logger.at.knowcenter = DEBUG -#log4j.logger.at.gv.egiz.pdfas = INFO -#log4j.logger.at.knowcenter = INFO +log4j.logger.at.gv.egiz.pdfas = INFO +log4j.logger.at.knowcenter = INFO +log4j.logger.at.gv.egiz.pdfas.performance = DEBUG log4j.logger.org.apache.commons.httpclient.HttpMethodBase = ERROR -log4j.logger.at.gv.egiz.pdfas.impl.vfilter.helper.VerificationFilterBinaryHelper = TRACE # CONSOLE log4j.appender.CONSOLE = org.apache.log4j.ConsoleAppender -- cgit v1.2.3