diff options
author | tknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c> | 2010-01-14 17:03:02 +0000 |
---|---|---|
committer | tknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c> | 2010-01-14 17:03:02 +0000 |
commit | 3231b0d2c665d5493e3a1e63106b8bc934d9094b (patch) | |
tree | 7916522e394a974f8562488295998dbcdbc9d50d /src | |
parent | a60dc1973ad78883bf067f15bdc8dd749509cd2b (diff) | |
download | pdf-as-3-3231b0d2c665d5493e3a1e63106b8bc934d9094b.tar.gz pdf-as-3-3231b0d2c665d5493e3a1e63106b8bc934d9094b.tar.bz2 pdf-as-3-3231b0d2c665d5493e3a1e63106b8bc934d9094b.zip |
- 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
Diffstat (limited to 'src')
14 files changed, 59 insertions, 19 deletions
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 Binary files differindex b5cc858..74aac6c 100644 --- a/src/main/resources/DefaultConfiguration.zip +++ b/src/main/resources/DefaultConfiguration.zip 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ändert. 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.
|