aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2010-03-16 12:07:29 +0000
committertknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2010-03-16 12:07:29 +0000
commit11b5950be66bcc9d6f0bb28d3fc9d211bc70f4d9 (patch)
tree5a48a33069a318e269245998ecf89b387f331f67
parentda4926845267ca8bedf34917bd3bfb94aeafa153 (diff)
downloadpdf-as-3-11b5950be66bcc9d6f0bb28d3fc9d211bc70f4d9.tar.gz
pdf-as-3-11b5950be66bcc9d6f0bb28d3fc9d211bc70f4d9.tar.bz2
pdf-as-3-11b5950be66bcc9d6f0bb28d3fc9d211bc70f4d9.zip
Catching OutOfMemory exceptions, returning appropriate error message/code
Binary signature: bug concerning indirect pdf objects fixed SignaturePositioning improved (Signature position can be declared by String which is parsed) Some more error codes (Out of memory, Invalid signature position) iText utility for creation of pdf files added ConfigUtils updated (destination of configuration to be extracted can now be chosen) PDFASUtils updated (more tools) WebApplication: Freetext pdf creation implemented WebApplication: XSS security updates git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@580 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
-rw-r--r--.project8
-rw-r--r--.settings/org.maven.ide.eclipse.prefs9
-rw-r--r--src/main/distribution/brz/pdf-as.bat2
-rw-r--r--src/main/distribution/cl/pdf-as.bat2
-rw-r--r--src/main/distribution/cl/pdf-as.sh2
-rw-r--r--src/main/java/at/gv/egiz/pdfas/api/sign/pos/SignaturePositioning.java80
-rw-r--r--src/main/java/at/gv/egiz/pdfas/exceptions/ErrorCode.java3
-rw-r--r--src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java124
-rw-r--r--src/main/java/at/gv/egiz/pdfas/impl/signator/binary/BinarySignator_1_0_0.java5
-rw-r--r--src/main/java/at/gv/egiz/pdfas/itext/IText.java111
-rw-r--r--src/main/java/at/gv/egiz/pdfas/test/CreateFreeTextTest.java26
-rw-r--r--src/main/java/at/gv/egiz/pdfas/utils/ConfigUtils.java55
-rw-r--r--src/main/java/at/gv/egiz/pdfas/utils/PDFASUtils.java30
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java2
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/exceptions/OutOfMemoryException.java19
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/pdf/BinarySignature.java4
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/pdf/TablePos.java12
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/web/FormFields.java10
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/ProvidePDFServlet.java2
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/SignServlet.java102
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/UpdateFormServlet.java24
-rw-r--r--src/main/java/demo/SignatureCreationDemo.java3
-rw-r--r--src/main/resources/DefaultConfiguration.zipbin635285 -> 635448 bytes
-rw-r--r--src/main/resources/at/gv/egiz/pdfas/itext/DejaVuSansCondensed.ttfbin0 -> 541104 bytes
-rw-r--r--src/main/resources/at/gv/egiz/pdfas/itext/srgb.profilebin0 -> 3144 bytes
-rw-r--r--src/main/resources/at/gv/egiz/pdfas/web/i18n/language.properties8
-rw-r--r--src/main/resources/at/gv/egiz/pdfas/web/i18n/language_de.properties70
-rw-r--r--src/main/resources/config/help_text.properties5
-rw-r--r--src/main/resources/config/templates/default.bku.verify.template.detached.xml14
-rw-r--r--src/main/resources/config/templates/default.bku.verify.template.enveloping.old.xml7
-rw-r--r--src/main/resources/config/templates/default.bku.verify.template.enveloping.xml7
-rw-r--r--src/main/resources/config/templates/default.moa.verify.template.enveloping.xml12
-rw-r--r--src/main/webapp/WEB-INF/decorators.xml5
-rw-r--r--src/main/webapp/WEB-INF/web.xml10
-rw-r--r--src/main/webapp/css/pdfas-styles.css7
-rw-r--r--src/main/webapp/jsp/SIGNATURBLOCK.jsp15
-rw-r--r--src/main/webapp/jsp/error.jsp7
-rw-r--r--src/main/webapp/jsp/signupload.jsp90
-rw-r--r--src/site/changes.xml16
-rw-r--r--work/cfg/config.properties41
40 files changed, 744 insertions, 205 deletions
diff --git a/.project b/.project
index 28557b9..6d8b2ed 100644
--- a/.project
+++ b/.project
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>PDF-AS</name>
+ <name>pdf-as</name>
<comment></comment>
<projects>
+ <project>pdfbox-pdfas</project>
+ <project>itext-pdfas</project>
</projects>
<buildSpec>
<buildCommand>
@@ -16,12 +18,12 @@
</arguments>
</buildCommand>
<buildCommand>
- <name>org.maven.ide.eclipse.maven2Builder</name>
+ <name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
- <name>org.eclipse.wst.validation.validationbuilder</name>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
diff --git a/.settings/org.maven.ide.eclipse.prefs b/.settings/org.maven.ide.eclipse.prefs
new file mode 100644
index 0000000..5f11ed7
--- /dev/null
+++ b/.settings/org.maven.ide.eclipse.prefs
@@ -0,0 +1,9 @@
+#Tue Dec 01 08:53:40 CET 2009
+activeProfiles=
+eclipse.preferences.version=1
+fullBuildGoals=process-test-resources
+includeModules=false
+resolveWorkspaceProjects=true
+resourceFilterGoals=process-resources resources\:testResources
+skipCompilerPlugin=true
+version=1
diff --git a/src/main/distribution/brz/pdf-as.bat b/src/main/distribution/brz/pdf-as.bat
index 88eb615..059b977 100644
--- a/src/main/distribution/brz/pdf-as.bat
+++ b/src/main/distribution/brz/pdf-as.bat
@@ -5,4 +5,4 @@ rem Note: Configuration is not deployed if it already exists.
rem java -Dpdf-as.work-dir=. -jar ${project.build.finalName}.jar -ddc
rem Start commandline
-java -Dpdf-as.work-dir=. -jar ${project.build.finalName}.jar %*
+java -Xms128m -Xmx786m -XX:MaxPermSize=256m -Dpdf-as.work-dir=. -jar ${project.build.finalName}.jar %*
diff --git a/src/main/distribution/cl/pdf-as.bat b/src/main/distribution/cl/pdf-as.bat
index c4753c5..0cadb9a 100644
--- a/src/main/distribution/cl/pdf-as.bat
+++ b/src/main/distribution/cl/pdf-as.bat
@@ -5,4 +5,4 @@ rem Note: Configuration is not deployed if it already exists.
java -jar ${project.build.finalName}.jar -ddc
rem Start commandline
-java -jar ${project.build.finalName}.jar %*
+java -Xms128m -Xmx786m -XX:MaxPermSize=256m -jar ${project.build.finalName}.jar %*
diff --git a/src/main/distribution/cl/pdf-as.sh b/src/main/distribution/cl/pdf-as.sh
index 254b86a..f47bc5f 100644
--- a/src/main/distribution/cl/pdf-as.sh
+++ b/src/main/distribution/cl/pdf-as.sh
@@ -5,4 +5,4 @@
java -jar ${project.build.finalName}.jar -ddc
# Start commandline
-java -jar ${project.build.finalName}.jar $@
+java -Xms128m -Xmx786m -XX:MaxPermSize=256m -jar ${project.build.finalName}.jar $@
diff --git a/src/main/java/at/gv/egiz/pdfas/api/sign/pos/SignaturePositioning.java b/src/main/java/at/gv/egiz/pdfas/api/sign/pos/SignaturePositioning.java
index b9e2c8a..42b02eb 100644
--- a/src/main/java/at/gv/egiz/pdfas/api/sign/pos/SignaturePositioning.java
+++ b/src/main/java/at/gv/egiz/pdfas/api/sign/pos/SignaturePositioning.java
@@ -3,6 +3,8 @@
*/
package at.gv.egiz.pdfas.api.sign.pos;
+import java.util.StringTokenizer;
+
import at.gv.egiz.pdfas.api.sign.pos.axis.AbsoluteAxisAlgorithm;
import at.gv.egiz.pdfas.api.sign.pos.axis.AutoAxisAlgorithm;
import at.gv.egiz.pdfas.api.sign.pos.axis.AxisAlgorithm;
@@ -10,6 +12,8 @@ import at.gv.egiz.pdfas.api.sign.pos.page.AbsolutePageAlgorithm;
import at.gv.egiz.pdfas.api.sign.pos.page.AutoPageAlgorithm;
import at.gv.egiz.pdfas.api.sign.pos.page.NewPageAlgorithm;
import at.gv.egiz.pdfas.api.sign.pos.page.PageAlgorithm;
+import at.gv.egiz.pdfas.exceptions.ErrorCode;
+import at.knowcenter.wag.egov.egiz.exceptions.PDFDocumentException;
/**
* Defines how the signature positioning is to be performed.
@@ -186,4 +190,80 @@ public class SignaturePositioning
this.footerLine = footerLine;
}
+ public SignaturePositioning() {
+ }
+
+ public SignaturePositioning(String position) throws PDFDocumentException {
+ if (position != null) {
+ StringTokenizer tokenizer = new StringTokenizer(position, ";");
+ while (tokenizer.hasMoreTokens()) {
+ String token = tokenizer.nextToken().replaceAll(" ", "");
+ String[] sToken = token.split(":");
+ if (sToken == null || sToken.length != 2 || sToken[0].length() != 1) {
+ throw new PDFDocumentException(ErrorCode.INVALID_SIGNATURE_POSITION, "Invalid signature position element: " + token);
+ }
+ char cmd = sToken[0].toLowerCase().charAt(0);
+ String value = sToken[1];
+ switch (cmd) {
+ case 'x':
+ if ("auto".equalsIgnoreCase(value)) {
+ this.setXAlgorithm(new AutoAxisAlgorithm());
+ } else {
+ try {
+ this.setXAlgorithm(new AbsoluteAxisAlgorithm(Float.parseFloat(value)));
+ } catch (NumberFormatException e) {
+ throw new PDFDocumentException(ErrorCode.INVALID_SIGNATURE_POSITION, "Invalid signature position element: " + token);
+ }
+ }
+ break;
+ case 'y':
+ if ("auto".equalsIgnoreCase(value)) {
+ this.setYAlgorithm(new AutoAxisAlgorithm());
+ } else {
+ try {
+ this.setYAlgorithm(new AbsoluteAxisAlgorithm(Float.parseFloat(value)));
+ } catch (NumberFormatException e) {
+ throw new PDFDocumentException(ErrorCode.INVALID_SIGNATURE_POSITION, "Invalid signature position element: " + token);
+ }
+ }
+ break;
+ case 'w':
+ if ("auto".equalsIgnoreCase(value)) {
+ this.setWidthAlgorithm(new AutoAxisAlgorithm());
+ } else {
+ try {
+ this.setWidthAlgorithm(new AbsoluteAxisAlgorithm(Float.parseFloat(value)));
+ } catch (NumberFormatException e) {
+ throw new PDFDocumentException(ErrorCode.INVALID_SIGNATURE_POSITION, "Invalid signature position element: " + token);
+ }
+ }
+ break;
+ case 'p':
+ if ("auto".equalsIgnoreCase(value)) {
+ this.setPageAlgorithm(new AutoPageAlgorithm());
+ } else if ("new".equalsIgnoreCase(value)) {
+ this.setPageAlgorithm(new NewPageAlgorithm());
+ } else {
+ try {
+ this.setPageAlgorithm(new AbsolutePageAlgorithm(Integer.parseInt(value)));
+ } catch (NumberFormatException e) {
+ throw new PDFDocumentException(ErrorCode.INVALID_SIGNATURE_POSITION, "Invalid signature position element: " + token);
+ }
+ }
+ break;
+ case 'f':
+ try {
+ this.setFooterLine(Float.parseFloat(value));
+ } catch (NumberFormatException e) {
+ throw new PDFDocumentException(ErrorCode.INVALID_SIGNATURE_POSITION, "Invalid signature position element: " + token);
+ }
+ break;
+ default:
+ throw new PDFDocumentException(ErrorCode.INVALID_SIGNATURE_POSITION, "Invalid signature position element: " + token);
+ }
+ }
+ }
+ }
+
+
}
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 c53151f..9c2e440 100644
--- a/src/main/java/at/gv/egiz/pdfas/exceptions/ErrorCode.java
+++ b/src/main/java/at/gv/egiz/pdfas/exceptions/ErrorCode.java
@@ -16,6 +16,7 @@ public final class ErrorCode
{
public static final int EXTERNAL_ERROR = 0;
public static final int UNKNOWN_ERROR = 6;
+ public static final int OUT_OF_MEMORY_ERROR = 7;
public static final int SETTING_NOT_FOUND = 100;
public static final int SETTINGS_EXCEPTION = 101;
@@ -31,6 +32,8 @@ public final class ErrorCode
public static final int FONT_NOT_FOUND = 230;
public static final int DOCUMENT_IS_PROTECTED = 231;
+ public static final int INVALID_SIGNATURE_POSITION = 224;
+
public static final int SIGNATURE_COULDNT_BE_CREATED = 300;
public static final int SIGNED_TEXT_EMPTY = 301;
public static final int PROFILE_NOT_DEFINED = 302;
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 824416f..2ccc1b7 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
@@ -50,6 +50,7 @@ import at.gv.egiz.pdfas.utils.ConfigUtils;
import at.knowcenter.wag.egov.egiz.PdfAS;
import at.knowcenter.wag.egov.egiz.PdfASID;
import at.knowcenter.wag.egov.egiz.cfg.SettingsReader;
+import at.knowcenter.wag.egov.egiz.exceptions.OutOfMemoryException;
import at.knowcenter.wag.egov.egiz.exceptions.PDFDocumentException;
import at.knowcenter.wag.egov.egiz.exceptions.PresentableException;
import at.knowcenter.wag.egov.egiz.exceptions.SignatureException;
@@ -240,20 +241,24 @@ public class PdfAsObject implements PdfAs
TablePos pos = PosHelper.formTablePos(signParameters.getSignaturePositioning());
String connectorId = CommandlineConnectorChooser.chooseCommandlineConnectorForSign(signParameters.getSignatureDevice());
-
- SignatorInformation si = PdfAS.signCommandline(
- new PdfDataSourceAdapter(signParameters.getDocument()),
- new DataSinkAdapter(signParameters.getOutput()),
- signatorId,
- connectorId,
- signParameters.getSignatureProfileId(),
- signParameters.getSignatureKeyIdentifier(),
- pos,
- signParameters.getTimeStamperImpl()
- );
-
- return new SignResultImpl(signParameters.getOutput(), si.getSignSignatureObject().getX509Certificate(),
- new ActualSignaturePositionAdapter(si.getActualTablePos()), si.getNonTextualObjects());
+
+ try {
+ SignatorInformation si = PdfAS.signCommandline(
+ new PdfDataSourceAdapter(signParameters.getDocument()),
+ new DataSinkAdapter(signParameters.getOutput()),
+ signatorId,
+ connectorId,
+ signParameters.getSignatureProfileId(),
+ signParameters.getSignatureKeyIdentifier(),
+ pos,
+ signParameters.getTimeStamperImpl()
+ );
+ return new SignResultImpl(signParameters.getOutput(), si.getSignSignatureObject().getX509Certificate(),
+ new ActualSignaturePositionAdapter(si.getActualTablePos()), si.getNonTextualObjects());
+ } catch (java.lang.OutOfMemoryError e) {
+ throw new OutOfMemoryException(ErrorCode.OUT_OF_MEMORY_ERROR, "Insufficient memory allocated to virtual machine. Start Java with parameters \"-Xms128m -Xmx786m -XX:MaxPermSize=256m\".", e);
+ }
+
}
/**
@@ -364,31 +369,35 @@ public class PdfAsObject implements PdfAs
}
assert inputDataSource != null;
- ExtractionStage es = new ExtractionStage();
- List signature_holders = es.extractSignatureHolders(inputDataSource, parameters);
-
-// List sigInfs = new ArrayList(signature_holders.size());
- List sigInfs = new ArrayList();
- List noSigs = new ArrayList();
- Iterator it = signature_holders.iterator();
- while (it.hasNext())
- {
- SignatureHolder sh = (SignatureHolder)it.next();
-
- if(sh instanceof NoSignatureHolder) {
- noSigs.add(sh);
- } else {
-
- SignatureInformation si = new SignatureInformationAdapter(sh);
- sigInfs.add(si);
- if (analyzeParameters.isReturnNonTextualObjects()) {
- si.setNonTextualObjects(doExtractNonTexualObjects(sh, (PdfDataSource) inputDataSource));
- }
-
- }
+ try {
+ ExtractionStage es = new ExtractionStage();
+ List signature_holders = es.extractSignatureHolders(inputDataSource, parameters);
+
+ // List sigInfs = new ArrayList(signature_holders.size());
+ List sigInfs = new ArrayList();
+ List noSigs = new ArrayList();
+ Iterator it = signature_holders.iterator();
+ while (it.hasNext())
+ {
+ SignatureHolder sh = (SignatureHolder)it.next();
+
+ if(sh instanceof NoSignatureHolder) {
+ noSigs.add(sh);
+ } else {
+
+ SignatureInformation si = new SignatureInformationAdapter(sh);
+ sigInfs.add(si);
+ if (analyzeParameters.isReturnNonTextualObjects()) {
+ si.setNonTextualObjects(doExtractNonTexualObjects(sh, (PdfDataSource) inputDataSource));
+ }
+
+ }
+ }
+ return new AnalyzeResultImpl(sigInfs, noSigs);
+ } catch (java.lang.OutOfMemoryError e) {
+ throw new OutOfMemoryException(ErrorCode.OUT_OF_MEMORY_ERROR, "Insufficient memory allocated to virtual machine. Start Java with parameters \"-Xms128m -Xmx786m -XX:MaxPermSize=256m\".", e);
}
- return new AnalyzeResultImpl(sigInfs, noSigs);
}
private List doExtractNonTexualObjects(SignatureHolder sh, PdfDataSource pdfDataSource) {
@@ -433,25 +442,30 @@ public class PdfAsObject implements PdfAs
}
assert signature_holders.size() == signatures.size();
- List results = PdfAS.verifySignatureHolders(signature_holders, verifyAfterAnalysisParameters.getSignatureDevice(), verifyAfterAnalysisParameters.isReturnHashInputData(), verifyAfterAnalysisParameters.getVerificationTime());
-
- List vrs = new ArrayList(results.size());
-
- assert signature_holders.size() == results.size() : "Not all signatures were verified.";
-
- for (int i = 0; i < signature_holders.size(); i++)
- {
- SignatureResponse response = (SignatureResponse) results.get(i);
- SignatureHolder holder = (SignatureHolder) signature_holders.get(i);
-
- VerifyResult vr = new VerifyResultAdapter(response, holder, verifyAfterAnalysisParameters.getVerificationTime());
- vr.setNonTextualObjects( ((SignatureInformation) signatures.get(i)).getNonTextualObjects());
-
- vrs.add(vr);
+ try {
+ List results = PdfAS.verifySignatureHolders(signature_holders, verifyAfterAnalysisParameters.getSignatureDevice(), verifyAfterAnalysisParameters.isReturnHashInputData(), verifyAfterAnalysisParameters.getVerificationTime());
+
+ List vrs = new ArrayList(results.size());
+
+ assert signature_holders.size() == results.size() : "Not all signatures were verified.";
+
+ for (int i = 0; i < signature_holders.size(); i++)
+ {
+ SignatureResponse response = (SignatureResponse) results.get(i);
+ SignatureHolder holder = (SignatureHolder) signature_holders.get(i);
+
+ VerifyResult vr = new VerifyResultAdapter(response, holder, verifyAfterAnalysisParameters.getVerificationTime());
+ vr.setNonTextualObjects( ((SignatureInformation) signatures.get(i)).getNonTextualObjects());
+
+ vrs.add(vr);
+ }
+
+ VerifyResultsImpl verifyResults = new VerifyResultsImpl(vrs);
+ return verifyResults;
+ } catch (java.lang.OutOfMemoryError e) {
+ throw new OutOfMemoryException(ErrorCode.OUT_OF_MEMORY_ERROR, "Insufficient memory allocated to virtual machine. Start Java with parameters \"-Xms128m -Xmx786m -XX:MaxPermSize=256m\".", e);
}
-
- VerifyResultsImpl verifyResults = new VerifyResultsImpl(vrs);
- return verifyResults;
+
}
}
diff --git a/src/main/java/at/gv/egiz/pdfas/impl/signator/binary/BinarySignator_1_0_0.java b/src/main/java/at/gv/egiz/pdfas/impl/signator/binary/BinarySignator_1_0_0.java
index 36d3764..bdb5fdb 100644
--- a/src/main/java/at/gv/egiz/pdfas/impl/signator/binary/BinarySignator_1_0_0.java
+++ b/src/main/java/at/gv/egiz/pdfas/impl/signator/binary/BinarySignator_1_0_0.java
@@ -17,6 +17,7 @@
*/
package at.gv.egiz.pdfas.impl.signator.binary;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -26,6 +27,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -40,6 +42,7 @@ import at.gv.egiz.pdfas.framework.signator.SignatorInformation;
import at.gv.egiz.pdfas.impl.input.CompoundPdfDataSourceImpl;
import at.gv.egiz.pdfas.impl.signator.IncrementalUpdateHelper;
import at.gv.egiz.pdfas.utils.OgnlUtil;
+import at.gv.egiz.pdfas.utils.PDFASUtils;
import at.knowcenter.wag.egov.egiz.PdfAS;
import at.knowcenter.wag.egov.egiz.PdfASID;
import at.knowcenter.wag.egov.egiz.cfg.SettingsReader;
@@ -199,7 +202,7 @@ public class BinarySignator_1_0_0 implements Signator
iui.invisibleKZString = invKZString;
String temp_string = iui.temp_ir_number + " " + iui.temp_ir_generation + " obj"; //$NON-NLS-1$//$NON-NLS-2$
- byte[] temp_bytes = temp_string.getBytes("US-ASCII"); //$NON-NLS-1$
+ byte[] temp_bytes = ArrayUtils.add(temp_string.getBytes("US-ASCII"), 0, (byte) 0x0A);
int temp_start = ByteArrayUtils.lastIndexOf(iui.signed_pdf, temp_bytes);
byte[] stream_bytes = new byte[] { '>', '>', 's', 't', 'r', 'e', 'a', 'm', 0x0A };
int stream_start = ByteArrayUtils.indexOf(iui.signed_pdf, temp_start, stream_bytes);
diff --git a/src/main/java/at/gv/egiz/pdfas/itext/IText.java b/src/main/java/at/gv/egiz/pdfas/itext/IText.java
new file mode 100644
index 0000000..767dbbc
--- /dev/null
+++ b/src/main/java/at/gv/egiz/pdfas/itext/IText.java
@@ -0,0 +1,111 @@
+package at.gv.egiz.pdfas.itext;
+
+import java.awt.color.ICC_Profile;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.output.ByteArrayOutputStream;
+import org.apache.log4j.Logger;
+
+import com.lowagie.text.Document;
+import com.lowagie.text.DocumentException;
+import com.lowagie.text.Font;
+import com.lowagie.text.PageSize;
+import com.lowagie.text.Paragraph;
+import com.lowagie.text.Rectangle;
+import com.lowagie.text.pdf.BaseFont;
+import com.lowagie.text.pdf.PdfArray;
+import com.lowagie.text.pdf.PdfDictionary;
+import com.lowagie.text.pdf.PdfICCBased;
+import com.lowagie.text.pdf.PdfName;
+import com.lowagie.text.pdf.PdfString;
+import com.lowagie.text.pdf.PdfWriter;
+
+public final class IText {
+
+ private IText() {
+ }
+
+ private static final Logger LOG = Logger.getLogger(IText.class);
+
+ private static final Font DEFAULT_FONT = new Font(Font.HELVETICA, 12, Font.NORMAL);
+ private static final String DEFAULT_TTF_FONT_RESOURCE = "DejaVuSansCondensed.ttf";
+ private static final String DEFAULT_ICC_PROFILE_RESOURCE = "srgb.profile";
+ private static final Rectangle DEFAULT_PAGE_SIZE = PageSize.A4;
+ private static final int[] DEFAULT_MARGINS_MM = { 25, 25, 25, 25 }; // top, right, bottom, left
+ public static final String DEFAULT_FILENAME = "text";
+
+ private static Font DEFAULT_TTF_FONT;
+ private static PdfICCBased DEFAULT_ICC_COLOR_SPACE;
+
+ static {
+ try {
+ byte[] ttfFontData = IOUtils.toByteArray(IText.class.getResourceAsStream(DEFAULT_TTF_FONT_RESOURCE));
+ DEFAULT_TTF_FONT = new Font(BaseFont.createFont(DEFAULT_TTF_FONT_RESOURCE, BaseFont.WINANSI, true, true, ttfFontData, null));
+ } catch (Exception e) {
+ LOG.error(e);
+ DEFAULT_TTF_FONT = DEFAULT_FONT;
+ }
+ try {
+ byte[] iccData = IOUtils.toByteArray(IText.class.getResourceAsStream(DEFAULT_ICC_PROFILE_RESOURCE));
+ DEFAULT_ICC_COLOR_SPACE = new PdfICCBased(ICC_Profile.getInstance(iccData));
+ DEFAULT_ICC_COLOR_SPACE.remove(PdfName.ALTERNATE);
+ } catch (Exception e) {
+ LOG.error(e);
+ DEFAULT_ICC_COLOR_SPACE = null;
+ }
+ }
+
+ public static byte[] createPDF(String content, boolean pdfa) throws DocumentException, IOException {
+ ByteArrayOutputStream baOut = new ByteArrayOutputStream();
+ createPDF(content, pdfa, baOut);
+ return baOut.toByteArray();
+ }
+
+ public static byte[] createPDF(String content) throws DocumentException, IOException {
+ return createPDF(content, false);
+ }
+
+
+ private static void addContent(Document document, boolean pdfa, String content) throws DocumentException {
+ Paragraph p = new Paragraph(content, pdfa ? DEFAULT_TTF_FONT : DEFAULT_FONT);
+ document.add(p);
+ }
+ public static void createPDF(String content, OutputStream outputStream) throws DocumentException, IOException {
+ createPDF(content, false, outputStream);
+ }
+
+ public static void createPDF(String content, boolean pdfa, OutputStream outputStream) throws DocumentException, IOException {
+ final float factor = (float) 72 / (float) 25.4;
+ Document document = new Document(
+ DEFAULT_PAGE_SIZE,
+ (float) DEFAULT_MARGINS_MM[3] * factor, // left
+ (float) DEFAULT_MARGINS_MM[1] * factor, // right
+ (float) DEFAULT_MARGINS_MM[0] * factor, // top
+ (float) DEFAULT_MARGINS_MM[2] * factor // bottom
+ );
+
+ PdfWriter pdfWriter = PdfWriter.getInstance(document, outputStream);
+ if (pdfa) {
+ pdfWriter.setPDFXConformance(PdfWriter.PDFA1B);
+ }
+ document.open();
+ if (pdfa) {
+ PdfDictionary pdfOutputIntent = new PdfDictionary(PdfName.OUTPUTINTENT);
+ pdfOutputIntent.put(PdfName.OUTPUTCONDITIONIDENTIFIER, new PdfString("sRGB IEC61966-2.1"));
+ pdfOutputIntent.put(PdfName.INFO, new PdfString("sRGB IEC61966-2.1"));
+ pdfOutputIntent.put(PdfName.S, PdfName.GTS_PDFA1);
+ if (DEFAULT_ICC_COLOR_SPACE != null) {
+ pdfOutputIntent.put(PdfName.DESTOUTPUTPROFILE, pdfWriter.addToBody(DEFAULT_ICC_COLOR_SPACE).getIndirectReference());
+ }
+ pdfWriter.getExtraCatalog().put(PdfName.OUTPUTINTENTS, new PdfArray(pdfOutputIntent));
+ }
+ addContent(document, pdfa, content);
+ if (pdfa) {
+ pdfWriter.createXmpMetadata();
+ }
+ document.close();
+ }
+
+}
diff --git a/src/main/java/at/gv/egiz/pdfas/test/CreateFreeTextTest.java b/src/main/java/at/gv/egiz/pdfas/test/CreateFreeTextTest.java
new file mode 100644
index 0000000..7665f33
--- /dev/null
+++ b/src/main/java/at/gv/egiz/pdfas/test/CreateFreeTextTest.java
@@ -0,0 +1,26 @@
+package at.gv.egiz.pdfas.test;
+
+import java.io.File;
+
+import at.gv.egiz.pdfas.itext.IText;
+import at.gv.egiz.pdfas.utils.PDFASUtils;
+
+public class CreateFreeTextTest {
+
+ private CreateFreeTextTest() {
+ }
+
+ public static void main(String[] args) {
+
+ try {
+
+ byte[] pdf = IText.createPDF("Hello World", false);
+ PDFASUtils.toFile(pdf, new File("itext.pdf"));
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+}
diff --git a/src/main/java/at/gv/egiz/pdfas/utils/ConfigUtils.java b/src/main/java/at/gv/egiz/pdfas/utils/ConfigUtils.java
index 88e597b..1862f20 100644
--- a/src/main/java/at/gv/egiz/pdfas/utils/ConfigUtils.java
+++ b/src/main/java/at/gv/egiz/pdfas/utils/ConfigUtils.java
@@ -1,8 +1,6 @@
package at.gv.egiz.pdfas.utils;
-import java.io.BufferedOutputStream;
import java.io.File;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -81,11 +79,37 @@ public final class ConfigUtils {
if (in == null) {
throw new ConfigUtilsException("Unable to find default configuration resource \"" + Constants.DEFAULT_CONFIGURATION_ZIP_RESOURCE + "\".");
}
- ZipInputStream zis = new ZipInputStream(in);
+ return deployFromZIP(in, destination, overwriteExisting);
+ } catch (IOException e) {
+ throw new ConfigUtilsException(e);
+ }
+ }
+
+ /**
+ * Deploys the contents of a ZIP file to a certain location.
+ *
+ * @param inputStream The inputStream of a ZIP container.
+ * @param destination The destination folder.
+ * @param overwriteExisting If set <code>true</code> an already existing configuration is overwritten. If <code>false</code> nothing is being copied if the destination folder already exists.
+ * @return <code>true</code> if the configuration has been deployed, <code>false</code> if not.
+ * @throws ConfigUtilsException Thrown if there was an error during the deployment of the configuration.
+ */
+ public static boolean deployFromZIP(InputStream inputStream, String destination, boolean overwriteExisting) throws ConfigUtilsException {
+ try {
+ if (!overwriteExisting) {
+ if (configurationAlreadyExists(destination)) {
+ logger_.debug("There is at least one file or folder that would be overwritten at destination path \"" + destination + "\". Skipping extraction.");
+ return false;
+ }
+ }
+ if (inputStream == null) {
+ throw new ConfigUtilsException("Unable to deploy ZIP file. InputStream is null.");
+ }
+ ZipInputStream zis = new ZipInputStream(inputStream);
ZipEntry ze;
File destinationFolder = new File(destination);
destinationFolder.mkdirs();
- logger_.debug("Extracting default configuration to folder \"" + destinationFolder.getCanonicalPath() + "\".");
+ logger_.debug("Extracting ZIP contents to folder \"" + destinationFolder.getCanonicalPath() + "\".");
while ((ze = zis.getNextEntry()) != null) {
if (ze.isDirectory()) {
File newFolder = new File(destinationFolder, ze.getName());
@@ -94,7 +118,7 @@ public final class ConfigUtils {
} else {
File destFile = new File(destinationFolder, ze.getName());
logger_.trace("Extracting file \"" + destFile.getName() + "\".");
- toFile(zis, destFile);
+ PDFASUtils.toFile(zis, destFile);
}
zis.closeEntry();
}
@@ -104,7 +128,7 @@ public final class ConfigUtils {
throw new ConfigUtilsException(e);
}
}
-
+
private static boolean configurationAlreadyExists(String destination) throws ConfigUtilsException, IOException {
logger_.debug("Checking configuration \"" + destination + "\" already exists (resp. if there are any directories or files that would be overwritten).");
File destinationFolder = new File(destination);
@@ -196,25 +220,6 @@ public final class ConfigUtils {
return deployDefaultConfiguration(false);
}
- public static boolean toFile(InputStream inputStream, File file) throws IOException {
- boolean result = false;
- BufferedOutputStream bufferedOutputStream = null;
- try {
- bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(file));
- writeInputStreamToOutputStream(inputStream, bufferedOutputStream);
- } finally {
- if (bufferedOutputStream != null) {
- try {
- bufferedOutputStream.close();
- result = true;
- } catch (IOException e) {
- result = false;
- }
- }
- }
- return result;
- }
-
public static void writeInputStreamToOutputStream(InputStream inputStream, OutputStream outputStream) throws IOException {
final int bufferSize = 1024;
byte[] buffer = new byte[bufferSize];
diff --git a/src/main/java/at/gv/egiz/pdfas/utils/PDFASUtils.java b/src/main/java/at/gv/egiz/pdfas/utils/PDFASUtils.java
index b26cc9b..9841779 100644
--- a/src/main/java/at/gv/egiz/pdfas/utils/PDFASUtils.java
+++ b/src/main/java/at/gv/egiz/pdfas/utils/PDFASUtils.java
@@ -1,5 +1,12 @@
package at.gv.egiz.pdfas.utils;
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
import at.gv.egiz.pdfas.exceptions.ErrorCode;
import at.knowcenter.wag.egov.egiz.exceptions.PDFDocumentException;
@@ -26,5 +33,28 @@ public class PDFASUtils {
throw new PDFDocumentException(ErrorCode.DOCUMENT_IS_PROTECTED, "Document is protected.");
}
}
+
+ public static boolean toFile(byte[] data, File file) throws IOException {
+ return PDFASUtils.toFile(new ByteArrayInputStream(data), file);
+ }
+
+ public static boolean toFile(InputStream inputStream, File file) throws IOException {
+ boolean result = false;
+ BufferedOutputStream bufferedOutputStream = null;
+ try {
+ bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(file));
+ ConfigUtils.writeInputStreamToOutputStream(inputStream, bufferedOutputStream);
+ } finally {
+ if (bufferedOutputStream != null) {
+ try {
+ bufferedOutputStream.close();
+ result = true;
+ } catch (IOException e) {
+ result = false;
+ }
+ }
+ }
+ return result;
+ }
}
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 423c222..4b585fe 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java
@@ -100,7 +100,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 (20100118)";
+ public static final String PDFAS_VERSION = "3.1.1-snapshot (20100316)";
/**
* The key of the strict mode setting.
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/exceptions/OutOfMemoryException.java b/src/main/java/at/knowcenter/wag/egov/egiz/exceptions/OutOfMemoryException.java
new file mode 100644
index 0000000..1b75e36
--- /dev/null
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/exceptions/OutOfMemoryException.java
@@ -0,0 +1,19 @@
+package at.knowcenter.wag.egov.egiz.exceptions;
+
+public class OutOfMemoryException extends PresentableException {
+
+ private static final long serialVersionUID = 1L;
+
+ public OutOfMemoryException(int errorCode, String message, Throwable cause) {
+ super(errorCode, message, cause);
+ }
+
+ public OutOfMemoryException(int errorCode, String message) {
+ super(errorCode, message);
+ }
+
+ public OutOfMemoryException(int errorCode, Throwable cause) {
+ super(errorCode, cause);
+ }
+
+}
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 d1e227a..32871e8 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
@@ -18,6 +18,7 @@
package at.knowcenter.wag.egov.egiz.pdf;
import java.io.ByteArrayOutputStream;
+import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
@@ -32,6 +33,7 @@ import java.util.Iterator;
import java.util.List;
+import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -1213,7 +1215,7 @@ public abstract class BinarySignature
byte[] signed_pdf = iui.signed_pdf;
String str = iui.egiz_dict_ir_number + " " + iui.egiz_dict_ir_generation + " obj";
- byte[] obj_bytes = str.getBytes("US-ASCII");
+ byte[] obj_bytes = ArrayUtils.add(str.getBytes("US-ASCII"), 0, (byte) 0x0A);
int obj_index = ByteArrayUtils.lastIndexOf(signed_pdf, obj_bytes);
int obj_start = obj_index + obj_bytes.length;
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/TablePos.java b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/TablePos.java
index 317e7a4..b343bc6 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/TablePos.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/TablePos.java
@@ -18,6 +18,8 @@
package at.knowcenter.wag.egov.egiz.pdf;
import java.io.Serializable;
+
+import at.gv.egiz.pdfas.exceptions.ErrorCode;
import at.knowcenter.wag.egov.egiz.exceptions.PDFDocumentException;
/**
@@ -153,12 +155,12 @@ public class TablePos implements Serializable
String[] cmd_kv = cmd_kvstring.split(":");
if (cmd_kv.length != 2)
{
- throw new PDFDocumentException(224, "Pos string (=" + pos_string + ") is invalid.");
+ throw new PDFDocumentException(ErrorCode.INVALID_SIGNATURE_POSITION, "Pos string (=" + pos_string + ") is invalid.");
}
String cmdstr = cmd_kv[0];
if (cmdstr.length() != 1)
{
- throw new PDFDocumentException(224, "Pos string (=" + pos_string + ") is invalid.");
+ throw new PDFDocumentException(ErrorCode.INVALID_SIGNATURE_POSITION, "Pos string (=" + pos_string + ") is invalid.");
}
char command = cmdstr.charAt(0);
String commandval= cmd_kv[1];
@@ -227,13 +229,13 @@ public class TablePos implements Serializable
float flval=Float.parseFloat(commandval);
if (flval<0)
{
- throw new PDFDocumentException(224, "Pos string (=" + pos_string + ") is invalid.");
+ throw new PDFDocumentException(ErrorCode.INVALID_SIGNATURE_POSITION, "Pos string (=" + pos_string + ") is invalid.");
}
this.footer_line = flval;
break;
}
default : {
- throw new PDFDocumentException(224, "Pos string (=" + pos_string + ") is invalid.");
+ throw new PDFDocumentException(ErrorCode.INVALID_SIGNATURE_POSITION, "Pos string (=" + pos_string + ") is invalid.");
}
}
}
@@ -241,7 +243,7 @@ public class TablePos implements Serializable
}
catch (NumberFormatException e)
{
- throw new PDFDocumentException(224, "Pos string (=" + pos_string + ") cannot be parsed.");
+ throw new PDFDocumentException(ErrorCode.INVALID_SIGNATURE_POSITION, "Pos string (=" + pos_string + ") cannot be parsed.");
}
}
public String toString()
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 d455179..876413a 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
@@ -41,8 +41,6 @@ import at.knowcenter.wag.egov.egiz.sig.SignatureTypes;
*/
public abstract class FormFields
{
- public static final String PARAMETER_FREE_TEXT_ENTRY = "freetext";
-
public static final String FIELD_UPLOAD = "upload";
public static final String FIELD_CONNECTOR = "connector";
@@ -101,6 +99,14 @@ public abstract class FormFields
public static final String FIELD_SIGPOS_Y = "sig-pos-y";
public static final String FIELD_SIGPOS_P = "sig-pos-p";
+
+ public static final String FIELD_SOURCE = "source_filefreetext";
+
+ public static final String VALUE_SOURCE_FILE = "source-is-file";
+
+ public static final String VALUE_SOURCE_FREETEXT = "source-is-freetext";
+
+ public static final String FIELD_FREETEXT = "freetext";
// end add
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 803dc59..0efed03 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
@@ -60,6 +60,8 @@ public class ProvidePDFServlet extends HttpServlet {
session.removeAttribute(SessionAttributes.SIGNED_PDF_DOCUMENT);
log.debug("Returning signed pdf to browser.");
SignServletHelper.returnSignResponse(si, request, response);
+ log.debug("Removing free text (if any) from session.");
+ session.removeAttribute(UpdateFormServlet.UPLOADFORM_FREETEXT_KEY);
return;
}
} else {
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 c946225..69b237f 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
@@ -33,18 +33,26 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
+import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import com.lowagie.text.DocumentException;
+
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.ByteArrayPdfDataSourceImpl;
+import at.gv.egiz.pdfas.itext.IText;
+import at.gv.egiz.pdfas.utils.ConfigUtils;
+import at.gv.egiz.pdfas.utils.PDFASUtils;
import at.gv.egiz.pdfas.utils.WebUtils;
import at.gv.egiz.pdfas.web.SignSessionInformation;
import at.gv.egiz.pdfas.web.helper.SignServletHelper;
@@ -235,6 +243,7 @@ public class SignServlet extends HttpServlet
try
{
+
// tzefferer: modified
// UploadedData ud = retrieveUploadedDataFromRequest(request);
UploadedData ud_form = retrieveUploadedDataFromRequest(request);
@@ -244,9 +253,7 @@ public class SignServlet extends HttpServlet
}
catch (Exception e)
{
- // Error retrieving data
-// request.setAttribute("error", "Fehler beim Upload der Daten");
-// request.setAttribute("cause", "Beim Upload der Daten ist ein Fehler aufgetreten.");
+ log.error(e);
request.setAttribute("error", "signservlet.error");
request.setAttribute("cause", "signservlet.cause");
request.setAttribute("resourcebundle", Boolean.TRUE);
@@ -344,8 +351,11 @@ public class SignServlet extends HttpServlet
FileItem mode_fi = null;
FileItem file_upload_fi = null;
FileItem download_fi = null;
+ FileItem freeText = null;
+ FileItem pdfa = null;
Iterator it = items.iterator();
+ HttpSession session = request.getSession();
while (it.hasNext())
{
FileItem item = (FileItem) it.next();
@@ -374,18 +384,21 @@ public class SignServlet extends HttpServlet
if (item.getFieldName().equals(FormFields.FIELD_SIGNATURE_TYPE))
{
sig_type_fi = item;
+ session.setAttribute(UpdateFormServlet.UPLOADFORM_SIGNATURE_TYPE_KEY, sig_type_fi.getString("UTF-8"));
continue;
}
if (item.getFieldName().equals(FormFields.FIELD_CONNECTOR))
{
sig_app_fi = item;
+ session.setAttribute(UpdateFormServlet.UPLOADFORM_SIGNATURE_DEVICE_KEY, sig_app_fi.getString("UTF-8"));
continue;
}
if (item.getFieldName().equals(FormFields.FIELD_MODE))
{
mode_fi = item;
+ session.setAttribute(UpdateFormServlet.UPLOADFORM_SIGNATURE_MODE_KEY, mode_fi.getString("UTF-8"));
continue;
}
@@ -402,14 +415,30 @@ public class SignServlet extends HttpServlet
}
if (FormFields.FIELD_PDFA_ENABLED.equals(item.getFieldName())) {
+ pdfa = item;
+ session.setAttribute(UpdateFormServlet.UPLOADFORM_PDFA_KEY, pdfa.getString("UTF-8"));
+ continue;
+ }
+
+ if (FormFields.FIELD_FREETEXT.equals(item.getFieldName())) {
+ freeText = item;
+ String value = freeText.getString("UTF-8");
+ if (value != null) {
+ session.setAttribute(UpdateFormServlet.UPLOADFORM_FREETEXT_KEY, value);
+ }
+ continue;
+ }
+
+ if (FormFields.FIELD_SOURCE.equals(item.getFieldName())) {
+ session.setAttribute(UpdateFormServlet.UPLOADFORM_SOURCE_KEY, item.getString("UTF-8"));
continue;
}
- throw new ServletException("unrecognized POST data."); //$NON-NLS-1$
+ throw new ServletException("Unrecognized POST data."); //$NON-NLS-1$
}
- if (preview_fi == null || sig_type_fi == null || sig_app_fi == null || file_upload_fi == null || download_fi == null)
+ if (preview_fi == null || sig_type_fi == null || sig_app_fi == null || (file_upload_fi == null && freeText== null) || download_fi == null)
{
throw new ServletException("Insufficient data provided in request"); //$NON-NLS-1$
}
@@ -436,28 +465,47 @@ public class SignServlet extends HttpServlet
String sig_type = sig_type_fi.getString("UTF-8"); //$NON-NLS-1$
String sig_app = sig_app_fi.getString("UTF-8"); //$NON-NLS-1$
- String doc_file_name = TempDirHelper.extractFileNameSuffix(file_upload_fi.getName());
- log.debug("file content type =" + file_upload_fi.getContentType()); //$NON-NLS-1$
-
- String extension = VerifyServlet.extractExtension(doc_file_name);
- if (extension != null && !extension.equals("pdf")) //$NON-NLS-1$
- {
- throw new PDFDocumentException(201, "The provided file '" + doc_file_name + "' doesn't have the PDF extension (.pdf)."); //$NON-NLS-1$//$NON-NLS-2$
- }
-
- if (file_upload_fi.getSize() <= 0)
- {
- throw new PDFDocumentException(250, "The document is empty."); //$NON-NLS-1$
- }
-
- PdfDataSource pdfDataSource = null;
- try
- {
- pdfDataSource = TempDirHelper.placePdfIntoTempDir(file_upload_fi.getInputStream(), doc_file_name);
- }
- catch (IOException e)
- {
- throw new PDFDocumentException(201, "Couldn't store the file in the temp dir.", e);
+ PdfDataSource pdfDataSource;
+ String doc_file_name;
+ // distinguish between file and freetext
+ if (file_upload_fi != null) {
+ log.debug("Processing file.");
+ doc_file_name = TempDirHelper.extractFileNameSuffix(file_upload_fi.getName());
+ log.debug("file content type =" + file_upload_fi.getContentType()); //$NON-NLS-1$
+
+ String extension = VerifyServlet.extractExtension(doc_file_name);
+ if (extension != null && !extension.equals("pdf")) //$NON-NLS-1$
+ {
+ throw new PDFDocumentException(201, "The provided file '" + doc_file_name + "' doesn't have the PDF extension (.pdf)."); //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ if (file_upload_fi.getSize() <= 0)
+ {
+ throw new PDFDocumentException(250, "The document is empty."); //$NON-NLS-1$
+ }
+
+ try
+ {
+ pdfDataSource = TempDirHelper.placePdfIntoTempDir(file_upload_fi.getInputStream(), doc_file_name);
+ }
+ catch (IOException e)
+ {
+ throw new PDFDocumentException(201, "Couldn't store the file in the temp dir.", e);
+ }
+ } else {
+ log.debug("Processing free text.");
+ try {
+ boolean pdfaEnabled = pdfa != null && "true".equalsIgnoreCase(pdfa.getString());
+ byte[] freeTextPDF = IText.createPDF(freeText.getString("UTF-8"), pdfaEnabled);
+
+ pdfDataSource = new ByteArrayPdfDataSourceImpl(freeTextPDF);
+ doc_file_name = IText.DEFAULT_FILENAME;
+ } catch (DocumentException e) {
+ throw new PDFDocumentException(201, "Unable to create PDF document.", e);
+ } catch (IOException e) {
+ throw new PDFDocumentException(201, "Unable to create PDF document.", e);
+ }
+
}
// byte[] pdf = file_upload_fi.get();
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 2d21545..f0d3d3d 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
@@ -19,22 +19,34 @@ public class UpdateFormServlet extends HttpServlet {
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";
+ public static final String UPLOADFORM_SOURCE_KEY = "signupload.jsp:sourceKey";
+ public static final String UPLOADFORM_FREETEXT_KEY = "signupload.jsp:freeTextKey";
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 device = request.getParameter(FormFields.FIELD_CONNECTOR);
- String type = request.getParameter(FormFields.FIELD_SIGNATURE_TYPE);
- String pdfa = request.getParameter(FormFields.FIELD_PDFA_ENABLED);
+
+ public static void updateSession(HttpServletRequest request) {
+ String mode = request.getParameter(FormFields.FIELD_MODE);
+ String device = request.getParameter(FormFields.FIELD_CONNECTOR);
+ String type = request.getParameter(FormFields.FIELD_SIGNATURE_TYPE);
+ String pdfa = request.getParameter(FormFields.FIELD_PDFA_ENABLED);
+ String source = request.getParameter(FormFields.FIELD_SOURCE);
+ String freeText = request.getParameter(FormFields.FIELD_FREETEXT);
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);
+ session.setAttribute(UPLOADFORM_SOURCE_KEY, source);
+ if (freeText != null) {
+ session.setAttribute(UPLOADFORM_FREETEXT_KEY, freeText);
+ }
+ }
+
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ updateSession(request);
RequestDispatcher dispatcher = request.getRequestDispatcher("/jsp/signupload.jsp");
dispatcher.forward(request, response);
diff --git a/src/main/java/demo/SignatureCreationDemo.java b/src/main/java/demo/SignatureCreationDemo.java
index 1f6205d..dd7e36b 100644
--- a/src/main/java/demo/SignatureCreationDemo.java
+++ b/src/main/java/demo/SignatureCreationDemo.java
@@ -12,6 +12,7 @@ import at.gv.egiz.pdfas.api.exceptions.PdfAsException;
import at.gv.egiz.pdfas.api.io.DataSource;
import at.gv.egiz.pdfas.api.sign.SignParameters;
import at.gv.egiz.pdfas.api.sign.SignResult;
+import at.gv.egiz.pdfas.api.sign.pos.SignaturePositioning;
import at.gv.egiz.pdfas.api.timestamp.DummyTimeStamper;
import at.gv.egiz.pdfas.io.FileBasedDataSink;
import at.gv.egiz.pdfas.io.FileBasedDataSource;
@@ -57,7 +58,7 @@ public class SignatureCreationDemo {
signParameters.setDocument(dataSource);
signParameters.setOutput(dataSink);
signParameters.setSignatureDevice(Constants.SIGNATURE_DEVICE_MOA);
- signParameters.setSignaturePositioning(null);
+ signParameters.setSignaturePositioning(new SignaturePositioning("x:auto;y:auto;w:auto;p:auto;f:80"));
// standard signature
signParameters.setSignatureType(Constants.SIGNATURE_TYPE_TEXTUAL);
signParameters.setSignatureProfileId("SIGNATURBLOCK_DE");
diff --git a/src/main/resources/DefaultConfiguration.zip b/src/main/resources/DefaultConfiguration.zip
index c248b9a..b9a0e77 100644
--- a/src/main/resources/DefaultConfiguration.zip
+++ b/src/main/resources/DefaultConfiguration.zip
Binary files differ
diff --git a/src/main/resources/at/gv/egiz/pdfas/itext/DejaVuSansCondensed.ttf b/src/main/resources/at/gv/egiz/pdfas/itext/DejaVuSansCondensed.ttf
new file mode 100644
index 0000000..988aa1b
--- /dev/null
+++ b/src/main/resources/at/gv/egiz/pdfas/itext/DejaVuSansCondensed.ttf
Binary files differ
diff --git a/src/main/resources/at/gv/egiz/pdfas/itext/srgb.profile b/src/main/resources/at/gv/egiz/pdfas/itext/srgb.profile
new file mode 100644
index 0000000..7f9d18d
--- /dev/null
+++ b/src/main/resources/at/gv/egiz/pdfas/itext/srgb.profile
Binary files differ
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 3914cba..58d5843 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
@@ -63,13 +63,19 @@ signupload.button.sign = Sign document
signupload.documentnotselected = Please select a pdf document to be signed.
signupload.documentnotselected.preview = Please select a pdf document to be signed for preview.
signupload.file = PDF document
+signupload.freetext = Free text
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.heading2.freetext = Create and sign document
+signupload.nofreetext = Please enter a text to be signed.
+signupload.nofreetext.preview = Please enter a text to be signed for preview.
+signupload.note = Documents signed in textual mode can only be verified if the underlying certificate can be retrieved from a directory service.
+signupload.note.file = Textual signature mode is only practicable for simple documents without special structures (like tables, forms...) and graphics.
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.selectfilenote.freetext = Please select appropriate signature parameters and enter a text from which a pdf document will be created and signed with your citizen card.
signupload.signaturedevice = Signature device
signupload.signaturemode = Signature mode
signupload.signaturetype = Signature type
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 f73ec7c..9e7a5a0 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
@@ -1,7 +1,7 @@
-common.back = zurück
-common.backtolist = zurück zur Liste
-common.binary = binär
+common.back = zur\u00FCck
+common.backtolist = zur\u00FCck zur Liste
+common.binary = bin\u00E4r
common.bku = Lokale BKU
common.locale.param = locale=de
common.moa = MOA
@@ -9,13 +9,13 @@ common.mocca = Online BKU
common.textual = textuell
common.title = PDF-Signatur
-dataok.heading2 = Datenänderung
-dataok.taken = Die Daten wurden erfolgreich übernommen.
+dataok.heading2 = Daten\u00E4nderung
+dataok.taken = Die Daten wurden erfolgreich \u00FCbernommen.
download.button.alreadydone = Download bereits erfolgt
download.button.download = Signiertes Dokument herunterladen
download.heading2 = Dokument Signatur erstellen
-download.note = Der Signatur-Vorgang ist abgeschlossen. Das signierte Dokument kann nun heruntergeladen werden.<br/>Hinweis: Der Download ist nur einmalig möglich. Das Dokument wird nicht am Server gespeichert.
+download.note = Der Signatur-Vorgang ist abgeschlossen. Das signierte Dokument kann nun heruntergeladen werden.<br/>Hinweis: Der Download ist nur einmalig m\u00F6glich. Das Dokument wird nicht am Server gespeichert.
download.title = PDF-Signatur: Download
error.cause = Ursache
@@ -29,7 +29,7 @@ errorverify.title = PDF-Signatur: Resultat
nullrequestpage.button.pleasewait = Bitte warten...
nullrequestpage.button.submit = Absenden...
nullrequestpage.heading2 = Bitte warten...
-nullrequestpage.note.local = Die Verbindung zu Ihrer Bürgerkartenumgebung wird hergestellt...
+nullrequestpage.note.local = Die Verbindung zu Ihrer B\u00FCrgerkartenumgebung wird hergestellt...
nullrequestpage.note.server = Die Verbindung zur Online BKU wird hergestellt...
nullrequestpage.title = PDF-Signatur: Lokale Verbindung
@@ -37,13 +37,13 @@ pleasewait.body = Bitte warten.<br/>\r\nApplet wird geladen...
pleasewait.title = Online BKU
results.certificate = Zertifikat
-results.certificatecheck = Zertifikats-Prüfung
-results.heading2 = Prüfergebnis
+results.certificatecheck = Zertifikats-Pr\u00FCfung
+results.heading2 = Pr\u00FCfergebnis
results.issuer = Aussteller
-results.manifestcheck = Manifest-Prüfung
+results.manifestcheck = Manifest-Pr\u00FCfung
results.property = Eigenschaft
results.serialnumber = Seriennummer
-results.signaturecheck = Signatur-Prüfung
+results.signaturecheck = Signatur-Pr\u00FCfung
results.signer = Signator
signaturblock.issuer.value.cn = Ausstellername
@@ -60,17 +60,23 @@ signservlet.error = Fehler beim Upload der Daten
signupload.button.preview = Vorschau
signupload.button.sign = Signatur erstellen
-signupload.documentnotselected = Bitte wählen Sie das zu signierende PDF-Dokument aus.
-signupload.documentnotselected.preview = Bitte wählen Sie das zu signierende PDF-Dokument für die Vorschau aus.
+signupload.documentnotselected = Bitte w\u00E4hlen Sie das zu signierende PDF-Dokument aus.
+signupload.documentnotselected.preview = Bitte w\u00E4hlen Sie das zu signierende PDF-Dokument f\u00FCr die Vorschau aus.
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.freetext = Freitext
+signupload.heading2 = Dokument signieren
+signupload.heading2.freetext = Dokument erstellen und signieren
+signupload.nofreetext = Bitte geben Sie den zu signierenden Text ein.
+signupload.nofreetext.preview = Bitte geben Sie den zu signierenden Text f\u00FCr die Vorschau ein.
+signupload.note = Textuell signierte Dokumente k\u00F6nnen nur dann gepr\u00FCft werden, wenn das Zertifikat in einem Verzeichnisdienst verf\u00FCgbar ist.
+signupload.note.file = Der textuelle Signaturmodus ist nur f\u00FCr einfache Dokumente ohne Strukturierung (Tabellen, Formulare udgl.) und ohne Grafiken sinnvoll anwendbar.
+signupload.note.pdfa = Bitte ber\u00FCcksichtigen Sie, dass die Verwendung von PDF/A-1b die Gr\u00F6\u00DFe der signierten Datei erh\u00F6ht, 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.noteonsigmark = Das Erscheinungsbild der Signaturmarke kann abh\u00E4ngig vom Signaturtyp, vom Signaturmodus, von der verwendeten B\u00FCrgerkarte, sowie von der verwendeten B\u00FCrgerkartenumgebung 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.selectfilenote = Bitte w\u00E4hlen Sie die Signaturparameter sowie das zu signierende PDF Dokument. Dieses wird mit Ihrer B\u00FCrgerkarte signiert.
+signupload.selectfilenote.freetext = Bitte w\u00E4hlen Sie die Signaturparameter und geben Sie einen Text ein aus dem ein PDF-Dokument erstellt und mir Ihrer B\u00FCrgerkarte signiert wird.
+signupload.signaturedevice = Signaturger\u00E4t
signupload.signaturemode = Signaturmodus
signupload.signaturetype = Signaturtyp
signupload.signaturetype.signaturblock.de = Standardsignatur Deutsch
@@ -79,22 +85,22 @@ signupload.signaturetype.signaturblock.en = Standardsignatur Englisch
test.common.title = PDF-Signatur (Test)
verifylist.button.preview = Vorschau...
-verifylist.button.verifyallsignatures = Alle prüfen
-verifylist.button.verifysinglesignature = Nur diese Signatur prüfen
-verifylist.heading2.plural = Dokument Signaturen prüfen
-verifylist.heading2.singular = Dokument Signatur prüfen
-
-verifypreview.applyvalues = Werte übernehmen
-verifypreview.applyvaluesandverify = Werte übernehmen und prüfen
-verifypreview.heading2 = Vorschau: Dokument prüfen
+verifylist.button.verifyallsignatures = Alle pr\u00FCfen
+verifylist.button.verifysinglesignature = Nur diese Signatur pr\u00FCfen
+verifylist.heading2.plural = Dokument Signaturen pr\u00FCfen
+verifylist.heading2.singular = Dokument Signatur pr\u00FCfen
+
+verifypreview.applyvalues = Werte \u00FCbernehmen
+verifypreview.applyvaluesandverify = Werte \u00FCbernehmen und pr\u00FCfen
+verifypreview.heading2 = Vorschau: Dokument pr\u00FCfen
verifypreview.reconstruction = Rekonstruktion der Signaturmarke
verifypreviewservlet.cause = Beim Upload der Daten ist ein Fehler aufgetreten.
verifypreviewservlet.error = Fehler beim Upload der Daten
verifyupload.button.listsignatures = Signaturen auflisten
-verifyupload.button.verifyallsignatures = Alle prüfen
-verifyupload.heading2 = Dokument Signatur prüfen
-verifyupload.note = Hier bitte den vollständigen Dokumenttext samt Signaturblock eingeben.
-verifyupload.verifydevice = Prüf-Applikation
-verifyupload.verifymode = Prüf-Modus
+verifyupload.button.verifyallsignatures = Alle pr\u00FCfen
+verifyupload.heading2 = Dokument Signatur pr\u00FCfen
+verifyupload.note = Hier bitte den vollst\u00E4ndigen Dokumenttext samt Signaturblock eingeben.
+verifyupload.verifydevice = Pr\u00FCf-Applikation
+verifyupload.verifymode = Pr\u00FCf-Modus
diff --git a/src/main/resources/config/help_text.properties b/src/main/resources/config/help_text.properties
index 61b35d1..d6e6608 100644
--- a/src/main/resources/config/help_text.properties
+++ b/src/main/resources/config/help_text.properties
@@ -5,7 +5,8 @@ error.code.2=Die Signatur für das Dokument kann nicht überprüft werden.
error.code.3=Es wurde kein Dokument zur Signierung angegeben oder das Dokument konnte nicht gespeichert werden.
error.code.4=Es wurde kein Dokument zur Überprüfung angegeben oder das Dokument konnte nicht gespeichert werden.
error.code.5=Zum Signieren eines Dokmentes müssen Sie authentifiziert sein.
-error.code.6=Unbekannter Fehler
+error.code.6=Unbekannter/interner Fehler
+error.code.7=Das Dokument konnte nicht verarbeitet werden, da unzureichend Speicher zu Verfügung steht.
error.code.10=Das System kann nicht initialisiert werden. Bitte wenden Sie sich an einen Systemadministrator.
@@ -28,7 +29,7 @@ error.code.220=Die Bildmarke für die Signatur kann nicht geladen werden.
error.code.221=Die Referenz für die Bildmarke der Signatur ist ungültig.
error.code.222=Der Zugriff auf die Bildmarke der Signatur ist nicht möglich.
error.code.223=Es ist keine Signaturtabelle definiert.
-error.code.224=Die angegebene absolute Position ist ungültig.
+error.code.224=Die angegebene Signatur Position ist ungültig.
error.code.225=Die angegebene Seite in der absoluten Position darf nicht kleiner als 1 sein.
error.code.226=Der angegebene Wert für die Breite in der absoluten Position darf nicht kleiner gleich 0 sein.
error.code.227=Der angegebene Wert für die Seitennummer im Positionsparameter ist zu groß.
diff --git a/src/main/resources/config/templates/default.bku.verify.template.detached.xml b/src/main/resources/config/templates/default.bku.verify.template.detached.xml
index 977098a..8948ea2 100644
--- a/src/main/resources/config/templates/default.bku.verify.template.detached.xml
+++ b/src/main/resources/config/templates/default.bku.verify.template.detached.xml
@@ -1 +1,13 @@
-<dsig:Signature xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" Id="signature-SigIdReplace"><dsig:SignedInfo><dsig:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/><dsig:SignatureMethod Algorithm="CertAlgReplace"/><dsig:Reference Id="signed-data-reference-SigDataRefReplace" URI="urn:Document"><dsig:DigestMethod Algorithm="DataDigestReplace"/><dsig:DigestValue>DigestValueSignedDataReplace</dsig:DigestValue></dsig:Reference><dsig:Reference Id="etsi-data-reference-EtsiDataRefReplace" Type="http://uri.etsi.org/01903/v1.1.1#SignedProperties" URI="#xmlns(etsi=http://uri.etsi.org/01903/v1.1.1%23)%20xpointer(id('etsi-data-object-EtsiDataObjURIReplace')/child::etsi:QualifyingProperties/child::etsi:SignedProperties)"><dsig:DigestMethod Algorithm="PropertiesDigestReplace"/><dsig:DigestValue>DigestValueSignedPropertiesReplace</dsig:DigestValue></dsig:Reference></dsig:SignedInfo><dsig:SignatureValue>SignatureValueReplace</dsig:SignatureValue><dsig:KeyInfo><dsig:X509Data><dsig:X509Certificate>X509CertificateReplace</dsig:X509Certificate></dsig:X509Data></dsig:KeyInfo><dsig:Object Id="etsi-data-object-EtsiDataObjURIReplace"><etsi:QualifyingProperties xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:etsi="http://uri.etsi.org/01903/v1.1.1#" Target="#signature-SigIdReplace"><etsi:SignedProperties xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:etsi="http://uri.etsi.org/01903/v1.1.1#"><etsi:SignedSignatureProperties><etsi:SigningTime>SigningTimeReplace</etsi:SigningTime><etsi:SigningCertificate><etsi:Cert><etsi:CertDigest><etsi:DigestMethod Algorithm="CertDigestReplace"></etsi:DigestMethod><etsi:DigestValue>DigestValueX509CertificateReplace</etsi:DigestValue></etsi:CertDigest><etsi:IssuerSerial><dsig:X509IssuerName>X509IssuerNameReplace</dsig:X509IssuerName><dsig:X509SerialNumber>X509SerialNumberReplace</dsig:X509SerialNumber></etsi:IssuerSerial></etsi:Cert></etsi:SigningCertificate><etsi:SignaturePolicyIdentifier><etsi:SignaturePolicyImplied></etsi:SignaturePolicyImplied></etsi:SignaturePolicyIdentifier></etsi:SignedSignatureProperties><etsi:SignedDataObjectProperties><etsi:DataObjectFormat ObjectReference="#signed-data-reference-SigDataRefReplace"><etsi:MimeType>MimeTypeReplace</etsi:MimeType></etsi:DataObjectFormat></etsi:SignedDataObjectProperties></etsi:SignedProperties></etsi:QualifyingProperties></dsig:Object></dsig:Signature> \ No newline at end of file
+<dsig:Signature xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" Id="signature-SigIdReplace">
+<dsig:SignedInfo>
+<dsig:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
+<dsig:SignatureMethod Algorithm="CertAlgReplace"/>
+<dsig:Reference Id="signed-data-reference-SigDataRefReplace" URI="urn:Document">
+<dsig:DigestMethod Algorithm="DataDigestReplace"/>
+<dsig:DigestValue>DigestValueSignedDataReplace</dsig:DigestValue>
+</dsig:Reference>
+<dsig:Reference Id="etsi-data-reference-EtsiDataRefReplace" Type="http://uri.etsi.org/01903/v1.1.1#SignedProperties" URI="#xmlns(etsi=http://uri.etsi.org/01903/v1.1.1%23)%20xpointer(id('etsi-data-object-EtsiDataObjURIReplace')/child::etsi:QualifyingProperties/child::etsi:SignedProperties)"><dsig:DigestMethod Algorithm="PropertiesDigestReplace"/><dsig:DigestValue>DigestValueSignedPropertiesReplace</dsig:DigestValue></dsig:Reference></dsig:SignedInfo>
+<dsig:SignatureValue>SignatureValueReplace</dsig:SignatureValue>
+<dsig:KeyInfo><dsig:X509Data><dsig:X509Certificate>X509CertificateReplace</dsig:X509Certificate></dsig:X509Data></dsig:KeyInfo>
+<dsig:Object Id="etsi-data-object-EtsiDataObjURIReplace"><etsi:QualifyingProperties xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:etsi="http://uri.etsi.org/01903/v1.1.1#" Target="#signature-SigIdReplace"><etsi:SignedProperties xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:etsi="http://uri.etsi.org/01903/v1.1.1#"><etsi:SignedSignatureProperties><etsi:SigningTime>SigningTimeReplace</etsi:SigningTime><etsi:SigningCertificate><etsi:Cert><etsi:CertDigest><etsi:DigestMethod Algorithm="CertDigestReplace"></etsi:DigestMethod><etsi:DigestValue>DigestValueX509CertificateReplace</etsi:DigestValue></etsi:CertDigest><etsi:IssuerSerial><dsig:X509IssuerName>X509IssuerNameReplace</dsig:X509IssuerName><dsig:X509SerialNumber>X509SerialNumberReplace</dsig:X509SerialNumber></etsi:IssuerSerial></etsi:Cert></etsi:SigningCertificate><etsi:SignaturePolicyIdentifier><etsi:SignaturePolicyImplied></etsi:SignaturePolicyImplied></etsi:SignaturePolicyIdentifier></etsi:SignedSignatureProperties><etsi:SignedDataObjectProperties><etsi:DataObjectFormat ObjectReference="#signed-data-reference-SigDataRefReplace"><etsi:MimeType>MimeTypeReplace</etsi:MimeType></etsi:DataObjectFormat></etsi:SignedDataObjectProperties></etsi:SignedProperties></etsi:QualifyingProperties></dsig:Object>
+</dsig:Signature> \ No newline at end of file
diff --git a/src/main/resources/config/templates/default.bku.verify.template.enveloping.old.xml b/src/main/resources/config/templates/default.bku.verify.template.enveloping.old.xml
index 4a8968a..cf64b3b 100644
--- a/src/main/resources/config/templates/default.bku.verify.template.enveloping.old.xml
+++ b/src/main/resources/config/templates/default.bku.verify.template.enveloping.old.xml
@@ -1 +1,6 @@
-<dsig:Signature xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" Id="signature-SigIdReplace"><dsig:SignedInfo><dsig:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/><dsig:SignatureMethod Algorithm="CertAlgReplace"/><dsig:Reference Id="signed-data-reference-SigDataRefReplace" URI="#signed-data-object-SigDataObjURIReplace"><dsig:Transforms><dsig:Transform Algorithm="http://www.w3.org/2002/06/xmldsig-filter2"><xpf:XPath xmlns:xpf="http://www.w3.org/2002/06/xmldsig-filter2" Filter="intersect">id('signed-data-object-SigDataObjURIReplace')/node()</xpf:XPath></dsig:Transform><dsig:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#base64"/></dsig:Transforms><dsig:DigestMethod Algorithm="DataDigestReplace"/><dsig:DigestValue>DigestValueSignedDataReplace</dsig:DigestValue></dsig:Reference><dsig:Reference Id="etsi-data-reference-EtsiDataRefReplace" Type="http://uri.etsi.org/01903/v1.1.1#SignedProperties" URI="#etsi-data-object-EtsiDataObjURIReplace"><dsig:Transforms><dsig:Transform Algorithm="http://www.w3.org/2002/06/xmldsig-filter2"><xpf:XPath xmlns:xpf="http://www.w3.org/2002/06/xmldsig-filter2" Filter="intersect">id('etsi-data-object-EtsiDataObjURIReplace')/node()</xpf:XPath></dsig:Transform></dsig:Transforms><dsig:DigestMethod Algorithm="PropertiesDigestReplace"/><dsig:DigestValue>DigestValueSignedPropertiesReplace</dsig:DigestValue></dsig:Reference></dsig:SignedInfo><dsig:SignatureValue>SignatureValueReplace</dsig:SignatureValue><dsig:KeyInfo><dsig:X509Data><dsig:X509Certificate>X509CertificateReplace</dsig:X509Certificate></dsig:X509Data></dsig:KeyInfo><dsig:Object Id="signed-data-object-SigDataObjURIReplace"><sl:Base64Content>Base64ContentReplace</sl:Base64Content></dsig:Object><dsig:Object Id="etsi-data-object-EtsiDataObjURIReplace"><etsi:QualifyingProperties xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:etsi="http://uri.etsi.org/01903/v1.1.1#" Target="#signature-SigIdReplace"><etsi:SignedProperties><etsi:SignedSignatureProperties><etsi:SigningTime>SigningTimeReplace</etsi:SigningTime><etsi:SigningCertificate><etsi:Cert><etsi:CertDigest><etsi:DigestMethod Algorithm="CertDigestReplace"></etsi:DigestMethod><etsi:DigestValue>DigestValueX509CertificateReplace</etsi:DigestValue></etsi:CertDigest><etsi:IssuerSerial><dsig:X509IssuerName>X509IssuerNameReplace</dsig:X509IssuerName><dsig:X509SerialNumber>X509SerialNumberReplace</dsig:X509SerialNumber></etsi:IssuerSerial></etsi:Cert></etsi:SigningCertificate><etsi:SignaturePolicyIdentifier><etsi:SignaturePolicyImplied></etsi:SignaturePolicyImplied></etsi:SignaturePolicyIdentifier></etsi:SignedSignatureProperties><etsi:SignedDataObjectProperties><etsi:DataObjectFormat ObjectReference="#signed-data-reference-SigDataRefReplace"><etsi:MimeType>text/plain</etsi:MimeType></etsi:DataObjectFormat></etsi:SignedDataObjectProperties></etsi:SignedProperties></etsi:QualifyingProperties></dsig:Object></dsig:Signature> \ No newline at end of file
+<dsig:Signature xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" Id="signature-SigIdReplace"><dsig:SignedInfo><dsig:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/><dsig:SignatureMethod Algorithm="CertAlgReplace"/><dsig:Reference Id="signed-data-reference-SigDataRefReplace" URI="#signed-data-object-SigDataObjURIReplace"><dsig:Transforms><dsig:Transform Algorithm="http://www.w3.org/2002/06/xmldsig-filter2"><xpf:XPath xmlns:xpf="http://www.w3.org/2002/06/xmldsig-filter2" Filter="intersect">id('signed-data-object-SigDataObjURIReplace')/node()</xpf:XPath></dsig:Transform><dsig:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#base64"/></dsig:Transforms><dsig:DigestMethod Algorithm="DataDigestReplace"/><dsig:DigestValue>DigestValueSignedDataReplace</dsig:DigestValue></dsig:Reference><dsig:Reference Id="etsi-data-reference-EtsiDataRefReplace" Type="http://uri.etsi.org/01903/v1.1.1#SignedProperties" URI="#etsi-data-object-EtsiDataObjURIReplace"><dsig:Transforms><dsig:Transform Algorithm="http://www.w3.org/2002/06/xmldsig-filter2"><xpf:XPath xmlns:xpf="http://www.w3.org/2002/06/xmldsig-filter2" Filter="intersect">id('etsi-data-object-EtsiDataObjURIReplace')/node()</xpf:XPath></dsig:Transform></dsig:Transforms><dsig:DigestMethod Algorithm="PropertiesDigestReplace"/><dsig:DigestValue>DigestValueSignedPropertiesReplace</dsig:DigestValue></dsig:Reference></dsig:SignedInfo>
+<dsig:SignatureValue>SignatureValueReplace</dsig:SignatureValue>
+<dsig:KeyInfo><dsig:X509Data><dsig:X509Certificate>X509CertificateReplace</dsig:X509Certificate></dsig:X509Data></dsig:KeyInfo>
+<dsig:Object Id="signed-data-object-SigDataObjURIReplace"><sl:Base64Content>Base64ContentReplace</sl:Base64Content></dsig:Object>
+<dsig:Object Id="etsi-data-object-EtsiDataObjURIReplace"><etsi:QualifyingProperties xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:etsi="http://uri.etsi.org/01903/v1.1.1#" Target="#signature-SigIdReplace"><etsi:SignedProperties><etsi:SignedSignatureProperties><etsi:SigningTime>SigningTimeReplace</etsi:SigningTime><etsi:SigningCertificate><etsi:Cert><etsi:CertDigest><etsi:DigestMethod Algorithm="CertDigestReplace"></etsi:DigestMethod><etsi:DigestValue>DigestValueX509CertificateReplace</etsi:DigestValue></etsi:CertDigest><etsi:IssuerSerial><dsig:X509IssuerName>X509IssuerNameReplace</dsig:X509IssuerName><dsig:X509SerialNumber>X509SerialNumberReplace</dsig:X509SerialNumber></etsi:IssuerSerial></etsi:Cert></etsi:SigningCertificate><etsi:SignaturePolicyIdentifier><etsi:SignaturePolicyImplied></etsi:SignaturePolicyImplied></etsi:SignaturePolicyIdentifier></etsi:SignedSignatureProperties><etsi:SignedDataObjectProperties><etsi:DataObjectFormat ObjectReference="#signed-data-reference-SigDataRefReplace"><etsi:MimeType>text/plain</etsi:MimeType></etsi:DataObjectFormat></etsi:SignedDataObjectProperties></etsi:SignedProperties></etsi:QualifyingProperties></dsig:Object>
+</dsig:Signature> \ No newline at end of file
diff --git a/src/main/resources/config/templates/default.bku.verify.template.enveloping.xml b/src/main/resources/config/templates/default.bku.verify.template.enveloping.xml
index c43a99a..bd30d70 100644
--- a/src/main/resources/config/templates/default.bku.verify.template.enveloping.xml
+++ b/src/main/resources/config/templates/default.bku.verify.template.enveloping.xml
@@ -1 +1,6 @@
-<dsig:Signature xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" Id="signature-SigIdReplace"><dsig:SignedInfo><dsig:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/><dsig:SignatureMethod Algorithm="CertAlgReplace"/><dsig:Reference Id="signed-data-reference-SigDataRefReplace" URI="#signed-data-object-SigDataObjURIReplace"><dsig:Transforms><dsig:Transform Algorithm="http://www.w3.org/2002/06/xmldsig-filter2"><xpf:XPath xmlns:xpf="http://www.w3.org/2002/06/xmldsig-filter2" Filter="intersect">id('signed-data-object-SigDataObjURIReplace')/node()</xpf:XPath></dsig:Transform><dsig:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#base64"/></dsig:Transforms><dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><dsig:DigestValue>DigestValueSignedDataReplace</dsig:DigestValue></dsig:Reference><dsig:Reference Id="etsi-data-reference-EtsiDataRefReplace" Type="http://uri.etsi.org/01903/v1.1.1#SignedProperties" URI="#xmlns(etsi=http://uri.etsi.org/01903/v1.1.1%23)%20xpointer(id('etsi-data-object-EtsiDataObjURIReplace')/child::etsi:QualifyingProperties/child::etsi:SignedProperties)"><dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><dsig:DigestValue>DigestValueSignedPropertiesReplace</dsig:DigestValue></dsig:Reference></dsig:SignedInfo><dsig:SignatureValue>SignatureValueReplace</dsig:SignatureValue><dsig:KeyInfo><dsig:X509Data><dsig:X509Certificate>X509CertificateReplace</dsig:X509Certificate></dsig:X509Data></dsig:KeyInfo><dsig:Object Id="signed-data-object-SigDataObjURIReplace"><dsig:Base64Content>Base64ContentReplace</dsig:Base64Content></dsig:Object><dsig:Object Id="etsi-data-object-EtsiDataObjURIReplace"><etsi:QualifyingProperties xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:etsi="http://uri.etsi.org/01903/v1.1.1#" Target="#signature-SigIdReplace"><etsi:SignedProperties xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:etsi="http://uri.etsi.org/01903/v1.1.1#"><etsi:SignedSignatureProperties><etsi:SigningTime>SigningTimeReplace</etsi:SigningTime><etsi:SigningCertificate><etsi:Cert><etsi:CertDigest><etsi:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></etsi:DigestMethod><etsi:DigestValue>DigestValueX509CertificateReplace</etsi:DigestValue></etsi:CertDigest><etsi:IssuerSerial><dsig:X509IssuerName>X509IssuerNameReplace</dsig:X509IssuerName><dsig:X509SerialNumber>X509SerialNumberReplace</dsig:X509SerialNumber></etsi:IssuerSerial></etsi:Cert></etsi:SigningCertificate><etsi:SignaturePolicyIdentifier><etsi:SignaturePolicyImplied></etsi:SignaturePolicyImplied></etsi:SignaturePolicyIdentifier></etsi:SignedSignatureProperties><etsi:SignedDataObjectProperties><etsi:DataObjectFormat ObjectReference="#signed-data-reference-SigDataRefReplace"><etsi:MimeType>text/plain</etsi:MimeType></etsi:DataObjectFormat></etsi:SignedDataObjectProperties></etsi:SignedProperties></etsi:QualifyingProperties></dsig:Object></dsig:Signature> \ No newline at end of file
+<dsig:Signature xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" Id="signature-SigIdReplace"><dsig:SignedInfo><dsig:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/><dsig:SignatureMethod Algorithm="CertAlgReplace"/><dsig:Reference Id="signed-data-reference-SigDataRefReplace" URI="#signed-data-object-SigDataObjURIReplace"><dsig:Transforms><dsig:Transform Algorithm="http://www.w3.org/2002/06/xmldsig-filter2"><xpf:XPath xmlns:xpf="http://www.w3.org/2002/06/xmldsig-filter2" Filter="intersect">id('signed-data-object-SigDataObjURIReplace')/node()</xpf:XPath></dsig:Transform><dsig:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#base64"/></dsig:Transforms><dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><dsig:DigestValue>DigestValueSignedDataReplace</dsig:DigestValue></dsig:Reference><dsig:Reference Id="etsi-data-reference-EtsiDataRefReplace" Type="http://uri.etsi.org/01903/v1.1.1#SignedProperties" URI="#xmlns(etsi=http://uri.etsi.org/01903/v1.1.1%23)%20xpointer(id('etsi-data-object-EtsiDataObjURIReplace')/child::etsi:QualifyingProperties/child::etsi:SignedProperties)"><dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><dsig:DigestValue>DigestValueSignedPropertiesReplace</dsig:DigestValue></dsig:Reference></dsig:SignedInfo>
+<dsig:SignatureValue>SignatureValueReplace</dsig:SignatureValue>
+<dsig:KeyInfo><dsig:X509Data><dsig:X509Certificate>X509CertificateReplace</dsig:X509Certificate></dsig:X509Data></dsig:KeyInfo>
+<dsig:Object Id="signed-data-object-SigDataObjURIReplace"><dsig:Base64Content>Base64ContentReplace</dsig:Base64Content></dsig:Object>
+<dsig:Object Id="etsi-data-object-EtsiDataObjURIReplace"><etsi:QualifyingProperties xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:etsi="http://uri.etsi.org/01903/v1.1.1#" Target="#signature-SigIdReplace"><etsi:SignedProperties xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:etsi="http://uri.etsi.org/01903/v1.1.1#"><etsi:SignedSignatureProperties><etsi:SigningTime>SigningTimeReplace</etsi:SigningTime><etsi:SigningCertificate><etsi:Cert><etsi:CertDigest><etsi:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></etsi:DigestMethod><etsi:DigestValue>DigestValueX509CertificateReplace</etsi:DigestValue></etsi:CertDigest><etsi:IssuerSerial><dsig:X509IssuerName>X509IssuerNameReplace</dsig:X509IssuerName><dsig:X509SerialNumber>X509SerialNumberReplace</dsig:X509SerialNumber></etsi:IssuerSerial></etsi:Cert></etsi:SigningCertificate><etsi:SignaturePolicyIdentifier><etsi:SignaturePolicyImplied></etsi:SignaturePolicyImplied></etsi:SignaturePolicyIdentifier></etsi:SignedSignatureProperties><etsi:SignedDataObjectProperties><etsi:DataObjectFormat ObjectReference="#signed-data-reference-SigDataRefReplace"><etsi:MimeType>text/plain</etsi:MimeType></etsi:DataObjectFormat></etsi:SignedDataObjectProperties></etsi:SignedProperties></etsi:QualifyingProperties></dsig:Object>
+</dsig:Signature> \ No newline at end of file
diff --git a/src/main/resources/config/templates/default.moa.verify.template.enveloping.xml b/src/main/resources/config/templates/default.moa.verify.template.enveloping.xml
index f04f101..0d4b3db 100644
--- a/src/main/resources/config/templates/default.moa.verify.template.enveloping.xml
+++ b/src/main/resources/config/templates/default.moa.verify.template.enveloping.xml
@@ -1 +1,11 @@
-<dsig:Signature Id="signature-1-1" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"><dsig:SignedInfo xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"><dsig:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/><dsig:SignatureMethod Algorithm="CertAlgReplace"/><dsig:Reference Id="reference-1-1" URI="#xpointer(id('signed-data-1-1-1')/node())"><dsig:Transforms><dsig:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#base64"></dsig:Transform></dsig:Transforms><dsig:DigestMethod Algorithm="DataDigestReplace"/><dsig:DigestValue>DigestValueSignedDataReplace</dsig:DigestValue></dsig:Reference><dsig:Reference Type="http://uri.etsi.org/01903/v1.1.1#SignedProperties" URI="#xmlns(etsi=http://uri.etsi.org/01903/v1.1.1%23)%20xpointer(id('etsi-signed-1-1')/child::etsi:QualifyingProperties/child::etsi:SignedProperties)"><dsig:DigestMethod Algorithm="PropertiesDigestReplace"></dsig:DigestMethod><dsig:DigestValue>DigestValueSignedPropertiesReplace</dsig:DigestValue></dsig:Reference></dsig:SignedInfo><dsig:SignatureValue>SignatureValueReplace</dsig:SignatureValue><dsig:KeyInfo><dsig:X509Data><dsig:X509Certificate>X509CertificateReplace</dsig:X509Certificate></dsig:X509Data></dsig:KeyInfo><dsig:Object Id="signed-data-1-1-1"><Base64Content>Base64ContentReplace</Base64Content></dsig:Object><dsig:Object Id="etsi-signed-1-1"><etsi:QualifyingProperties Target="#signature-1-1" xmlns:etsi="http://uri.etsi.org/01903/v1.1.1#"><etsi:SignedProperties xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:etsi="http://uri.etsi.org/01903/v1.1.1#"><etsi:SignedSignatureProperties><etsi:SigningTime>SigningTimeReplace</etsi:SigningTime><etsi:SigningCertificate><etsi:Cert><etsi:CertDigest><etsi:DigestMethod Algorithm="CertDigestReplace"></etsi:DigestMethod><etsi:DigestValue>DigestValueX509CertificateReplace</etsi:DigestValue></etsi:CertDigest><etsi:IssuerSerial><dsig:X509IssuerName>X509IssuerNameReplace</dsig:X509IssuerName><dsig:X509SerialNumber>X509SerialNumberReplace</dsig:X509SerialNumber></etsi:IssuerSerial></etsi:Cert></etsi:SigningCertificate><etsi:SignaturePolicyIdentifier><etsi:SignaturePolicyImplied></etsi:SignaturePolicyImplied></etsi:SignaturePolicyIdentifier></etsi:SignedSignatureProperties><etsi:SignedDataObjectProperties><etsi:DataObjectFormat ObjectReference="#reference-1-1"><etsi:MimeType>text/plain</etsi:MimeType></etsi:DataObjectFormat></etsi:SignedDataObjectProperties></etsi:SignedProperties></etsi:QualifyingProperties></dsig:Object></dsig:Signature> \ No newline at end of file
+<dsig:Signature Id="signature-1-1" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#">
+<dsig:SignedInfo xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"><dsig:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/><dsig:SignatureMethod Algorithm="CertAlgReplace"/><dsig:Reference Id="reference-1-1" URI="#xpointer(id('signed-data-1-1-1')/node())"><dsig:Transforms><dsig:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#base64"></dsig:Transform></dsig:Transforms><dsig:DigestMethod Algorithm="DataDigestReplace"/><dsig:DigestValue>DigestValueSignedDataReplace</dsig:DigestValue></dsig:Reference><dsig:Reference Type="http://uri.etsi.org/01903/v1.1.1#SignedProperties" URI="#xmlns(etsi=http://uri.etsi.org/01903/v1.1.1%23)%20xpointer(id('etsi-signed-1-1')/child::etsi:QualifyingProperties/child::etsi:SignedProperties)"><dsig:DigestMethod Algorithm="PropertiesDigestReplace"></dsig:DigestMethod><dsig:DigestValue>DigestValueSignedPropertiesReplace</dsig:DigestValue></dsig:Reference></dsig:SignedInfo>
+<dsig:SignatureValue>SignatureValueReplace</dsig:SignatureValue>
+<dsig:KeyInfo>
+<dsig:X509Data>
+<dsig:X509Certificate>X509CertificateReplace</dsig:X509Certificate>
+</dsig:X509Data>
+</dsig:KeyInfo>
+<dsig:Object Id="signed-data-1-1-1"><Base64Content>Base64ContentReplace</Base64Content></dsig:Object>
+<dsig:Object Id="etsi-signed-1-1"><etsi:QualifyingProperties Target="#signature-1-1" xmlns:etsi="http://uri.etsi.org/01903/v1.1.1#"><etsi:SignedProperties xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:etsi="http://uri.etsi.org/01903/v1.1.1#"><etsi:SignedSignatureProperties><etsi:SigningTime>SigningTimeReplace</etsi:SigningTime><etsi:SigningCertificate><etsi:Cert><etsi:CertDigest><etsi:DigestMethod Algorithm="CertDigestReplace"></etsi:DigestMethod><etsi:DigestValue>DigestValueX509CertificateReplace</etsi:DigestValue></etsi:CertDigest><etsi:IssuerSerial><dsig:X509IssuerName>X509IssuerNameReplace</dsig:X509IssuerName><dsig:X509SerialNumber>X509SerialNumberReplace</dsig:X509SerialNumber></etsi:IssuerSerial></etsi:Cert></etsi:SigningCertificate><etsi:SignaturePolicyIdentifier><etsi:SignaturePolicyImplied></etsi:SignaturePolicyImplied></etsi:SignaturePolicyIdentifier></etsi:SignedSignatureProperties><etsi:SignedDataObjectProperties><etsi:DataObjectFormat ObjectReference="#reference-1-1"><etsi:MimeType>text/plain</etsi:MimeType></etsi:DataObjectFormat></etsi:SignedDataObjectProperties></etsi:SignedProperties></etsi:QualifyingProperties></dsig:Object>
+</dsig:Signature> \ No newline at end of file
diff --git a/src/main/webapp/WEB-INF/decorators.xml b/src/main/webapp/WEB-INF/decorators.xml
index 352a902..a88892d 100644
--- a/src/main/webapp/WEB-INF/decorators.xml
+++ b/src/main/webapp/WEB-INF/decorators.xml
@@ -9,11 +9,6 @@
<pattern>/*.pdf</pattern>
</excludes>
- <!--
- <decorator name="standalone" page="/sitemesh/standalone.jsp">
- <decorator name="production" page="/sitemesh/buergerkarte/pdf-as-template.jsp">
- <decorator name="test" page="/sitemesh/buergerkarte/test-pdf-as-template.jsp">
- -->
<decorator name="standalone" page="/sitemesh/standalone.jsp">
<pattern>/*</pattern>
</decorator>
diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml
index ce82e9a..4a7ad77 100644
--- a/src/main/webapp/WEB-INF/web.xml
+++ b/src/main/webapp/WEB-INF/web.xml
@@ -39,7 +39,15 @@
</init-param>
<init-param>
<param-name>forceRequestEncoding</param-name>
- <param-value>false</param-value>
+ <param-value>true</param-value>
+ </init-param>
+ <init-param>
+ <param-name>setResponseEncoding</param-name>
+ <param-value>true</param-value>
+ </init-param>
+ <init-param>
+ <param-name>forceResponseEncoding</param-name>
+ <param-value>true</param-value>
</init-param>
</filter>
diff --git a/src/main/webapp/css/pdfas-styles.css b/src/main/webapp/css/pdfas-styles.css
index a7e1906..6831232 100644
--- a/src/main/webapp/css/pdfas-styles.css
+++ b/src/main/webapp/css/pdfas-styles.css
@@ -16,6 +16,13 @@ table.pdfassignature td.pdfaslabel {
/* word-spacing: nowrap; */
}
+textarea.freetext {
+ width: 450px;
+ height: 150px;
+ font: 1em 'Courier New', courier, monospace;
+ margin: 0px 0px 0px 0px;
+}
+
table#pdfasupperformtable {
margin-top: 10px;
}
diff --git a/src/main/webapp/jsp/SIGNATURBLOCK.jsp b/src/main/webapp/jsp/SIGNATURBLOCK.jsp
index 336365b..66e64e3 100644
--- a/src/main/webapp/jsp/SIGNATURBLOCK.jsp
+++ b/src/main/webapp/jsp/SIGNATURBLOCK.jsp
@@ -26,7 +26,7 @@
if ("SIGNATURBLOCK_DE".equals(type)) {
sbValue = "Signaturwert";
sbLabel = "signatur-logo_de-100.png";
- sbMetaValue = "Informationen zur Prüfung der elektronischen Signatur und des Ausdrucks finden Sie unter: <input type=\"text\" name=\"vservice\" readonly=\"readonly\" disabled=\"disabled\" value=\"https://www.buergerkarte.at/signature-verification\" size=\"50\" maxlength=\"255\"/>";
+ sbMetaValue = "Informationen zur Prüfung der elektronischen Signatur und des Ausdrucks finden Sie unter: <input type=\"text\" name=\"vservice\" readonly=\"readonly\" disabled=\"disabled\" value=\"http://www.signaturpruefung.gv.at\" size=\"50\" maxlength=\"255\"/>";
sbName = "Unterzeichner";
sbDate = "Datum/Zeit-UTC";
sbIssuer = "Aussteller-Zertifikat";
@@ -37,7 +37,7 @@
} else {
sbValue = "Signature Value";
sbLabel = "signatur-logo_en-100.png";
- sbMetaValue = "Information about the verification of the electronic signature and of the printout can be found at: <input type=\"text\" name=\"vservice\" readonly=\"readonly\" disabled=\"disabled\" value=\"https://www.buergerkarte.at/signature-verification\" size=\"50\" maxlength=\"255\"/>";
+ sbMetaValue = "Information about the verification of the electronic signature and of the printout can be found at: <input type=\"text\" name=\"vservice\" readonly=\"readonly\" disabled=\"disabled\" value=\"http://www.signature-verification.gv.at\" size=\"50\" maxlength=\"255\"/>";
sbName = "Signatory";
sbDate = "Date/Time-UTC";
sbIssuer = "Issuer-Certificate";
@@ -92,15 +92,8 @@
<tr>
<td class="pdfaslabel" nowrap="nowrap"><%= sbID %></td>
<td class="pdfasvalue">
- <% if (Constants.SIGNATURE_DEVICE_MOC.equals(device)) { %>
- <div class="pdfasnobreak">etsi-moc-1.0@12345678</div>
- <% } else { %>
- <div class="pdfasnobreak">etsi-bka-1.0@1234567890-123456789@</div>
- <div class="pdfasnobreak">12345-1234-</div>
- <div class="pdfasnobreak">0-</div>
- <div class="pdfasnobreak">12345-</div>
- <div class="pdfasnobreak">12345</div></td>
- <% } // end if %>
+ <div class="pdfasnobreak">etsi-moc-1.1@dbc17c36</div>
+ </td>
</tr>
<tr>
<td class="pdfaslabel" nowrap="nowrap"><%= sbMeta %></td>
diff --git a/src/main/webapp/jsp/error.jsp b/src/main/webapp/jsp/error.jsp
index d135f88..8a06691 100644
--- a/src/main/webapp/jsp/error.jsp
+++ b/src/main/webapp/jsp/error.jsp
@@ -8,6 +8,7 @@
<%@ page import="org.apache.commons.httpclient.util.EncodingUtil" %>
<%@ page import="org.apache.commons.httpclient.NameValuePair" %>
<%@ page import="at.gv.egiz.pdfas.web.helper.SignServletHelper" %>
+<%@ page import="org.apache.commons.lang.StringEscapeUtils" %>
<%@ page import="java.io.*" %>
<%@ include file="language.jsp" %>
@@ -80,12 +81,12 @@
<div class="pdfasnote">
<% if (rb) { %>
<fmt:message key="<%= error %>"/>
- <% } else { out.write(error); } %>
+ <% } else { out.write(StringEscapeUtils.escapeHtml(error)); } %>
</div>
<div class="pdfasnote"><fmt:message key="error.cause"/>: <strong>
<% if (rb) { %>
<fmt:message key="<%= cause %>"/>
- <% } else { out.write(cause); } %>
+ <% } else { out.write(StringEscapeUtils.escapeHtml(cause)); } %>
</strong></div>
<% if (!isExternalInvocation && !paramInvok) { %>
<div class="pdfasverticalspace"></div>
@@ -99,7 +100,7 @@
pe.printStackTrace(pw);
sw.close();
pw.close();
- out.print(sw);
+ out.print(StringEscapeUtils.escapeHtml(sw.toString()));
}
%>
</pre>
diff --git a/src/main/webapp/jsp/signupload.jsp b/src/main/webapp/jsp/signupload.jsp
index 010012b..f6c02fe 100644
--- a/src/main/webapp/jsp/signupload.jsp
+++ b/src/main/webapp/jsp/signupload.jsp
@@ -1,5 +1,6 @@
<%@ page import="at.knowcenter.wag.egov.egiz.web.FormFields" %>
<%@ page import="at.knowcenter.wag.egov.egiz.web.SessionAttributes" %>
+<%@ page import="org.apache.commons.lang.StringEscapeUtils" %>
<%@ 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"%>
@@ -41,18 +42,35 @@
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.<%= FormFields.FIELD_SOURCE %>.value = submitform.<%= FormFields.FIELD_SOURCE %>.value;
+ if (submitform.<%= FormFields.FIELD_FREETEXT %>) {
+ updateform.<%= FormFields.FIELD_FREETEXT %>.value = submitform.<%= FormFields.FIELD_FREETEXT %>.value;
+ }
updateform.submit();
return(false);
}
function submitForm(preview) {
var submitform = document.getElementById('submitform');
- if (!submitform.fileupload.value) {
- if (preview) {
- alert('<fmt:message key="signupload.documentnotselected.preview"/>');
- } else {
- alert('<fmt:message key="signupload.documentnotselected"/>');
+ if (submitform.fileupload) {
+ // file
+ if (!submitform.fileupload.value) {
+ if (preview) {
+ alert('<fmt:message key="signupload.documentnotselected.preview"/>');
+ } else {
+ alert('<fmt:message key="signupload.documentnotselected"/>');
+ }
+ return(false);
+ }
+ } else {
+ // freetext
+ if (!submitform.freetext.value) {
+ if (preview) {
+ alert('<fmt:message key="signupload.nofreetext.preview"/>');
+ } else {
+ alert('<fmt:message key="signupload.nofreetext"/>');
+ }
+ return(false);
}
- return(false);
}
if (preview) {
submitform.<%= FormFields.FIELD_PREVIEW %>.value='true';
@@ -118,6 +136,21 @@
}
}
session.setAttribute(UpdateFormServlet.UPLOADFORM_SIGNATURE_TYPE_KEY, type);
+
+ // source
+ String source = (String) session.getAttribute(UpdateFormServlet.UPLOADFORM_SOURCE_KEY);
+ if (source == null) {
+ source = FormFields.VALUE_SOURCE_FILE;
+ }
+ session.setAttribute(UpdateFormServlet.UPLOADFORM_SOURCE_KEY, source);
+ boolean freeText = FormFields.VALUE_SOURCE_FREETEXT.equals(source);
+
+ // freetext
+ String freeTextValue = (String) session.getAttribute(UpdateFormServlet.UPLOADFORM_FREETEXT_KEY);
+ if (freeTextValue == null) {
+ freeTextValue = "";
+ }
+ session.setAttribute(UpdateFormServlet.UPLOADFORM_FREETEXT_KEY, freeTextValue);
%>
</head>
@@ -131,13 +164,29 @@
<fmt:message key="common.title"/>
<% } // end if %>
</h1>
-<h2 align="left"><fmt:message key="signupload.heading2"/></h2>
-<div class="pdfasnote"><fmt:message key="signupload.selectfilenote"/></div>
-<form name="updateform" id="updateform" method="post" action="<%= request.getContextPath() %>/UpdateForm">
+<h2 align="left">
+ <% if (freeText) { %>
+ <fmt:message key="signupload.heading2.freetext"/>
+ <% } else { %>
+ <fmt:message key="signupload.heading2"/>
+ <% } %>
+</h2>
+<div class="pdfasnote">
+ <% if (freeText) { %>
+ <fmt:message key="signupload.selectfilenote.freetext"/>
+ <% } else { %>
+ <fmt:message key="signupload.selectfilenote"/>
+ <% } %>
+</div>
+<form name="updateform" id="updateform" accept-charset="UTF-8" method="post" action="<%= request.getContextPath() %>/UpdateForm">
<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=""/>
+ <input type="hidden" name="<%= FormFields.FIELD_PDFA_ENABLED %>" value=""/>
+ <input type="hidden" name="<%= FormFields.FIELD_SOURCE %>" value=""/>
+ <% if (freeText) { %>
+ <input type="hidden" name="<%= FormFields.FIELD_FREETEXT %>" value=""/>
+ <% } // end if %>
</form>
<form name="submitform" id="submitform"
enctype="multipart/form-data"
@@ -183,12 +232,31 @@
</select>
</td>
</tr>
+ <!--
<tr>
<td align="left" nowrap="nowrap"><label><fmt:message key="signupload.file"/>:</label></td>
<td align="left"><input size="50" type="file" id="fileupload" name="<%= FormFields.FIELD_UPLOAD %>" accept="application/pdf"/></td>
</tr>
+ -->
+ <tr>
+ <td align="left" nowrap="nowrap" style="vertical-align: top;">
+ <select name="<%= FormFields.FIELD_SOURCE %>" onchange="return updateForm();">
+ <option value="<%= FormFields.VALUE_SOURCE_FILE %>" <%= FormFields.VALUE_SOURCE_FILE.equals(source) ? "selected=\"selected\"" : "" %>><fmt:message key="signupload.file"/></option>
+ <option value="<%= FormFields.VALUE_SOURCE_FREETEXT %>" <%= FormFields.VALUE_SOURCE_FREETEXT.equals(source) ? "selected=\"selected\"" : "" %>><fmt:message key="signupload.freetext"/></option>
+ </select>
+ </td>
+ <td align="left">
+ <% if (freeText) { %>
+ <textarea class="freetext" id="freetext" name="<%= FormFields.FIELD_FREETEXT %>"><%= StringEscapeUtils.escapeHtml(freeTextValue) %></textarea>
+ <% } else { %>
+ <input size="50" type="file" id="fileupload" name="<%= FormFields.FIELD_UPLOAD %>" accept="application/pdf"/>
+ <% } // end if freetext %>
+ </td>
+ </tr>
</table>
- <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>
+ <div class="pdfasnote"><span class="pdfasemphasis">
+ <fmt:message key="signupload.note.prefix"/>:</span> <% if (!freeText) { %><fmt:message key="signupload.note.file"/><% } %> <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" />
diff --git a/src/site/changes.xml b/src/site/changes.xml
index 66d697e..4c19e8b 100644
--- a/src/site/changes.xml
+++ b/src/site/changes.xml
@@ -13,6 +13,22 @@
</release>
-->
+ <release version="3.1.1-snapshot" date="2010-03-16" description="add">
+ <action dev="tknall" type="add">Catching OutOfMemory exceptions, returning appropriate error message/code</action>
+ <action dev="tknall" type="fix">Binary signature: bug concerning indirect pdf objects fixed</action>
+ <action dev="tknall" type="update">Maven2-repository updated</action>
+ <action dev="tknall" type="update">pdfbox/itext projects converted to maven2 projects</action>
+ <action dev="tknall" type="update">pdfbox/itext maven2 artifact renamed and version added (see .pom)</action>
+ <action dev="tknall" type="remove">old pdfbox/itext libraries removed</action>
+ <action dev="tknall" type="add">SignaturePositioning improved (Signature position can be declared by String which is parsed)</action>
+ <action dev="tknall" type="add">Some more error codes (Out of memory, Invalid signature position)</action>
+ <action dev="tknall" type="add">iText utility for creation of pdf files added</action>
+ <action dev="tknall" type="update">ConfigUtils updated (destination of configuration to be extracted can now be chosen)</action>
+ <action dev="tknall" type="update">PDFASUtils updated (more tools)</action>
+ <action dev="tknall" type="add">WebApplication: Freetext pdf creation implemented</action>
+ <action dev="tknall" type="fix">WebApplication: XSS security updates</action>
+ </release>
+
<release version="3.1" date="2010-01-18" description="add">
<action dev="tknall" type="add">Support for PDF signature handler.</action>
<action dev="tknall" type="add">Protection of signed documents against inadvertently modification.</action>
diff --git a/work/cfg/config.properties b/work/cfg/config.properties
index 6967454..1bd86ad 100644
--- a/work/cfg/config.properties
+++ b/work/cfg/config.properties
@@ -113,15 +113,16 @@ moa.verify.TrustProfileID=SecureSignature
sig_obj.type.default=SIGNATURBLOCK_DE
sig_obj.types.AMTSSIGNATURBLOCK_DE=off
sig_obj.types.AMTSSIGNATURBLOCK_EN=off
+sig_obj.types.BAIK_ARCHIV_SIGNATUR=on
+sig_obj.types.BAIK_URKUNDE_SIGNATUR=on
+sig_obj.types.INVISIBLE=on
+sig_obj.types.SIGNATURBLOCK_DE_PDFA=on
sig_obj.types.SIGNATURBLOCK_DE=on
+sig_obj.types.SIGNATURBLOCK_EN_PDFA=on
sig_obj.types.SIGNATURBLOCK_EN=on
sig_obj.types.SIGNATURBLOCK_MINIMAL_DE=on
sig_obj.types.SIGNATURBLOCK_MINIMAL_EN=on
-sig_obj.types.SIGNATURBLOCK_DE_PDFA=on
-sig_obj.types.SIGNATURBLOCK_EN_PDFA=on
-sig_obj.types.INVISIBLE=on
-sig_obj.types.BAIK_ARCHIV_SIGNATUR=on
-sig_obj.types.BAIK_URKUNDE_SIGNATUR=on
+sig_obj.types.SIGNATURBLOCK_MINIMAL_TABLE_DE=on
#############################################
@@ -691,6 +692,36 @@ sig_obj.BAIK_URKUNDE_SIGNATUR.table.info.5=SIG_ALG-cv
sig_obj.BAIK_URKUNDE_SIGNATUR.table.info.6=SIG_KZ-cv
+###################################################################################################
+# PROFIL: minimaler Signaturblock waagrecht mit Tabelle (Deutsch)
+
+sig_obj.SIGNATURBLOCK_MINIMAL_TABLE_DE.description=minimale Standardsignatur mit Tabelle Deutsch
+sig_obj.SIGNATURBLOCK_MINIMAL_TABLE_DE.key.SIG_META=Prüfinformation
+
+sig_obj.SIGNATURBLOCK_MINIMAL_TABLE_DE.value.SIG_META=Informationen zur Prüfung der elektronischen Signatur und des Ausdrucks finden Sie unter:\nhttp://www.signaturpruefung.gv.at
+sig_obj.SIGNATURBLOCK_MINIMAL_TABLE_DE.value.SIG_LABEL=./images/signatur-logo_de.png
+
+sig_obj.SIGNATURBLOCK_MINIMAL_TABLE_DE.pos=w:300.0;f:80
+sig_obj.SIGNATURBLOCK_MINIMAL_TABLE_DE.adobeSignFieldValue=PDF-AS Signatur
+sig_obj.SIGNATURBLOCK_MINIMAL_TABLE_DE.adobeSignReasonValue=Informationen zur Prüfung finden Sie unter http://www.signaturpruefung.gv.at
+sig_obj.SIGNATURBLOCK_MINIMAL_TABLE_DE.verifyURL=http://www.signaturpruefung.gv.at
+
+#---------------------- MAIN TABLE -------------------------
+sig_obj.SIGNATURBLOCK_MINIMAL_TABLE_DE.table.main.1=SIG_LABEL-i|SIG_META-v
+
+sig_obj.SIGNATURBLOCK_MINIMAL_TABLE_DE.table.main.ColsWidth=1 3
+sig_obj.SIGNATURBLOCK_MINIMAL_TABLE_DE.table.main.Style.bgcolor=255 255 255
+sig_obj.SIGNATURBLOCK_MINIMAL_TABLE_DE.table.main.Style.padding=8
+sig_obj.SIGNATURBLOCK_MINIMAL_TABLE_DE.table.main.Style.border=0.1
+sig_obj.SIGNATURBLOCK_MINIMAL_TABLE_DE.table.main.Style.halign=left
+sig_obj.SIGNATURBLOCK_MINIMAL_TABLE_DE.table.main.Style.valign=middle
+sig_obj.SIGNATURBLOCK_MINIMAL_TABLE_DE.table.main.Style.font=HELVETICA,10,NORMAL
+sig_obj.SIGNATURBLOCK_MINIMAL_TABLE_DE.table.main.Style.valuefont=HELVETICA,10,NORMAL
+
+# scaling of image (in pdf units)
+sig_obj.SIGNATURBLOCK_MINIMAL_TABLE_DE.table.main.Style.imagescaletofit=65.0;65.0
+
+
#############################################