aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-lib/src/main/java
diff options
context:
space:
mode:
authorAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-04-10 16:12:47 +0200
committerAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-04-10 16:12:47 +0200
commitaadde85ff54a35bd1007fe8a6aa16cf217607c13 (patch)
treed1fada4a0d8d85c19732056cc443ef971dbf82b8 /pdf-as-lib/src/main/java
parenta221fc3f781244a6e0dce8f1e652a98412c3ee1d (diff)
downloadpdf-as-3-aadde85ff54a35bd1007fe8a6aa16cf217607c13.tar.gz
pdf-as-3-aadde85ff54a35bd1007fe8a6aa16cf217607c13.tar.bz2
pdf-as-3-aadde85ff54a35bd1007fe8a6aa16cf217607c13.zip
Introduce XAdES 1.4 support for Handy Signatur (TODO: configure ID pattern correctly)
Diffstat (limited to 'pdf-as-lib/src/main/java')
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/utils/TempDirHelper.java2
-rw-r--r--pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/DetachedBKUConnector.java7
-rw-r--r--pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/MOASoapWithAttachmentConnector.java7
-rw-r--r--pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/sigkz/SigKZIDHelper.java9
-rw-r--r--pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/signaturelayout/SignatureLayoutHandlerFactory.java5
-rw-r--r--pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/signaturelayout/atrust/ATrustXades14SignatureLayoutHandler.java24
6 files changed, 51 insertions, 3 deletions
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/utils/TempDirHelper.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/utils/TempDirHelper.java
index bccc67b..38ff2d1 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/utils/TempDirHelper.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/utils/TempDirHelper.java
@@ -121,7 +121,7 @@ public class TempDirHelper
boolean delete_success = files[i].delete();
if (!delete_success)
{
- log.error("Couldn't delete the temporary file: " + files[i]);
+ log.debug("Couldn't delete the temporary file: " + files[i]);
}
}
}
diff --git a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/DetachedBKUConnector.java b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/DetachedBKUConnector.java
index 6926d2b..646f2be 100644
--- a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/DetachedBKUConnector.java
+++ b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/DetachedBKUConnector.java
@@ -388,7 +388,12 @@ public class DetachedBKUConnector implements Connector, LocalConnector
MOASoapWithAttachmentConnector moaConn = new MOASoapWithAttachmentConnector(this.params);
moaConn.reInitVerifyTemplate(MOASoapWithAttachmentConnector.ATRUST_VERIFY_TEMPLATE_KEY);
return moaConn.prepareXMLContent(data, so);
- }
+ } else if (SigKZIDHelper.isATrustX14Signed(so)) {
+ log.debug("ATrust Xades 1.4 signature detected");
+ MOASoapWithAttachmentConnector moaConn = new MOASoapWithAttachmentConnector(this.params);
+ moaConn.reInitVerifyTemplate(MOASoapWithAttachmentConnector.ATRUST_XADES_1_4_VERIFY_TEMPLATE_KEY);
+ return moaConn.prepareXMLContent(data, so);
+ }
// TD
else if (SigKZIDHelper.isBKUSigned(so)) {
log.debug("TD signature signature detected.");
diff --git a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/MOASoapWithAttachmentConnector.java b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/MOASoapWithAttachmentConnector.java
index f6f05fc..03c2dda 100644
--- a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/MOASoapWithAttachmentConnector.java
+++ b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/MOASoapWithAttachmentConnector.java
@@ -61,6 +61,7 @@ public class MOASoapWithAttachmentConnector implements Connector
{
//23.11.2010 changed by exthex - added reconstructXMLDsig method and moved xmldsig creation to chooseAndCreateXMLDsig method
public static final String ATRUST_VERIFY_TEMPLATE_KEY = "atrust.verify.template.detached";
+ public static final String ATRUST_XADES_1_4_VERIFY_TEMPLATE_KEY = "atrust.xades14.verify.template.detached";
/**
* The SIG_ID prefix.
@@ -260,7 +261,11 @@ public class MOASoapWithAttachmentConnector implements Connector
log.debug("A-Trust signature detected.");
this.environment.reInitVerifyTemplate(ATRUST_VERIFY_TEMPLATE_KEY);
return prepareXMLContent(data, so);
-
+ } else if (SigKZIDHelper.isATrustX14Signed(so)) {
+ log.debug("ATrust Xades 1.4 signature detected");
+ MOASoapWithAttachmentConnector moaConn = new MOASoapWithAttachmentConnector(this.params);
+ moaConn.reInitVerifyTemplate(MOASoapWithAttachmentConnector.ATRUST_XADES_1_4_VERIFY_TEMPLATE_KEY);
+ return moaConn.prepareXMLContent(data, so);
// TD bku
} else if (SigKZIDHelper.isBKUSigned(so)) {
log.debug("TD bku signature detected.");
diff --git a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/sigkz/SigKZIDHelper.java b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/sigkz/SigKZIDHelper.java
index 03bf931..5a20a30 100644
--- a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/sigkz/SigKZIDHelper.java
+++ b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/sigkz/SigKZIDHelper.java
@@ -43,6 +43,7 @@ import at.knowcenter.wag.egov.egiz.framework.SignatorFactory;
import at.knowcenter.wag.egov.egiz.sig.connectors.bku.SignSignatureObject;
import at.knowcenter.wag.egov.egiz.sig.sigid.DetachedLocRefMOAIdFormatter;
import at.knowcenter.wag.egov.egiz.sig.sigid.HotfixIdFormatter;
+import at.knowcenter.wag.egov.egiz.sig.signaturelayout.atrust.ATrustXades14SignatureLayoutHandler;
/**
* @author wprinz
@@ -246,6 +247,14 @@ public final class SigKZIDHelper
}
return sig_id.startsWith("etsi-bka-atrust-1.0");
}
+
+ public static boolean isATrustX14Signed(SignSignatureObject so) {
+ String sig_id = so.id;
+ if (sig_id == null && StringUtils.isEmpty(sig_id)) {
+ return false;
+ }
+ return sig_id.startsWith(ATrustXades14SignatureLayoutHandler.ETSI_BKA_ATRUST_1_2);
+ }
/**
* Checks if signed with a known BKU method/param
diff --git a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/signaturelayout/SignatureLayoutHandlerFactory.java b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/signaturelayout/SignatureLayoutHandlerFactory.java
index 07a7792..283eb85 100644
--- a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/signaturelayout/SignatureLayoutHandlerFactory.java
+++ b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/signaturelayout/SignatureLayoutHandlerFactory.java
@@ -79,6 +79,9 @@ public class SignatureLayoutHandlerFactory {
if (bkuIdentifier == null) {
throw new SettingsException(ErrorCode.MISSING_HEADER_SERVER_USER_AGENT, "Unable to determine type of citizen card environment. Response header \"Server\" resp. \"user-agent\" is missing. Refer to security layer specification 1.2.2, section 3.3.2.");
}
+
+ log.debug("Trying to get SignatureLayoutHandler for \"" + bkuIdentifier + "\".");
+
SignatureLayoutHandler signatureLayoutHandler = (SignatureLayoutHandler) instances.get(bkuIdentifier);
if (signatureLayoutHandler == null) {
@@ -127,6 +130,8 @@ public class SignatureLayoutHandlerFactory {
log.debug("SignatureLayoutHandler successfully instantiated.");
instances.put(bkuIdentifier, signatureLayoutHandler);
} else {
+ log.debug("SignatureLayoutHandler has already been instantiated. Class: \"" +
+ signatureLayoutHandler.getClass().getName() + "\"");
log.trace("SignatureLayoutHandler has already been instantiated. Returning old instance.");
}
diff --git a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/signaturelayout/atrust/ATrustXades14SignatureLayoutHandler.java b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/signaturelayout/atrust/ATrustXades14SignatureLayoutHandler.java
new file mode 100644
index 0000000..2184a5c
--- /dev/null
+++ b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/signaturelayout/atrust/ATrustXades14SignatureLayoutHandler.java
@@ -0,0 +1,24 @@
+package at.knowcenter.wag.egov.egiz.sig.signaturelayout.atrust;
+
+import at.knowcenter.wag.egov.egiz.exceptions.ConnectorException;
+import at.knowcenter.wag.egov.egiz.sig.connectors.ConnectorEnvironment;
+import at.knowcenter.wag.egov.egiz.sig.connectors.bku.SignSignatureObject;
+import at.knowcenter.wag.egov.egiz.sig.connectors.moa.MOAHelper;
+import at.knowcenter.wag.egov.egiz.sig.connectors.mocca.MOCCAHelper;
+import at.knowcenter.wag.egov.egiz.sig.sigid.DetachedMOCIdFormatter;
+import at.knowcenter.wag.egov.egiz.sig.sigid.SimpleIdFormatter;
+import at.knowcenter.wag.egov.egiz.sig.signaturelayout.SignatureLayoutHandler;
+
+public class ATrustXades14SignatureLayoutHandler implements
+ SignatureLayoutHandler {
+
+ public static final String ETSI_BKA_ATRUST_1_2 = "etsi-bka-atrust-1.2";
+
+ public SignSignatureObject parseCreateXMLSignatureResponse(
+ String xmlResponse, ConnectorEnvironment env)
+ throws ConnectorException {
+ return MOCCAHelper.parseCreateXMLResponse(xmlResponse,
+ new DetachedMOCIdFormatter(ETSI_BKA_ATRUST_1_2), env);
+ }
+
+}