aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authortknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2010-01-14 17:03:02 +0000
committertknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2010-01-14 17:03:02 +0000
commit3231b0d2c665d5493e3a1e63106b8bc934d9094b (patch)
tree7916522e394a974f8562488295998dbcdbc9d50d /src/main/java
parenta60dc1973ad78883bf067f15bdc8dd749509cd2b (diff)
downloadpdf-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/main/java')
-rw-r--r--src/main/java/at/gv/egiz/pdfas/commandline/CommandlineConnectorChooser.java3
-rw-r--r--src/main/java/at/gv/egiz/pdfas/commandline/Main.java23
-rw-r--r--src/main/java/at/gv/egiz/pdfas/exceptions/ErrorCode.java2
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java2
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/commandline/Main.java23
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/pdf/BinarySignature.java2
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFSignatureObjectIText.java2
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/pdf/Placeholder.java2
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureObject.java2
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/X509Cert.java4
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/ConnectorChooser.java5
-rw-r--r--src/main/java/at/knowcenter/wag/exactparser/parsing/PDFUtils.java2
12 files changed, 55 insertions, 17 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;