diff options
Diffstat (limited to 'src/main')
13 files changed, 87 insertions, 23 deletions
diff --git a/src/main/java/at/gv/egiz/pdfas/web/i18n/LanguageDecoratorMapper.java b/src/main/java/at/gv/egiz/pdfas/web/i18n/LanguageDecoratorMapper.java index c610e42..42e6b03 100644 --- a/src/main/java/at/gv/egiz/pdfas/web/i18n/LanguageDecoratorMapper.java +++ b/src/main/java/at/gv/egiz/pdfas/web/i18n/LanguageDecoratorMapper.java @@ -60,7 +60,7 @@ public class LanguageDecoratorMapper extends AbstractDecoratorMapper { session.setAttribute(LocaleParamFilter.LOCALE_SESSION_KEY, locale);
}
} else {
- LOG.debug("Locale found: " + locale);
+ LOG.trace("Locale found: " + locale);
}
return locale;
@@ -83,7 +83,7 @@ public class LanguageDecoratorMapper extends AbstractDecoratorMapper { File decFile = new File(config.getServletContext().getRealPath(path));
- LOG.debug("Looking for decorator \"" + path + "\".");
+ LOG.trace("Looking for decorator \"" + path + "\".");
if (decFile.isFile()) {
result = new DefaultDecorator(d.getName(), path, null) {
public String getInitParameter(String paramName) {
@@ -93,13 +93,13 @@ public class LanguageDecoratorMapper extends AbstractDecoratorMapper { }
if (result != null) {
- LOG.debug("Decorator found (\"" + result.getName() + "\", \"" + getFirstNotNull(new Object[] { result.getURIPath(), result.getPage(), "<n/a>"}) + "\").");
+ LOG.trace("Decorator found (\"" + result.getName() + "\", \"" + getFirstNotNull(new Object[] { result.getURIPath(), result.getPage(), "<n/a>"}) + "\").");
return result;
} else {
LOG.trace("No decorator found. Delegating to super class.");
result = super.getDecorator(request, page);
if (result != null) {
- LOG.debug("Super class returned decorator (\"" + result.getName() + "\", \"" + getFirstNotNull(new Object[] { result.getURIPath(), result.getPage(), "<n/a>"}) + "\").");
+ LOG.trace("Super class returned decorator (\"" + result.getName() + "\", \"" + getFirstNotNull(new Object[] { result.getURIPath(), result.getPage(), "<n/a>"}) + "\").");
} else {
LOG.trace("Super class did not return a decorator.");
}
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 43f7f14..78e4eec 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java @@ -25,13 +25,10 @@ import java.util.Comparator; import java.util.Date;
import java.util.List;
import java.util.Vector;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import at.gv.egiz.pdfas.algorithmSuite.AlgorithmSuiteUtil;
import at.gv.egiz.pdfas.api.analyze.NonTextObjectInfo;
import at.gv.egiz.pdfas.api.timestamp.TimeStamper;
import at.gv.egiz.pdfas.commandline.CommandlineConnectorChooser;
@@ -102,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";
+ public static final String PDFAS_VERSION = "3.1-snapshot (20091221)";
/**
* The key of the strict mode setting.
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/AdobeSignatureHelper.java b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/AdobeSignatureHelper.java index 9a52a84..1ce0b6f 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/AdobeSignatureHelper.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/AdobeSignatureHelper.java @@ -6,6 +6,7 @@ import java.util.Iterator; import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
+import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import at.gv.egiz.pdfas.api.commons.Constants;
@@ -36,6 +37,8 @@ import com.lowagie.text.pdf.PdfString; */
public class AdobeSignatureHelper {
private static final String ADOBE_SIGN_FIELDNAME_KEY = "adobeSignFieldValue";
+
+ private static final String ADOBE_SIGN_REASONNAME_KEY = "adobeSignReasonValue";
private static final String ADOBE_SIG_ENABLED_KEY = "adobeSignEnabled";
@@ -112,6 +115,12 @@ public class AdobeSignatureHelper { // sig.setContact("contact is not visible");
// sig.setDate(new PdfDate());
+ String reason = getAdobeReasonName(so.getSignatureTypeDefinition().getType());
+ if (!StringUtils.isEmpty(reason)) {
+ sig.setReason(reason);
+ }
+
+
/* disabled in order to align adobe signature appearance for textual signatures with binary signatures
if (si != null) {
XMLGregorianCalendar c = DatatypeFactory.newInstance().newXMLGregorianCalendar(
@@ -155,7 +164,11 @@ public class AdobeSignatureHelper { }
private static String getAdobeFieldName(String sigProfile) {
- return getDefaultableConfigProperty(sigProfile, ADOBE_SIGN_FIELDNAME_KEY, "PDF-AS-Signatur");
+ return getDefaultableConfigProperty(sigProfile, ADOBE_SIGN_FIELDNAME_KEY, "PDF-AS Signatur");
+ }
+
+ private static String getAdobeReasonName(String sigProfile) {
+ return getDefaultableConfigProperty(sigProfile, ADOBE_SIGN_REASONNAME_KEY, null);
}
private static String getDefaultableConfigProperty(String sigProfile, String propName, String defaultValue) {
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/tools/CodingHelper.java b/src/main/java/at/knowcenter/wag/egov/egiz/tools/CodingHelper.java index ce46e68..8d05960 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/tools/CodingHelper.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/tools/CodingHelper.java @@ -218,6 +218,7 @@ public class CodingHelper }
catch (NoSuchAlgorithmException e)
{
+ e.printStackTrace();
return null;
}
}
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/web/FormFields.java b/src/main/java/at/knowcenter/wag/egov/egiz/web/FormFields.java index 7137741..d455179 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/web/FormFields.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/web/FormFields.java @@ -54,6 +54,9 @@ public abstract class FormFields public static final String FIELD_RAW_DOCUMENT_TEXT = "raw_document_text";
public static final String FIELD_SIGNATURE_TYPE = "sig_type";
+
+ // tknall: PDF/A-1b enabled
+ public static final String FIELD_PDFA_ENABLED = "pdfa_enabled";
public static final String FIELD_VERIFY_WHICH = "verify_which";
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 cdd3df1..32cfc1e 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 @@ -20,6 +20,7 @@ package at.knowcenter.wag.egov.egiz.web; import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
+import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import at.gv.egiz.pdfas.api.commons.Constants;
@@ -65,19 +66,19 @@ public class PdfASServletContextListener implements ServletContextListener String work_dir;
// search for system property
- if (sysPropWorkdir != null && sysPropWorkdir.length() > 0) {
+ if (!StringUtils.isEmpty(sysPropWorkdir)) {
work_dir = sysPropWorkdir;
logger.debug("Work-dir configuration via system property \"" + Constants.CONFIG_DIR_SYSTEM_PROPERTY + "\" = \"" + sysPropWorkdir + "\".");
// search for servlet parameter
- } else if (scWorkdir != null && scWorkdir.length() > 0){
+ } else if (!StringUtils.isEmpty(scWorkdir)){
work_dir = scWorkdir;
logger.debug("Work-dir configuration via servlet init parameter \"" + CONFIG_SERVLET_INIT_PARAMETER + "\" = \"" + scWorkdir + "\".");
// assume configuration to be located in webapp path
} else {
work_dir = sce.getServletContext().getRealPath("/");
- logger.debug("PDF-AS work-dir not explicitely given. Assuming configuration is located in webapp folder \"" + work_dir + "\".");
+ logger.info("PDF-AS work-dir not explicitely given. Assuming configuration is located in webapp folder \"" + work_dir + "\".");
}
logger.info("PDF-AS configuration location = \"" + work_dir + "\"");
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 792a3e1..f30f0fb 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 @@ -395,6 +395,10 @@ public class SignServlet extends HttpServlet download_fi = item;
continue;
}
+
+ if (FormFields.FIELD_PDFA_ENABLED.equals(item.getFieldName())) {
+ continue;
+ }
throw new ServletException("unrecognized POST data."); //$NON-NLS-1$
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/UpdateFormServlet.java b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/UpdateFormServlet.java index ba5d43e..2d21545 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/UpdateFormServlet.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/UpdateFormServlet.java @@ -18,20 +18,23 @@ public class UpdateFormServlet extends HttpServlet { public static final String UPLOADFORM_SIGNATURE_TYPE_KEY = "signupload.jsp:signatureType";
public static final String UPLOADFORM_SIGNATURE_MODE_KEY = "signupload.jsp:signatureMode";
public static final String UPLOADFORM_SIGNATURE_DEVICE_KEY = "signupload.jsp:signatureKey";
+ public static final String UPLOADFORM_PDFA_KEY = "signupload.jsp:pdfaKey";
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
this.doPost(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- String mode = request.getParameter(FormFields.FIELD_MODE);
+ String mode = request.getParameter(FormFields.FIELD_MODE);
String device = request.getParameter(FormFields.FIELD_CONNECTOR);
- String type = request.getParameter(FormFields.FIELD_SIGNATURE_TYPE);
+ String type = request.getParameter(FormFields.FIELD_SIGNATURE_TYPE);
+ String pdfa = request.getParameter(FormFields.FIELD_PDFA_ENABLED);
HttpSession session = request.getSession();
session.setAttribute(UPLOADFORM_SIGNATURE_DEVICE_KEY, device);
session.setAttribute(UPLOADFORM_SIGNATURE_MODE_KEY, mode);
session.setAttribute(UPLOADFORM_SIGNATURE_TYPE_KEY, type);
+ session.setAttribute(UPLOADFORM_PDFA_KEY, pdfa);
RequestDispatcher dispatcher = request.getRequestDispatcher("/jsp/signupload.jsp");
dispatcher.forward(request, response);
diff --git a/src/main/java/demo/ExtractNonTextualObjectsDemo.java b/src/main/java/demo/ExtractNonTextualObjectsDemo.java index d7c651f..60031f7 100644 --- a/src/main/java/demo/ExtractNonTextualObjectsDemo.java +++ b/src/main/java/demo/ExtractNonTextualObjectsDemo.java @@ -28,7 +28,7 @@ public class ExtractNonTextualObjectsDemo { public static void main(String[] args) {
if (args == null || args.length == 0) {
- System.err.println("Please provide path of file to be signed.");
+ System.err.println("Please provide path of file to be analyzed.");
System.exit(1);
}
diff --git a/src/main/resources/DefaultConfiguration.zip b/src/main/resources/DefaultConfiguration.zip Binary files differindex 1da1f47..3abe355 100644 --- a/src/main/resources/DefaultConfiguration.zip +++ b/src/main/resources/DefaultConfiguration.zip diff --git a/src/main/resources/at/gv/egiz/pdfas/web/i18n/language.properties b/src/main/resources/at/gv/egiz/pdfas/web/i18n/language.properties index b96e64c..3914cba 100644 --- a/src/main/resources/at/gv/egiz/pdfas/web/i18n/language.properties +++ b/src/main/resources/at/gv/egiz/pdfas/web/i18n/language.properties @@ -65,8 +65,10 @@ signupload.documentnotselected.preview = Please select a pdf document to be s signupload.file = PDF document
signupload.heading2 = Sign document
signupload.note = Textual signature mode is only practicable for simple documents without special structures (like tables, forms...) and graphics. Documents signed in textual mode can only be verified if the underlying certificate can be retrieved from a directory service.
+signupload.note.pdfa = Please note that using PDF/A-1b increases the size of the signed file since the font for the signature block has to be embedded.
signupload.note.prefix = Please note
signupload.noteonsigmark = The appearance of the signature mark depends on the signature type, signature mode, on the particular citizen card and on the given citizen card software.
+signupload.pdfa = use PDF/A-1b
signupload.selectfilenote = Please select the signature parameters and the pdf document to be signed with your citizen card.
signupload.signaturedevice = Signature device
signupload.signaturemode = Signature mode
diff --git a/src/main/resources/at/gv/egiz/pdfas/web/i18n/language_de.properties b/src/main/resources/at/gv/egiz/pdfas/web/i18n/language_de.properties index 5b7f309..f73ec7c 100644 --- a/src/main/resources/at/gv/egiz/pdfas/web/i18n/language_de.properties +++ b/src/main/resources/at/gv/egiz/pdfas/web/i18n/language_de.properties @@ -65,8 +65,10 @@ signupload.documentnotselected.preview = Bitte wählen Sie das zu signierende signupload.file = PDF Dokument
signupload.heading2 = Dokument Signatur erstellen
signupload.note = Der textuelle Signaturmodus ist nur für einfache Dokumente ohne Strukturierung (Tabellen, Formulare udgl.) und ohne Grafiken sinnvoll anwendbar. Textuell signierte Dokumente können nur dann geprüft werden, wenn das Zertifikat in einem Verzeichnisdienst verfügbar ist.
+signupload.note.pdfa = Bitte berücksichtigen Sie, dass die Verwendung von PDF/A-1b die Größe der signierten Datei erhöht, da die Schriftart des Signaturblocks eingebettet werden muss.
signupload.note.prefix = Bitte beachten Sie
signupload.noteonsigmark = Das Erscheinungsbild der Signaturmarke kann abhängig vom Signaturtyp, vom Signaturmodus, von der verwendeten Bürgerkarte, sowie von der verwendeten Bürgerkartenumgebung variieren.
+signupload.pdfa = PDF/A-1b verwenden
signupload.selectfilenote = Bitte wählen Sie die Signaturparameter sowie das zu signierende PDF Dokument. Dieses wird mit Ihrer Bürgerkarte signiert.
signupload.signaturedevice = Signaturgerät
signupload.signaturemode = Signaturmodus
diff --git a/src/main/webapp/jsp/signupload.jsp b/src/main/webapp/jsp/signupload.jsp index 526d2c1..010012b 100644 --- a/src/main/webapp/jsp/signupload.jsp +++ b/src/main/webapp/jsp/signupload.jsp @@ -3,6 +3,7 @@ <%@ page import="at.gv.egiz.pdfas.api.commons.Constants" %>
<%@ page import="at.gv.egiz.pdfas.web.i18n.LanguageDecoratorMapper"%>
<%@ page import="at.knowcenter.wag.egov.egiz.web.servlets.UpdateFormServlet"%>
+<%@ page import="org.apache.commons.lang.BooleanUtils"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
@@ -12,7 +13,13 @@ <head>
<%
boolean testMode = request.getContextPath().startsWith("/test-");
- boolean forceTextualForMocca = true;
+ boolean forceTextualForMocca = false;
+
+ final String SIGNATUREPROFILE_DE_nonPDFa = "SIGNATURBLOCK_DE";
+ final String SIGNATUREPROFILE_EN_nonPDFa = "SIGNATURBLOCK_EN";
+ final String SIGNATUREPROFILE_DE_PDFa = "SIGNATURBLOCK_DE_PDFA";
+ final String SIGNATUREPROFILE_EN_PDFa = "SIGNATURBLOCK_EN_PDFA";
+
%>
<title>
<%
@@ -31,8 +38,9 @@ var submitform = document.getElementById('submitform');
updateform.<%= FormFields.FIELD_SIGNATURE_TYPE %>.value = submitform.<%= FormFields.FIELD_SIGNATURE_TYPE %>.value;
- updateform.<%= FormFields.FIELD_MODE %>.value = submitform.<%= FormFields.FIELD_MODE %>.value;
- updateform.<%= FormFields.FIELD_CONNECTOR %>.value = submitform.<%= FormFields.FIELD_CONNECTOR %>.value;
+ updateform.<%= FormFields.FIELD_MODE %>.value = submitform.<%= FormFields.FIELD_MODE %>.value;
+ updateform.<%= FormFields.FIELD_CONNECTOR %>.value = submitform.<%= FormFields.FIELD_CONNECTOR %>.value;
+ updateform.<%= FormFields.FIELD_PDFA_ENABLED %>.value = (submitform.<%= FormFields.FIELD_PDFA_ENABLED %>.checked == true);
updateform.submit();
return(false);
}
@@ -73,6 +81,19 @@ mode = FormFields.VALUE_MODE_BINARY;
session.setAttribute(UpdateFormServlet.UPLOADFORM_SIGNATURE_MODE_KEY, mode);
}
+
+ // PDF/A-1b
+ boolean pdfa = BooleanUtils.toBoolean((String) session.getAttribute(UpdateFormServlet.UPLOADFORM_PDFA_KEY));
+ String TYPE_EN;
+ String TYPE_DE;
+ if (pdfa) {
+ TYPE_EN = SIGNATUREPROFILE_EN_PDFa;
+ TYPE_DE = SIGNATUREPROFILE_DE_PDFa;
+ } else {
+ TYPE_EN = SIGNATUREPROFILE_EN_nonPDFa;
+ TYPE_DE = SIGNATUREPROFILE_DE_nonPDFa;
+ }
+
// signature type
String type = (String) session.getAttribute(UpdateFormServlet.UPLOADFORM_SIGNATURE_TYPE_KEY);
if (type == null) {
@@ -80,9 +101,23 @@ if (locale == null) {
locale = request.getLocale();
}
- type = Locale.GERMAN.getLanguage().equals(locale.getLanguage()) ? "SIGNATURBLOCK_DE" : "SIGNATURBLOCK_EN";
- session.setAttribute(UpdateFormServlet.UPLOADFORM_SIGNATURE_TYPE_KEY, type);
+ type = Locale.GERMAN.getLanguage().equals(locale.getLanguage()) ? TYPE_DE : TYPE_EN;
+ } else {
+ if (pdfa) {
+ if (SIGNATUREPROFILE_DE_nonPDFa.equals(type)) {
+ type = SIGNATUREPROFILE_DE_PDFa;
+ } else if (SIGNATUREPROFILE_EN_nonPDFa.equals(type)) {
+ type = SIGNATUREPROFILE_EN_PDFa;
+ }
+ } else {
+ if (SIGNATUREPROFILE_DE_PDFa.equals(type)) {
+ type = SIGNATUREPROFILE_DE_nonPDFa;
+ } else if (SIGNATUREPROFILE_EN_PDFa.equals(type)) {
+ type = SIGNATUREPROFILE_EN_nonPDFa;
+ }
+ }
}
+ session.setAttribute(UpdateFormServlet.UPLOADFORM_SIGNATURE_TYPE_KEY, type);
%>
</head>
@@ -102,6 +137,7 @@ <input type="hidden" name="<%= FormFields.FIELD_SIGNATURE_TYPE %>" value=""/>
<input type="hidden" name="<%= FormFields.FIELD_MODE %>" value=""/>
<input type="hidden" name="<%= FormFields.FIELD_CONNECTOR %>" value=""/>
+ <input type="hidden" name="<%= FormFields.FIELD_PDFA_ENABLED%>" value=""/>
</form>
<form name="submitform" id="submitform"
enctype="multipart/form-data"
@@ -113,10 +149,12 @@ <td align="left" nowrap="nowrap"><label><fmt:message key="signupload.signaturetype"/>:</label></td>
<td align="left">
<select class="field" name="<%= FormFields.FIELD_SIGNATURE_TYPE %>" onchange="return updateForm();">
- <option value="SIGNATURBLOCK_DE" <%= "SIGNATURBLOCK_DE".equals(type) ? "selected=\"selected\"" : "" %>><fmt:message key="signupload.signaturetype.signaturblock.de"/></option>
- <option value="SIGNATURBLOCK_EN" <%= "SIGNATURBLOCK_EN".equals(type) ? "selected=\"selected\"" : "" %>><fmt:message key="signupload.signaturetype.signaturblock.en"/></option>
+ <option value="<%= TYPE_DE %>" <%= TYPE_DE.equals(type) ? "selected=\"selected\"" : "" %>><fmt:message key="signupload.signaturetype.signaturblock.de"/></option>
+ <option value="<%= TYPE_EN %>" <%= TYPE_EN.equals(type) ? "selected=\"selected\"" : "" %>><fmt:message key="signupload.signaturetype.signaturblock.en"/></option>
</select>
<!-- %= // FormFields.generateTypeSelectBox() % -->
+ <span style="padding-left: 20px; 1px solid black;"></span>
+ <input type="checkbox" name="<%= FormFields.FIELD_PDFA_ENABLED %>" value="true" <%= pdfa ? "checked=\"checked\"" : "" %> onclick="return updateForm();"/> <fmt:message key="signupload.pdfa"/>
</td>
</tr>
<tr>
@@ -150,7 +188,7 @@ <td align="left"><input size="50" type="file" id="fileupload" name="<%= FormFields.FIELD_UPLOAD %>" accept="application/pdf"/></td>
</tr>
</table>
- <div class="pdfasnote"><span class="pdfasemphasis"><fmt:message key="signupload.note.prefix"/>:</span> <fmt:message key="signupload.note"/></div>
+ <div class="pdfasnote"><span class="pdfasemphasis"><fmt:message key="signupload.note.prefix"/>:</span> <fmt:message key="signupload.note"/> <% if (pdfa) { %><fmt:message key="signupload.note.pdfa"/><% } %></div>
<input type="hidden" name="<%= FormFields.FIELD_DOWNLOAD %>" value="<%= FormFields.VALUE_DOWNLOAD_ATTACHMENT %>"/>
<input type="hidden" name="<%= FormFields.FIELD_PREVIEW %>" value="false" />
|