From c45c60eecc2f4445ae552a870aa095039644420c Mon Sep 17 00:00:00 2001 From: tknall Date: Tue, 17 Jun 2008 06:33:31 +0000 Subject: (Default) configuration updated regarding new configuration keys. Update concerting exclusion of minimal layout profiles for verification. APIDemo updated. Many printStackTraces replaces with logger-messages. Web-Application: New error code (251) introduced: Textual signature of files with no extractable textual content (e.g. files that solely contain images) is prevented. git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@293 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- dok/Issues.txt | 27 --- pom.xml | 2 +- .../java/at/gv/egiz/pdfas/commandline/Main.java | 5 +- .../gv/egiz/pdfas/exceptions/ErrorCodeHelper.java | 4 +- .../at/gv/egiz/pdfas/impl/api/PdfAsObject.java | 10 +- .../pdfas/impl/api/verify/VerifyResultAdapter.java | 11 +- .../impl/input/FileBasedPdfDataSourceImpl.java | 3 +- .../impl/input/FileBasedTextDataSourceImpl.java | 6 +- .../impl/input/correction/ExternalCorrector.java | 2 +- .../egiz/pdfas/impl/output/FileBasedDataSink.java | 3 +- .../binary/BinaryVerificator_1_0_0.java | 11 +- .../egiz/pdfas/web/helper/SignServletHelper.java | 2 +- .../java/at/knowcenter/wag/egov/egiz/PdfAS.java | 4 +- .../wag/egov/egiz/cfg/SettingsReader.java | 4 +- .../egov/egiz/exceptions/ErrorCodeException.java | 4 +- .../egov/egiz/framework/VerificationFilter.java | 4 +- .../verificators/BinaryVerificator_1_0_0.java | 2 +- .../wag/egov/egiz/ldap/api/LDAPAPIImpl.java | 10 +- .../wag/egov/egiz/pdf/BinarySignature.java | 12 +- .../wag/egov/egiz/pdf/PDFSignatureObjectIText.java | 17 -- .../knowcenter/wag/egov/egiz/pdf/Placeholder.java | 8 +- .../knowcenter/wag/egov/egiz/pdf/StringInfo.java | 7 +- .../wag/egov/egiz/sig/ConnectorFactory.java | 2 +- .../knowcenter/wag/egov/egiz/sig/DummyLDAPAPI.java | 10 +- .../wag/egov/egiz/sig/SignatureObject.java | 17 +- .../wag/egov/egiz/sig/SignatureResponse.java | 2 +- .../wag/egov/egiz/sig/SignatureTypes.java | 6 +- .../at/knowcenter/wag/egov/egiz/sig/X509Cert.java | 11 +- .../wag/egov/egiz/sig/connectors/MOAConnector.java | 4 - .../egov/egiz/sig/sigid/DetachedIdFormatter.java | 2 +- .../sig/sigid/DetachedLocRefMOAIdFormatter.java | 2 +- .../wag/egov/egiz/sig/sigkz/SigKZIDHelper.java | 12 +- .../wag/egov/egiz/tools/DebugHelper.java | 2 +- .../knowcenter/wag/egov/egiz/tools/Normalizer.java | 8 +- .../wag/egov/egiz/web/LocalRequestHelper.java | 15 +- .../egov/egiz/web/PdfASServletContextListener.java | 2 +- .../wag/egov/egiz/web/servlets/DataURLServlet.java | 6 +- .../egov/egiz/web/servlets/ProvidePDFServlet.java | 2 +- .../web/servlets/RetrieveSignatureDataServlet.java | 2 +- .../egov/egiz/web/servlets/SignPreviewServlet.java | 8 +- .../wag/egov/egiz/web/servlets/SignServlet.java | 20 +-- .../egiz/web/servlets/VerifyPreviewServlet.java | 4 +- .../wag/egov/egiz/web/servlets/VerifyServlet.java | 2 +- src/main/java/demo/APIDemo.java | 181 +++++++++++++++------ src/main/resources/DefaultConfiguration.zip | Bin 190303 -> 190525 bytes src/site/changes.xml | 17 ++ work/cfg/config.properties | 32 +++- work/cfg/help_text.properties | 1 + 48 files changed, 316 insertions(+), 212 deletions(-) diff --git a/dok/Issues.txt b/dok/Issues.txt index 36de44a..d0f5df4 100644 --- a/dok/Issues.txt +++ b/dok/Issues.txt @@ -2,30 +2,3 @@ Issue #1 (Bug oder Feature ?) Bei der Signatur eines Dokuments, dem zuvor eine leere letzte Seite hinzugefügt wurde, befindet sich die Signaturmarke am Beginn dieser letzten leeren Seite selbst wenn auf der vorletzten Seite noch genügend Platz zu Verfügung stehen würde. - -Issue #2 -Bei Aktivieren eines Minimallayout-Profils wurde bei der der Prüfung beliebiger Dokumente ein -Problem festgestellt: - -"java.lang.RuntimeException: There is no SIG_DATE in the list of found_keys. This must not happen." - -Bei der Definition eines Minimallayouts können bisher verpflichtende Einträge für die Signaturmarke -weggelassen werden (entsprechende Einträge SIG_XXX-cv in den Tabellen sowie entsprechende Keys -sig_obj.PROFIL.key.SIG_XXX=XXX). -In der eingecheckten Konfiguration (work-Verzeichnis) existieren zwei solche Minimallayouts. - -Da mit derselben Konfiguration auch Signaturen mit dem Minimallayout durchgeführt werden sollen, -kann dieses nicht einfach deaktiviert werden (für eine Verifikation binärer Signaturen benötigt man -keine aktiven Profile). - -Ein Hinzufügen der Zeilen: - -sig_obj.SIGNATURBLOCK_MINIMAL_DE.key.SIG_VALUE=Signaturwert -sig_obj.SIGNATURBLOCK_MINIMAL_DE.key.SIG_NAME=Unterzeichner -sig_obj.SIGNATURBLOCK_MINIMAL_DE.key.SIG_DATE=Datum/Zeit-UTC -sig_obj.SIGNATURBLOCK_MINIMAL_DE.key.SIG_ISSUER=Aussteller-Zertifikat -sig_obj.SIGNATURBLOCK_MINIMAL_DE.key.SIG_NUMBER=Serien-Nr. -sig_obj.SIGNATURBLOCK_MINIMAL_DE.key.SIG_KZ=Methode -sig_obj.SIGNATURBLOCK_MINIMAL_DE.key.SIG_ID=Parameter - -hat das Problem übrigens auch nicht gelöst. \ No newline at end of file diff --git a/pom.xml b/pom.xml index a95d284..c927ee6 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ knowcenter pdf-as PDF-AS - 3.0.6 + 3.0.6-20080616 Amtssignatur fuer elektronische Aktenfuehrung 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 d65ef45..c84b417 100644 --- a/src/main/java/at/gv/egiz/pdfas/commandline/Main.java +++ b/src/main/java/at/gv/egiz/pdfas/commandline/Main.java @@ -182,7 +182,10 @@ public abstract class Main } else { System.out.println("Default configuration has NOT been deployed. Maybe the configuration already exists."); } -// System.exit(0); + if (args.length == 1) { + // no other parameters supplied; exit application + System.exit(0); + } } catch (ConfigUtilsException e) { System.err.println("Deployment of default configuration failed: " + e.getMessage()); System.exit(1); diff --git a/src/main/java/at/gv/egiz/pdfas/exceptions/ErrorCodeHelper.java b/src/main/java/at/gv/egiz/pdfas/exceptions/ErrorCodeHelper.java index 5b37bdf..237a496 100644 --- a/src/main/java/at/gv/egiz/pdfas/exceptions/ErrorCodeHelper.java +++ b/src/main/java/at/gv/egiz/pdfas/exceptions/ErrorCodeHelper.java @@ -35,11 +35,11 @@ public class ErrorCodeHelper } catch (SettingsException e) { - log.warn(e); + log.warn(e.getMessage(), e); } catch (SettingNotFoundException e) { - log.warn(e); + log.warn(e.getMessage(), e); } return null; } diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java b/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java index 635ef89..40da270 100644 --- a/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java +++ b/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java @@ -238,8 +238,14 @@ public class PdfAsObject implements PdfAs String connectorId = CommandlineConnectorChooser.chooseCommandlineConnectorForSign(signParameters.getSignatureDevice()); - SignatorInformation si = PdfAS - .signCommandline(new PdfDataSourceAdapter(signParameters.getDocument()), new DataSinkAdapter(signParameters.getOutput()), signatorId, connectorId, signParameters.getSignatureProfileId(), pos); + SignatorInformation si = PdfAS.signCommandline( + new PdfDataSourceAdapter(signParameters.getDocument()), + new DataSinkAdapter(signParameters.getOutput()), + signatorId, + connectorId, + signParameters.getSignatureProfileId(), + pos + ); return new SignResultImpl(signParameters.getOutput(), si.getSignSignatureObject().getX509Certificate(), new ActualSignaturePositionAdapter(si.getActualTablePos())); } diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/verify/VerifyResultAdapter.java b/src/main/java/at/gv/egiz/pdfas/impl/api/verify/VerifyResultAdapter.java index bf3f57b..83d4db0 100644 --- a/src/main/java/at/gv/egiz/pdfas/impl/api/verify/VerifyResultAdapter.java +++ b/src/main/java/at/gv/egiz/pdfas/impl/api/verify/VerifyResultAdapter.java @@ -8,6 +8,9 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import at.gv.egiz.pdfas.api.verify.SignatureCheck; import at.gv.egiz.pdfas.api.verify.VerifyResult; import at.gv.egiz.pdfas.impl.api.commons.SignatureInformationAdapter; @@ -15,6 +18,7 @@ import at.knowcenter.wag.egov.egiz.exceptions.SettingNotFoundException; import at.knowcenter.wag.egov.egiz.pdf.SignatureHolder; import at.knowcenter.wag.egov.egiz.sig.SignatureResponse; + /** * Implements the VerifyResult interface. * @@ -24,6 +28,11 @@ public class VerifyResultAdapter extends SignatureInformationAdapter implements { protected SignatureResponse sigRes = null; + /** + * The log. + */ + private static final Log logger_ = LogFactory.getLog(VerifyResultAdapter.class); + protected Date vTime = null; /** @@ -100,7 +109,7 @@ public class VerifyResultAdapter extends SignatureInformationAdapter implements } catch (SettingNotFoundException e) { - e.printStackTrace(); + logger_.error(e.getMessage(), e); return new ArrayList(); } } diff --git a/src/main/java/at/gv/egiz/pdfas/impl/input/FileBasedPdfDataSourceImpl.java b/src/main/java/at/gv/egiz/pdfas/impl/input/FileBasedPdfDataSourceImpl.java index a3a0803..57e572f 100644 --- a/src/main/java/at/gv/egiz/pdfas/impl/input/FileBasedPdfDataSourceImpl.java +++ b/src/main/java/at/gv/egiz/pdfas/impl/input/FileBasedPdfDataSourceImpl.java @@ -97,8 +97,7 @@ public class FileBasedPdfDataSourceImpl implements PdfDataSource, FileBased } catch (IOException e) { - log.error("Couldn't create InputStream for file " + getFile() + ". Returning null."); - log.error(e); + log.error("Couldn't create InputStream for file " + getFile() + ". Returning null.", e); return null; } diff --git a/src/main/java/at/gv/egiz/pdfas/impl/input/FileBasedTextDataSourceImpl.java b/src/main/java/at/gv/egiz/pdfas/impl/input/FileBasedTextDataSourceImpl.java index 1988519..6e0f50b 100644 --- a/src/main/java/at/gv/egiz/pdfas/impl/input/FileBasedTextDataSourceImpl.java +++ b/src/main/java/at/gv/egiz/pdfas/impl/input/FileBasedTextDataSourceImpl.java @@ -88,8 +88,7 @@ public class FileBasedTextDataSourceImpl implements TextDataSource, FileBased } catch (IOException e) { - log.error("Couldn't read text for file " + getFile() + ". Returning null."); - log.error(e); + log.error("Couldn't read text for file " + getFile() + ". Returning null.", e); return null; } @@ -107,8 +106,7 @@ public class FileBasedTextDataSourceImpl implements TextDataSource, FileBased } catch (IOException e) { - log.error("Couldn't create InputStream for file " + getFile() + ". Returning null."); - log.error(e); + log.error("Couldn't create InputStream for file " + getFile() + ". Returning null.", e); return null; } diff --git a/src/main/java/at/gv/egiz/pdfas/impl/input/correction/ExternalCorrector.java b/src/main/java/at/gv/egiz/pdfas/impl/input/correction/ExternalCorrector.java index e244746..25df6a8 100644 --- a/src/main/java/at/gv/egiz/pdfas/impl/input/correction/ExternalCorrector.java +++ b/src/main/java/at/gv/egiz/pdfas/impl/input/correction/ExternalCorrector.java @@ -202,7 +202,7 @@ public class ExternalCorrector implements Corrector } catch (IOException e) { - log.error(e); + log.error(e.getMessage(), e); } } } diff --git a/src/main/java/at/gv/egiz/pdfas/impl/output/FileBasedDataSink.java b/src/main/java/at/gv/egiz/pdfas/impl/output/FileBasedDataSink.java index 4e1e3b7..4631800 100644 --- a/src/main/java/at/gv/egiz/pdfas/impl/output/FileBasedDataSink.java +++ b/src/main/java/at/gv/egiz/pdfas/impl/output/FileBasedDataSink.java @@ -78,8 +78,7 @@ public class FileBasedDataSink implements DataSink, FileBased } catch (IOException e) { - log.error("Couldn't create OutputStream for file " + getFile() + ". Returning null."); - log.error(e); + log.error("Couldn't create OutputStream for file " + getFile() + ". Returning null.", e); return null; 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 b52e97f..c2ec8ff 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 @@ -18,22 +18,17 @@ package at.gv.egiz.pdfas.impl.verificator.binary; import java.io.ByteArrayOutputStream; -import java.io.FileOutputStream; -import java.io.InputStream; import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import org.apache.log4j.Logger; + import at.gv.egiz.pdfas.exceptions.ErrorCode; import at.gv.egiz.pdfas.framework.input.PdfDataSource; import at.gv.egiz.pdfas.framework.verificator.Verificator; -import at.gv.egiz.pdfas.impl.input.ByteArrayPdfDataSourceImpl; import at.gv.egiz.pdfas.impl.input.CompoundPdfDataSourceImpl; import at.gv.egiz.pdfas.impl.input.DelimitedPdfDataSource; -import at.gv.egiz.pdfas.impl.input.helper.DataSourceHelper; - -import org.apache.log4j.Logger; - import at.knowcenter.wag.egov.egiz.PdfASID; import at.knowcenter.wag.egov.egiz.cfg.ConfigLogger; import at.knowcenter.wag.egov.egiz.cfg.SettingsReader; @@ -275,7 +270,7 @@ public class BinaryVerificator_1_0_0 implements Verificator } catch (Exception e) { - e.printStackTrace(); + logger_.error(e.getMessage(), e); } } diff --git a/src/main/java/at/gv/egiz/pdfas/web/helper/SignServletHelper.java b/src/main/java/at/gv/egiz/pdfas/web/helper/SignServletHelper.java index f9cb809..a904ad4 100644 --- a/src/main/java/at/gv/egiz/pdfas/web/helper/SignServletHelper.java +++ b/src/main/java/at/gv/egiz/pdfas/web/helper/SignServletHelper.java @@ -112,7 +112,7 @@ public class SignServletHelper // check if document is empty if (si.si.getSignatureData() == null || si.si.getSignatureData().getDataSource().getLength() == 0) { - throw new PDFDocumentException(250, "The document is empty."); + throw new PDFDocumentException(251, "Unable to extract and textual content."); } log.debug("connector = " + si.connector); //$NON-NLS-1$ 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 b9987ff..8593cf1 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java @@ -96,7 +96,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.0.6"; + public static final String PDFAS_VERSION = "3.0.6-20080616"; /** * The key of the strict mode setting. @@ -143,7 +143,7 @@ public abstract class PdfAS } catch (SettingsException e) { - e.printStackTrace(); + log.error(e.getMessage(), e); } return false; } diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/cfg/SettingsReader.java b/src/main/java/at/knowcenter/wag/egov/egiz/cfg/SettingsReader.java index c7e5933..6cd5e61 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/cfg/SettingsReader.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/cfg/SettingsReader.java @@ -570,14 +570,14 @@ public class SettingsReader implements Serializable { if (logger_.isWarnEnabled()) { - logger_.warn("Can not convert " + value + " to int."); + logger_.warn("Can not convert " + value + " to int.", e); } } catch (SettingNotFoundException e) { if (logger_.isWarnEnabled()) { - logger_.warn("Setting " + key + " not found, return default value:" + defaultValue); + logger_.warn("Setting " + key + " not found, return default value:" + defaultValue, e); } } return int_property; diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/exceptions/ErrorCodeException.java b/src/main/java/at/knowcenter/wag/egov/egiz/exceptions/ErrorCodeException.java index ec21fb5..584e716 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/exceptions/ErrorCodeException.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/exceptions/ErrorCodeException.java @@ -167,7 +167,7 @@ public class ErrorCodeException extends PresentableException catch (SettingsException e) { String log_message = "Can not load pdf signature settings. Cause:\n" + e.getMessage(); - logger_.error(log_message); + logger_.error(log_message, e); } } } @@ -293,7 +293,7 @@ public class ErrorCodeException extends PresentableException } catch (SettingsException e) { - e.printStackTrace(); + logger_.error(e.getMessage(), e); } return err_msg; } diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/framework/VerificationFilter.java b/src/main/java/at/knowcenter/wag/egov/egiz/framework/VerificationFilter.java index 6309ad4..415aa04 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/framework/VerificationFilter.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/framework/VerificationFilter.java @@ -308,7 +308,7 @@ public class VerificationFilter } catch (InvalidIDException e) { - e.printStackTrace(); + logger_.error(e.getMessage(), e); } if (kz != null && kz.getType().equals(SignatorFactory.TYPE_BINARY)) { @@ -527,7 +527,7 @@ public class VerificationFilter } catch (InvalidIDException e) { - e.printStackTrace(); + logger_.error(e.getMessage(), e); } writer.println(" holder[" + i + "]: " + holder.getSignatureObject().getSignationType() + ", KZ=" + kz); } diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/framework/verificators/BinaryVerificator_1_0_0.java b/src/main/java/at/knowcenter/wag/egov/egiz/framework/verificators/BinaryVerificator_1_0_0.java index b389a25..a6b87dc 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/framework/verificators/BinaryVerificator_1_0_0.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/framework/verificators/BinaryVerificator_1_0_0.java @@ -269,7 +269,7 @@ public class BinaryVerificator_1_0_0 implements Verificator } catch (Exception e) { - e.printStackTrace(); + logger_.error(e.getMessage(), e); } } diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/ldap/api/LDAPAPIImpl.java b/src/main/java/at/knowcenter/wag/egov/egiz/ldap/api/LDAPAPIImpl.java index d6f3e7c..1409ae8 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/ldap/api/LDAPAPIImpl.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/ldap/api/LDAPAPIImpl.java @@ -81,11 +81,11 @@ public class LDAPAPIImpl implements LDAPAPI { } } catch (SettingsException e) { - this.log.error(e); + this.log.error(e.getMessage(), e); } catch (SettingNotFoundException e) { - this.log.error(e); + this.log.error(e.getMessage(), e); } catch (LDAPException e) { - this.log.error(e); + this.log.error(e.getMessage(), e); } ; } @@ -98,7 +98,7 @@ public class LDAPAPIImpl implements LDAPAPI { LDAPClient client = this.ldapClientFactory.createClient(issuer); url = client.getUrl().toString(); } catch (LDAPException e) { - this.log.error(e); + this.log.error(e.getMessage(), e); } return url; } @@ -113,7 +113,7 @@ public class LDAPAPIImpl implements LDAPAPI { base64CertData = Util.Base64Encode(x509certificate.toByteArray()); } } catch (LDAPException e) { - this.log.error(e); + this.log.error(e.getMessage(), e); } return base64CertData; } 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 bb34040..24840e6 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 @@ -1526,7 +1526,7 @@ public abstract class BinarySignature } catch (UnsupportedEncodingException e) { - e.printStackTrace(); + logger.error(e.getMessage(), e); } // sort replaces @@ -1597,7 +1597,7 @@ public abstract class BinarySignature } catch (UnsupportedEncodingException e) { - e.printStackTrace(); + logger.error(e.getMessage(), e); } throw new KZSettingNotFoundException("Field " + SignatureTypes.SIG_KZ + " not found."); } @@ -1648,7 +1648,7 @@ public abstract class BinarySignature } catch (IOException e) { - e.printStackTrace(); + logger.error(e.getMessage(), e); return false; } @@ -1713,7 +1713,7 @@ public abstract class BinarySignature } catch (UnsupportedEncodingException e) { - e.printStackTrace(); + logger.error(e.getMessage(), e); return false; } } @@ -1849,7 +1849,7 @@ public abstract class BinarySignature } catch (UnsupportedEncodingException e) { - e.printStackTrace(); + logger.error(e.getMessage(), e); return -1; } } @@ -1893,7 +1893,7 @@ public abstract class BinarySignature } catch (UnsupportedEncodingException e) { - e.printStackTrace(); + logger.error(e.getMessage(), e); } } 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 ad3a24c..2053264 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 @@ -311,9 +311,7 @@ public class PDFSignatureObjectIText implements PDFSignatureObject Image image = Image.getInstance(img_file.getCanonicalPath()); logger_.debug("Using image file \"" + img_file.getCanonicalPath() + "\"."); - // TODO[tknall]: enable image scaling defined by configuration image.scaleToFit(80.0f, 80.0f); - // tknall end boolean fit = true; Style.ImageScaleToFit istf = cell_style.getImageScaleToFit(); if (istf != null) @@ -326,13 +324,6 @@ public class PDFSignatureObjectIText implements PDFSignatureObject } catch (BadElementException e) { - if (logger_.isDebugEnabled()) - { - if (logger_.isDebugEnabled()) - { - e.printStackTrace(); - } - } if (logger_.isEnabledFor(Level.ERROR)) { logger_.error("BadElementException:" + e.getMessage()); @@ -342,10 +333,6 @@ public class PDFSignatureObjectIText implements PDFSignatureObject } catch (MalformedURLException e) { - if (logger_.isDebugEnabled()) - { - e.printStackTrace(); - } if (logger_.isEnabledFor(Level.ERROR)) { logger_.error("MalformedURLException:" + e.getMessage()); @@ -355,10 +342,6 @@ public class PDFSignatureObjectIText implements PDFSignatureObject } catch (IOException e) { - if (logger_.isDebugEnabled()) - { - e.printStackTrace(); - } if (logger_.isEnabledFor(Level.ERROR)) { logger_.error("Error Code: 222, IOException:" + e.getMessage()); 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 6523db9..9155f15 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 @@ -66,7 +66,7 @@ public abstract class Placeholder } catch (IOException e) { - e.printStackTrace(); + logger_.error(e.getMessage(), e); return null; } } @@ -189,7 +189,7 @@ public abstract class Placeholder } catch (UnsupportedEncodingException e) { - e.printStackTrace(); + logger_.error(e.getMessage(), e); return null; } return replace_bytes; @@ -212,7 +212,7 @@ public abstract class Placeholder } catch (UnsupportedEncodingException e) { - e.printStackTrace(); + logger_.error(e.getMessage(), e); return null; } @@ -298,7 +298,7 @@ public abstract class Placeholder } catch (UnsupportedEncodingException e) { - e.printStackTrace(); + logger_.error(e.getMessage(), e); return null; } } diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/StringInfo.java b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/StringInfo.java index 5933e4b..d2b28a4 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/StringInfo.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/StringInfo.java @@ -20,6 +20,9 @@ package at.knowcenter.wag.egov.egiz.pdf; import java.io.Serializable; import java.io.UnsupportedEncodingException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + /** * Specifies a certain data area within the pdf. * @@ -37,6 +40,8 @@ public class StringInfo implements Serializable */ private static final long serialVersionUID = 5834801907046737048L; + protected static Log logger = LogFactory.getLog(StringInfo.class); + /** * The PDF document this range belongs to. */ @@ -85,7 +90,7 @@ public class StringInfo implements Serializable } catch (UnsupportedEncodingException e) { - e.printStackTrace(); + logger.error(e.getMessage(), e); return "(" + this.string_start + "," + this.string_length + ")"; } } diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/ConnectorFactory.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/ConnectorFactory.java index 9d744e1..e8deb39 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/ConnectorFactory.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/ConnectorFactory.java @@ -337,7 +337,7 @@ public abstract class ConnectorFactory is_id_field_visible = SettingsReader.getInstance().getValueFromKey(MOA_ID_VISIBLE_PROPERTY_KEY); } catch (SettingsException e) { - e.printStackTrace(); + logger_.error(e.getMessage(), e); } // if not setted in config, show it diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/DummyLDAPAPI.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/DummyLDAPAPI.java index 47d1d20..0ab1d25 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/DummyLDAPAPI.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/DummyLDAPAPI.java @@ -20,6 +20,9 @@ package at.knowcenter.wag.egov.egiz.sig; import java.io.File; import java.io.FileInputStream; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import at.knowcenter.wag.egov.egiz.cfg.SettingsReader; import at.knowcenter.wag.egov.egiz.ldap.api.LDAPAPIException; import at.knowcenter.wag.egov.egiz.ldap.client.LDAPIssuerNameFilter; @@ -36,6 +39,11 @@ public class DummyLDAPAPI implements LDAPAPI { String url_ = null; + /** + * The Logger. + */ + protected static Log logger = LogFactory.getLog(DummyLDAPAPI.class); + public DummyLDAPAPI(String url) { this.url_ = url; @@ -70,7 +78,7 @@ public byte[] loadBase64CertificateFromLDAP(String serial_number, String issuer) } catch (Exception e) { - e.printStackTrace(); + logger.error(e.getMessage(), e); data = null; } } 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 1b9b6a6..a765e8d 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 @@ -47,7 +47,6 @@ import at.knowcenter.wag.egov.egiz.exceptions.NormalizeException; import at.knowcenter.wag.egov.egiz.exceptions.SettingsException; import at.knowcenter.wag.egov.egiz.exceptions.SignatureException; import at.knowcenter.wag.egov.egiz.exceptions.SignatureTypesException; -import at.knowcenter.wag.egov.egiz.framework.SignatorFactory; import at.knowcenter.wag.egov.egiz.ldap.api.LDAPAPIException; import at.knowcenter.wag.egov.egiz.ldap.api.LDAPAPIFactory; import at.knowcenter.wag.egov.egiz.ldap.client.LDAPIssuerNameFilter; @@ -197,7 +196,7 @@ public class SignatureObject implements Serializable try { name = parser.parse(); } catch (RFC2253NameParserException e) { - logger_.error(e); + logger_.error(e.getMessage(), e); } return name; } @@ -465,7 +464,7 @@ public class SignatureObject implements Serializable } catch (InvalidIDException e) { - e.printStackTrace(); + logger_.error(e.getMessage(), e); } return kz; } @@ -705,7 +704,7 @@ public class SignatureObject implements Serializable } catch (CertificateEncodingException e) { - logger_.error(e); + logger_.error(e.getMessage(), e); } } @@ -872,7 +871,7 @@ public class SignatureObject implements Serializable } catch (InvalidIDException e) { - logger_.error(e); + logger_.error(e.getMessage(), e); return false; } } @@ -891,7 +890,7 @@ public class SignatureObject implements Serializable } catch (InvalidIDException e) { - e.printStackTrace(); + logger_.error(e.getMessage(), e); } return SigKZIDHelper.isTextual(kz); } @@ -910,7 +909,7 @@ public class SignatureObject implements Serializable } catch (InvalidIDException e) { - e.printStackTrace(); + logger_.error(e.getMessage(), e); } return SigKZIDHelper.isBinary(kz); @@ -1175,7 +1174,7 @@ public class SignatureObject implements Serializable Name issuerName = new RFC2253NameParser(issuer).parse(); cert = loadCertificateFromCertstore(serialNumber, issuerName.getRFC2253String(false)); } catch (RFC2253NameParserException e) { - logger_.error(e); + logger_.error(e.getMessage(), e); } } @@ -1245,7 +1244,7 @@ public class SignatureObject implements Serializable this.setSignationIssuer(cert.getIssuerName()); } } catch (IOException e) { - e.printStackTrace(); + logger_.error(e.getMessage(), e); return; } diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureResponse.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureResponse.java index deedb6d..6a5c95a 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureResponse.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureResponse.java @@ -136,7 +136,7 @@ public class SignatureResponse } catch (SignatureException e) { - logger_.warn(e.getMessage()); + logger_.warn(e.getMessage(), e); } } diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureTypes.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureTypes.java index 13fdf2f..3dd6f67 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureTypes.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureTypes.java @@ -388,11 +388,7 @@ public class SignatureTypes } catch (SignatureException e) { - if (logger_.isDebugEnabled()) - { - logger_.debug(e.getMessage()); - } - e.printStackTrace(); + logger_.error(e.getMessage(), e); } } } 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 148ac41..8aaa49a 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 @@ -157,12 +157,12 @@ public class X509Cert implements Serializable catch (java.security.cert.CertificateException ce) { // nothing to do, cause certString is not X509 conformc - ce.printStackTrace(); + logger_.error(ce.getMessage(), ce); } catch (IOException ioe) { // nothing to do, cause certString is not X509 conform - ioe.printStackTrace(); + logger_.error(ioe.getMessage(), ioe); } return x509_cert; } @@ -217,12 +217,13 @@ public class X509Cert implements Serializable catch (java.security.cert.CertificateException ce) { // nothing to do, cause certString is not X509 conformc - ce.printStackTrace(); + logger_.error(ce.getMessage(), ce); + } catch (IOException ioe) { // nothing to do, cause certString is not X509 conform - ioe.printStackTrace(); + logger_.error(ioe.getMessage(), ioe); } return x509_cert; @@ -453,7 +454,7 @@ public class X509Cert implements Serializable } catch (CertificateParsingException e) { - e.printStackTrace(); + logger_.error(e.getMessage(), e); } return null; } diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/MOAConnector.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/MOAConnector.java index 5e1aeed..5ec7f20 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/MOAConnector.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/MOAConnector.java @@ -214,10 +214,6 @@ public class MOAConnector implements Connector } catch (WebException we) { - if (logger_.isDebugEnabled()) - { - we.printStackTrace(); - } SignatureException se = new SignatureException(we.getErrorCode(), we); throw se; } diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/sigid/DetachedIdFormatter.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/sigid/DetachedIdFormatter.java index 7e67d0d..1b24a98 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/sigid/DetachedIdFormatter.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/sigid/DetachedIdFormatter.java @@ -40,7 +40,7 @@ public class DetachedIdFormatter implements IdFormatter try { SIG_ID_PREFIX = SettingsReader.getInstance().getValueFromKey(SIG_ID_PROPERTY_KEY); } catch (SettingsException e) { - e.printStackTrace(); + log.error(e.getMessage(), e); } // ids algorithm: diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/sigid/DetachedLocRefMOAIdFormatter.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/sigid/DetachedLocRefMOAIdFormatter.java index 89f9503..14fb41e 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/sigid/DetachedLocRefMOAIdFormatter.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/sigid/DetachedLocRefMOAIdFormatter.java @@ -44,7 +44,7 @@ public class DetachedLocRefMOAIdFormatter implements IdFormatter SIG_ID_PREFIX = SettingsReader.getInstance().getValueFromKey(SIG_ID_PROPERTY_KEY); } catch (SettingsException e) { - e.printStackTrace(); + logger_.error(e.getMessage(), e); } diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/sigkz/SigKZIDHelper.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/sigkz/SigKZIDHelper.java index f2ec571..5206ed1 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/sigkz/SigKZIDHelper.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/sigkz/SigKZIDHelper.java @@ -3,6 +3,9 @@ */ package at.knowcenter.wag.egov.egiz.sig.sigkz; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import at.knowcenter.wag.egov.egiz.PdfASID; import at.knowcenter.wag.egov.egiz.exceptions.ConnectorException; import at.knowcenter.wag.egov.egiz.exceptions.InvalidIDException; @@ -18,6 +21,11 @@ import at.knowcenter.wag.egov.egiz.sig.sigid.HotfixIdFormatter; public final class SigKZIDHelper { + /** + * The Logger. + */ + protected static Log logger = LogFactory.getLog(SigKZIDHelper.class); + public static boolean isTextual(PdfASID sig_kz) { if (sig_kz == null) @@ -73,7 +81,7 @@ public final class SigKZIDHelper } catch (InvalidIDException e) { - e.printStackTrace(); + logger.error(e.getMessage(), e); } } @@ -124,7 +132,7 @@ public final class SigKZIDHelper } catch (InvalidIDException e) { - e.printStackTrace(); + logger.error(e.getMessage(), e); } } diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/tools/DebugHelper.java b/src/main/java/at/knowcenter/wag/egov/egiz/tools/DebugHelper.java index e273437..8ff5faf 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/tools/DebugHelper.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/tools/DebugHelper.java @@ -64,7 +64,7 @@ public final class DebugHelper } catch (Exception e) { - log.error(e); + log.error(e.getMessage(), e); } } } diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/tools/Normalizer.java b/src/main/java/at/knowcenter/wag/egov/egiz/tools/Normalizer.java index 397f910..3dafb31 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/tools/Normalizer.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/tools/Normalizer.java @@ -139,7 +139,7 @@ public class Normalizer implements Serializable { if (logger_.isEnabledFor(Level.FATAL)) { logger_.fatal("Class not found:" + class_name); } - throw new NormalizeException("Can not load normalizer library"); + throw new NormalizeException("Can not load normalizer library", e); } try { normalize_ = (Normalize) normalize_class.newInstance(); @@ -147,12 +147,12 @@ public class Normalizer implements Serializable { if (logger_.isEnabledFor(Level.FATAL)) { logger_.fatal("Can not instantiate:" + class_name); } - throw new NormalizeException("Can not load normalizer library"); + throw new NormalizeException("Can not load normalizer library", e); } catch (IllegalAccessException e) { if (logger_.isEnabledFor(Level.FATAL)) { logger_.fatal("Can not access:" + class_name); } - throw new NormalizeException("Can not load normalizer library"); + throw new NormalizeException("Can not load normalizer library", e); } } @@ -264,7 +264,7 @@ public class Normalizer implements Serializable { settings_ = SettingsReader.getInstance(); } catch (SettingsException e) { String log_message = "Can not load normalizer settings. Cause:\n" + e.getMessage(); - logger_.error(log_message); + logger_.error(log_message, e); throw new NormalizeException(log_message, e); } } diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/web/LocalRequestHelper.java b/src/main/java/at/knowcenter/wag/egov/egiz/web/LocalRequestHelper.java index 2f02944..15792b9 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/web/LocalRequestHelper.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/web/LocalRequestHelper.java @@ -26,8 +26,9 @@ import java.util.Properties; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import at.gv.egiz.pdfas.impl.input.TextDataSourceImpl; -import at.gv.egiz.pdfas.framework.input.DataSource; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import at.gv.egiz.pdfas.web.CurrentLocalOperation; import at.gv.egiz.pdfas.web.SignSessionInformation; import at.gv.egiz.pdfas.web.VerifySessionInformation; @@ -39,10 +40,8 @@ import at.knowcenter.wag.egov.egiz.exceptions.NormalizeException; import at.knowcenter.wag.egov.egiz.exceptions.PresentableException; import at.knowcenter.wag.egov.egiz.exceptions.SettingsException; import at.knowcenter.wag.egov.egiz.exceptions.SignatureException; -import at.knowcenter.wag.egov.egiz.pdf.BinarySignatureHolder; import at.knowcenter.wag.egov.egiz.pdf.SignatureHolder; import at.knowcenter.wag.egov.egiz.sig.SignatureData; -import at.knowcenter.wag.egov.egiz.sig.SignatureDataImpl; import at.knowcenter.wag.egov.egiz.sig.SignatureObject; import at.knowcenter.wag.egov.egiz.sig.connectors.ConnectorChooser; import at.knowcenter.wag.egov.egiz.sig.connectors.LocalConnector; @@ -56,6 +55,12 @@ import at.knowcenter.wag.egov.egiz.sig.signatureobject.SignatureObjectHelper; */ public abstract class LocalRequestHelper { + + /** + * The logger. + */ + protected static Log logger = LogFactory.getLog(LocalRequestHelper.class); + /** * The resource of the null request page jsp. */ @@ -426,7 +431,7 @@ public abstract class LocalRequestHelper } catch (MalformedURLException e) { - e.printStackTrace(); + logger.error(e.getMessage(), e); } String loc_server = response.encodeURL(local_server.toString()); diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/web/PdfASServletContextListener.java b/src/main/java/at/knowcenter/wag/egov/egiz/web/PdfASServletContextListener.java index 95cb041..cdd3df1 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/web/PdfASServletContextListener.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/web/PdfASServletContextListener.java @@ -98,7 +98,7 @@ public class PdfASServletContextListener implements ServletContextListener try { SettingsReader.getInstance(); } catch (SettingsException e) { - logger.error(e); + logger.error(e.getMessage(), e); } SettingsReader.clearTemporaryDirectory(); diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/DataURLServlet.java b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/DataURLServlet.java index cbb33ba..19a82c3 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/DataURLServlet.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/DataURLServlet.java @@ -133,7 +133,7 @@ public class DataURLServlet extends HttpServlet } catch (PresentableException e) { - log.error(e); + log.error(e.getMessage(), e); SignServlet.prepareDispatchToErrorPage(e, request); dispatch(request, response, "/jsp/error.jsp"); } @@ -147,9 +147,9 @@ public class DataURLServlet extends HttpServlet // if (request.getCharacterEncoding() == null || request.getCharacterEncoding().equals("UTF-8")) //$NON-NLS-1$ if (request.getCharacterEncoding() == null || request.getCharacterEncoding().length() <= 0) //$NON-NLS-1$ { - log.error("The BKU didn't set a character encoding for the request."); //$NON-NLS-1$ + log.info("The BKU didn't set a character encoding for the request."); //$NON-NLS-1$ - log.warn("Manually setting character encoding to UTF-8"); //$NON-NLS-1$ + log.info("Manually setting character encoding to UTF-8"); //$NON-NLS-1$ request.setCharacterEncoding("UTF-8"); //$NON-NLS-1$ } } diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/ProvidePDFServlet.java b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/ProvidePDFServlet.java index 03bd074..a8ff426 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/ProvidePDFServlet.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/ProvidePDFServlet.java @@ -88,7 +88,7 @@ public class ProvidePDFServlet extends HttpServlet { response.getOutputStream().flush(); signedDocuments.remove(current); } catch (IOException e) { - log.warn("IO excepton while providing pdf document: " + e.getMessage()); + log.error("IO excepton while providing pdf document: " + e.getMessage(), e); } } } diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/RetrieveSignatureDataServlet.java b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/RetrieveSignatureDataServlet.java index 61996da..1b32db8 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/RetrieveSignatureDataServlet.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/RetrieveSignatureDataServlet.java @@ -86,7 +86,7 @@ public class RetrieveSignatureDataServlet extends HttpServlet } catch (SessionExpiredException e) { - log.error(e); + log.error(e.getMessage(), e); SignServlet.prepareDispatchToErrorPage(e, request); dispatch(request, response, "/jsp/error.jsp"); } diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/SignPreviewServlet.java b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/SignPreviewServlet.java index aec4f25..fa6b734 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/SignPreviewServlet.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/SignPreviewServlet.java @@ -25,6 +25,9 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import at.gv.egiz.pdfas.web.SignSessionInformation; import at.gv.egiz.pdfas.web.helper.SessionHelper; import at.gv.egiz.pdfas.web.helper.SignServletHelper; @@ -36,6 +39,8 @@ import at.knowcenter.wag.egov.egiz.exceptions.PresentableException; public class SignPreviewServlet extends HttpServlet { + protected static Log logger = LogFactory.getLog(SignPreviewServlet.class); + /** * SVUID. */ @@ -63,7 +68,8 @@ public class SignPreviewServlet extends HttpServlet } catch (PresentableException e) { - e.printStackTrace(); + logger.error(e.getMessage(), e); + SignServlet.prepareDispatchToErrorPage(e, request); dispatch(request, response, "/jsp/error.jsp"); } diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/SignServlet.java b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/SignServlet.java index 9b340e6..6330f0c 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/SignServlet.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/SignServlet.java @@ -34,15 +34,6 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import at.gv.egiz.pdfas.exceptions.ErrorCode; -import at.gv.egiz.pdfas.exceptions.ErrorCodeHelper; -import at.gv.egiz.pdfas.exceptions.external.ExternalErrorException; -import at.gv.egiz.pdfas.framework.input.PdfDataSource; -import at.gv.egiz.pdfas.impl.input.FileBasedPdfDataSourceImpl; -import at.gv.egiz.pdfas.web.SignSessionInformation; -import at.gv.egiz.pdfas.web.helper.SignServletHelper; -import at.gv.egiz.pdfas.web.helper.TempDirHelper; - import org.apache.commons.fileupload.FileItem; import org.apache.commons.fileupload.FileUploadException; import org.apache.commons.fileupload.disk.DiskFileItemFactory; @@ -50,6 +41,13 @@ import org.apache.commons.fileupload.servlet.ServletFileUpload; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import at.gv.egiz.pdfas.exceptions.ErrorCode; +import at.gv.egiz.pdfas.exceptions.ErrorCodeHelper; +import at.gv.egiz.pdfas.exceptions.external.ExternalErrorException; +import at.gv.egiz.pdfas.framework.input.PdfDataSource; +import at.gv.egiz.pdfas.web.SignSessionInformation; +import at.gv.egiz.pdfas.web.helper.SignServletHelper; +import at.gv.egiz.pdfas.web.helper.TempDirHelper; import at.knowcenter.wag.egov.egiz.PdfAS; import at.knowcenter.wag.egov.egiz.cfg.SettingsReader; import at.knowcenter.wag.egov.egiz.exceptions.PDFDocumentException; @@ -197,7 +195,7 @@ public class SignServlet extends HttpServlet } catch (PDFDocumentException e) { - log.warn("Unable to create signature position object: " + e.getMessage()); + log.warn("Unable to create signature position object: " + e.getMessage(), e); } } else { log.debug("No signature position provided."); @@ -308,7 +306,7 @@ public class SignServlet extends HttpServlet } catch (PresentableException e) { - e.printStackTrace(); + log.error(e.getMessage(), e); prepareDispatchToErrorPage(e, request); dispatch(request, response, "/jsp/error.jsp"); } diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyPreviewServlet.java b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyPreviewServlet.java index 9a91567..9b8583d 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyPreviewServlet.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyPreviewServlet.java @@ -582,7 +582,7 @@ public class VerifyPreviewServlet extends HttpServlet } catch (PresentableException e) { - e.printStackTrace(); + logger_.error(e.getMessage(), e); SignServlet.prepareDispatchToErrorPage(e, request); dispatch(request, response, "/jsp/error.jsp"); } @@ -702,7 +702,7 @@ public class VerifyPreviewServlet extends HttpServlet } catch (PresentableException e) { - e.printStackTrace(); + logger_.error(e.getMessage(), e); SignServlet.prepareDispatchToErrorPage(e, request); dispatch(request, response, "/jsp/error.jsp"); } diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyServlet.java b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyServlet.java index 97a1e6f..387ae08 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyServlet.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyServlet.java @@ -175,7 +175,7 @@ public class VerifyServlet extends HttpServlet } catch (PresentableException e) { - e.printStackTrace(); + log.error(e.getMessage(), e); SignServlet.prepareDispatchToErrorPage(e, request); dispatch(request, response, "/jsp/error_verify.jsp"); } diff --git a/src/main/java/demo/APIDemo.java b/src/main/java/demo/APIDemo.java index d4ce5e7..c2a989e 100644 --- a/src/main/java/demo/APIDemo.java +++ b/src/main/java/demo/APIDemo.java @@ -11,6 +11,7 @@ import at.gv.egiz.pdfas.api.PdfAs; import at.gv.egiz.pdfas.api.analyze.AnalyzeParameters; import at.gv.egiz.pdfas.api.analyze.AnalyzeResult; import at.gv.egiz.pdfas.api.commons.Constants; +import at.gv.egiz.pdfas.api.commons.SignatureProfile; import at.gv.egiz.pdfas.api.exceptions.PdfAsException; import at.gv.egiz.pdfas.api.io.DataSource; import at.gv.egiz.pdfas.api.sign.SignParameters; @@ -22,28 +23,38 @@ import at.gv.egiz.pdfas.framework.config.SettingsHelper; import at.gv.egiz.pdfas.framework.vfilter.VerificationFilterParameters; import at.gv.egiz.pdfas.io.FileBasedDataSink; import at.gv.egiz.pdfas.io.FileBasedDataSource; +import at.knowcenter.wag.egov.egiz.sig.SignatureTypeDefinition; +import at.knowcenter.wag.egov.egiz.sig.SignatureTypes; +/** + * Performs signatures and verifications with the pdfas api. + * @author tknall + */ public final class APIDemo { - + /** * Disable instantiation. */ private APIDemo() { } - + /** * Verifies a pdf document. - * @param configuration The folder containing the pdf-as work directory (including the configuration). - * @param source The signed pdf document. - * @param verifyDevice The device used for verification - * (see {@link Constants#SIGNATURE_DEVICE_MOA} and {@link Constants#SIGNATURE_DEVICE_BKU}). - * @throws PdfAsException Thrown in case of an error. - * @throws IOException Thrown in case of an i/o error. + * + * @param pdfasAPI + * The instantiated api. + * @param source + * The signed pdf document. + * @param verifyDevice + * The device used for verification (see + * {@link Constants#SIGNATURE_DEVICE_MOA} and + * {@link Constants#SIGNATURE_DEVICE_BKU}). + * @throws PdfAsException + * Thrown in case of an error. + * @throws IOException + * Thrown in case of an i/o error. */ - public static void verify(File configuration, File source, String verifyDevice) throws PdfAsException, IOException { - - // instantiate api - PdfAs pdfasAPI = PdfAsFactory.createPdfAs(configuration); + public static void verify(PdfAs pdfasAPI, File source, String verifyDevice) throws PdfAsException, IOException { // set source DataSource dataSource = new FileBasedDataSource(source, "application/pdf"); @@ -51,7 +62,7 @@ public final class APIDemo { // evaluate settings VerificationFilterParameters parameters = SettingsHelper.readVerificationFilterParametersFromSettings(); String verifyMode = Constants.VERIFY_MODE_FULL_CONSERVATIVE; - + if (parameters.extractBinarySignaturesOnly()) { verifyMode = Constants.VERIFY_MODE_BINARY_ONLY; } else if (parameters.assumeOnlySignatureUpdateBlocks()) { @@ -59,12 +70,12 @@ public final class APIDemo { } else { verifyMode = Constants.VERIFY_MODE_FULL_CONSERVATIVE; } - + // configure analyze parameters AnalyzeParameters analyzeParameters = new AnalyzeParameters(); analyzeParameters.setDocument(dataSource); analyzeParameters.setVerifyMode(verifyMode); - + // analyze System.out.println("Analyzing..."); AnalyzeResult analyzeResult = pdfasAPI.analyze(analyzeParameters); @@ -76,7 +87,7 @@ public final class APIDemo { vaap.setReturnHashInputData(true); vaap.setSignatureDevice(verifyDevice); vaap.setVerificationTime(null); - + // invoke verification System.out.println("Verifying..."); List verifyResults = pdfasAPI.verify(vaap).getResults(); @@ -90,30 +101,39 @@ public final class APIDemo { Main.formatVerifyResult(result, out); } out.flush(); - out.close(); } - + /** * Signs a pdf document. - * @param configuration The folder containing the pdf-as work directory (including the configuration). - * @param source The unsigned pdf document. - * @param signatureDevice The device used for signature - * (see {@link Constants#SIGNATURE_DEVICE_MOA} and {@link Constants#SIGNATURE_DEVICE_BKU}). - * @throws PdfAsException Thrown in case of an error. - * @throws IOException Thrown in case of an i/o error. - * @param destination The signed pdf document. - * @param signatureMode The mode used for signature (see {@link Constants#SIGNATURE_TYPE_BINARY} - * resp. {@link Constants#SIGNATURE_TYPE_TEXTUAL} or {@link Constants#SIGNATURE_TYPE_DETACHEDTEXTUAL}). - * @param signatureProfile The profile used for signature. - * @param signaturePos The position of the signature (see {@link SignaturePositioning}) or {@code null}. + * + * @param pdfasAPI + * The instantiated api. + * @param source + * The unsigned pdf document. + * @param signatureDevice + * The device used for signature (see + * {@link Constants#SIGNATURE_DEVICE_MOA} and + * {@link Constants#SIGNATURE_DEVICE_BKU}). + * @throws PdfAsException + * Thrown in case of an error. + * @throws IOException + * Thrown in case of an i/o error. + * @param destination + * The signed pdf document. + * @param signatureMode + * The mode used for signature (see + * {@link Constants#SIGNATURE_TYPE_BINARY} resp. + * {@link Constants#SIGNATURE_TYPE_TEXTUAL} or + * {@link Constants#SIGNATURE_TYPE_DETACHEDTEXTUAL}). + * @param signatureProfile + * The profile used for signature. + * @param signaturePos + * The position of the signature (see {@link SignaturePositioning}) + * or {@code null}. */ - private static void sign(File configuration, File source, File destination, - String signatureMode, String signatureDevice, String signatureProfile, - SignaturePositioning signaturePos) throws PdfAsException, IOException { - - // instantiate api - PdfAs pdfasAPI = PdfAsFactory.createPdfAs(configuration); + private static void sign(PdfAs pdfasAPI, File source, File destination, String signatureMode, String signatureDevice, String signatureProfile, SignaturePositioning signaturePos) + throws PdfAsException, IOException { // set source DataSource dataSource = new FileBasedDataSource(source, "application/pdf"); @@ -130,40 +150,103 @@ public final class APIDemo { signParameters.setSignatureProfileId(signatureProfile); signParameters.setSignaturePositioning(signaturePos); - // sign + // sign System.out.println("Signing..."); pdfasAPI.sign(signParameters); - + System.out.println("Successfully signed."); + + } + + /** + * Signs a test document with each available profile. Note that minimal layout profiles lead + * to an error textual signing the document. + */ + public static void signWithAllProfilesDemo() { + File configdir = new File("./work"); + File unsignedFile = new File("./test-files/blindtext.pdf"); + + String signatureMode = Constants.SIGNATURE_TYPE_TEXTUAL; + String signatureDevice = Constants.SIGNATURE_DEVICE_MOA; + SignaturePositioning signaturePos = null; + + try { + + // instantiate api + PdfAs pdfasAPI = PdfAsFactory.createPdfAs(configdir); + // warning: This method is not specified via api. It is only used to determine textual + // capable profiles + SignatureTypes sig_types = SignatureTypes.getInstance(); + + // ok, defined via api + Iterator profiles = pdfasAPI.getProfileInformation().iterator(); + while (profiles.hasNext()) { + SignatureProfile profile = (SignatureProfile) profiles.next(); + + SignatureTypeDefinition std = sig_types.getSignatureTypeDefinition(profile.getProfileId()); + String currentSignatureMode; + if (std.isTextExtractable()) { + currentSignatureMode = signatureMode; + } else { + currentSignatureMode = Constants.SIGNATURE_TYPE_BINARY; + } + + File signedFile = new File("./test-files/blindtext_" + currentSignatureMode + "-signed_" + profile.getProfileId() + ".pdf"); + + sign(pdfasAPI, unsignedFile, signedFile, currentSignatureMode, signatureDevice, profile.getProfileId(), signaturePos); + verify(pdfasAPI, signedFile, signatureDevice); + } + + } catch (PdfAsException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } /** - * Start a demo that signs a document and performs a verification afterwards. - * @param args The parameter(s). + * Signs a test document with a single profile. */ - public static void main(String[] args) { - + public static void signWithSingleProfileDemo() { File configdir = new File("./work"); File unsignedFile = new File("./test-files/blindtext.pdf"); - File signedFile = new File("./test-files/blindtext_signed.pdf"); - - String signatureMode = Constants.SIGNATURE_TYPE_BINARY; - String signatureDevice = Constants.SIGNATURE_DEVICE_MOA; + + String signatureMode = Constants.SIGNATURE_TYPE_BINARY; + String signatureDevice = Constants.SIGNATURE_DEVICE_MOA; String signatureProfile = "SIGNATURBLOCK_DE"; SignaturePositioning signaturePos = null; - + + File signedFile = new File("./test-files/blindtext_" + signatureMode + "-signed_" + signatureProfile + ".pdf"); + try { + + // instantiate api + PdfAs pdfasAPI = PdfAsFactory.createPdfAs(configdir); - sign(configdir, unsignedFile, signedFile, signatureMode, signatureDevice, signatureProfile, signaturePos); - verify(configdir, signedFile, signatureDevice); + sign(pdfasAPI, unsignedFile, signedFile, signatureMode, signatureDevice, signatureProfile, signaturePos); + verify(pdfasAPI, signedFile, signatureDevice); } catch (PdfAsException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } - + } + + /** + * Starts a demo that signs a document and performs a verification + * afterwards. + * + * @param args + * The parameter(s). + */ + public static void main(String[] args) { + +// signWithSingleProfileDemo(); + signWithAllProfilesDemo(); + } } diff --git a/src/main/resources/DefaultConfiguration.zip b/src/main/resources/DefaultConfiguration.zip index b1cc550..1496121 100644 Binary files a/src/main/resources/DefaultConfiguration.zip and b/src/main/resources/DefaultConfiguration.zip differ diff --git a/src/site/changes.xml b/src/site/changes.xml index 07f4504..2e7210c 100644 --- a/src/site/changes.xml +++ b/src/site/changes.xml @@ -13,6 +13,23 @@ --> + + APIDemo updated. + (default) configuration updated regarding new configuration keys. + Many printStackTraces replaces with logger-messages. + Update concerting exclusion of minimal layout profiles for verification. + + Web-Application: New error code (251) introduced: Textual signature of files with no + extractable textual content (e.g. files that solely contain images) is prevented. + + + + + Configurable line break tolerance for binary signatures (line_break_tolerance). + The reserved space for a certificate withing the egiz dictionary can be configured (...phlength.certificate=xxxx). + imagescaletofit configuration parameter introduced. + + Detection of incremental updates updated. Bug fixed. There was an error concerning empty HashInputData parsing a MOA CreateXMLSignatureResponse. diff --git a/work/cfg/config.properties b/work/cfg/config.properties index e5b4528..0f54030 100644 --- a/work/cfg/config.properties +++ b/work/cfg/config.properties @@ -187,6 +187,14 @@ defaults.phlength.SIG_VALUE=90 defaults.phlength.SIG_ID=70 defaults.phlength.SIG_NAME=130 +# default reserved space for certificates within binary signatures +# per profile: sig_obj.PROFILE.phlength.certificate=xyz +defaults.phlength.certificate=10000 + +# default line break tolerance +# per profile: sig_obj.PROFILE.phlength.line_break_tolerance=xyz +defaults.phlength.line_break_tolerance=10 + #absolute positioning #sig_obj.PROFIL.pos=p:1;x:40.0;y:800.0;w:400.0 @@ -338,20 +346,24 @@ sig_obj.SIGNATURBLOCK_MINIMAL_DE.key.SIG_META=Pr sig_obj.SIGNATURBLOCK_MINIMAL_DE.value.SIG_META=Informationen zur Prüfung der elektronischen Signatur und des Ausdrucks finden Sie unter:\nhttps://www.buergerkarte.at/signature-verification sig_obj.SIGNATURBLOCK_MINIMAL_DE.value.SIG_LABEL=./images/signatur-logo_de.png -sig_obj.SIGNATURBLOCK_MINIMAL_DE.pos=w:350.0 +sig_obj.SIGNATURBLOCK_MINIMAL_DE.pos=w:230.0 #---------------------- MAIN TABLE ------------------------- -sig_obj.SIGNATURBLOCK_MINIMAL_DE.table.main.1=SIG_LABEL-i|SIG_META-v +sig_obj.SIGNATURBLOCK_MINIMAL_DE.table.main.1=SIG_LABEL-i +sig_obj.SIGNATURBLOCK_MINIMAL_DE.table.main.2=SIG_META-v -sig_obj.SIGNATURBLOCK_MINIMAL_DE.table.main.ColsWidth=1 4 +sig_obj.SIGNATURBLOCK_MINIMAL_DE.table.main.ColsWidth=1 sig_obj.SIGNATURBLOCK_MINIMAL_DE.table.main.Style.bgcolor=255 255 255 sig_obj.SIGNATURBLOCK_MINIMAL_DE.table.main.Style.padding=3 -sig_obj.SIGNATURBLOCK_MINIMAL_DE.table.main.Style.border=0.1 +sig_obj.SIGNATURBLOCK_MINIMAL_DE.table.main.Style.border=0 sig_obj.SIGNATURBLOCK_MINIMAL_DE.table.main.Style.halign=left sig_obj.SIGNATURBLOCK_MINIMAL_DE.table.main.Style.valign=middle sig_obj.SIGNATURBLOCK_MINIMAL_DE.table.main.Style.font=HELVETICA,9,NORMAL sig_obj.SIGNATURBLOCK_MINIMAL_DE.table.main.Style.valuefont=HELVETICA,9,NORMAL +# scaling of image (in pdf units) +sig_obj.SIGNATURBLOCK_MINIMAL_DE.table.main.Style.imagescaletofit=65.0;65.0 + ################################################################################################### # PROFIL: minimaler Signaturblock (Englisch) @@ -362,20 +374,24 @@ sig_obj.SIGNATURBLOCK_MINIMAL_EN.key.SIG_META=Verification sig_obj.SIGNATURBLOCK_MINIMAL_EN.value.SIG_META=Information about the verification of the electronic signature and of the printout can be found at:\nhttps://www.buergerkarte.at/signature-verification sig_obj.SIGNATURBLOCK_MINIMAL_EN.value.SIG_LABEL=./images/signatur-logo_en.png -sig_obj.SIGNATURBLOCK_MINIMAL_EN.pos=w:350.0 +sig_obj.SIGNATURBLOCK_MINIMAL_EN.pos=w:230.0 #---------------------- MAIN TABLE ------------------------- -sig_obj.SIGNATURBLOCK_MINIMAL_EN.table.main.1=SIG_LABEL-i|SIG_META-v +sig_obj.SIGNATURBLOCK_MINIMAL_EN.table.main.1=SIG_LABEL-i +sig_obj.SIGNATURBLOCK_MINIMAL_EN.table.main.2=SIG_META-v -sig_obj.SIGNATURBLOCK_MINIMAL_EN.table.main.ColsWidth=1 4 +sig_obj.SIGNATURBLOCK_MINIMAL_EN.table.main.ColsWidth=1 sig_obj.SIGNATURBLOCK_MINIMAL_EN.table.main.Style.bgcolor=255 255 255 sig_obj.SIGNATURBLOCK_MINIMAL_EN.table.main.Style.padding=3 -sig_obj.SIGNATURBLOCK_MINIMAL_EN.table.main.Style.border=0.1 +sig_obj.SIGNATURBLOCK_MINIMAL_EN.table.main.Style.border=0 sig_obj.SIGNATURBLOCK_MINIMAL_EN.table.main.Style.halign=left sig_obj.SIGNATURBLOCK_MINIMAL_EN.table.main.Style.valign=middle sig_obj.SIGNATURBLOCK_MINIMAL_EN.table.main.Style.font=HELVETICA,9,NORMAL sig_obj.SIGNATURBLOCK_MINIMAL_EN.table.main.Style.valuefont=HELVETICA,9,NORMAL +# scaling of image (in pdf units) +sig_obj.SIGNATURBLOCK_MINIMAL_EN.table.main.Style.imagescaletofit=65.0;65.0 + ################################################################################################### # PROFIL: Signaturblock (Englisch) diff --git a/work/cfg/help_text.properties b/work/cfg/help_text.properties index 4dcd300..b99ff77 100644 --- a/work/cfg/help_text.properties +++ b/work/cfg/help_text.properties @@ -33,6 +33,7 @@ error.code.228=Der angegebene Wert f error.code.229=Der angegebene Wert für die y-Position in der absoluten Position darf nicht kleiner gleich 0 sein. error.code.250=Das angegebene Dokument ist leer. +error.code.251=Das angegebene Dokument enthält keinen extrahierbaren Text. Falls sich der Inhalt ausschließlich aus Bildern zusammensetzt, wird die Verwendung einer binären Signatur empfohlen. #SignatureException error.code.300=Die Signatur kann nicht erstellt werden. -- cgit v1.2.3