From 1ed2786b85d6f7dac5c83a1ba0474b7f33fa237c Mon Sep 17 00:00:00 2001 From: wprinz Date: Thu, 29 Jan 2009 13:47:42 +0000 Subject: api signatureKeyIdentifier override added, brz distribution assembly for maven, mime-type argument checking in SignResult constructor fixed git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@322 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../at/gv/egiz/pdfas/api/sign/SignParameters.java | 48 +++++++++++++++++++++- .../egiz/pdfas/framework/ConnectorParameters.java | 22 ++++++++++ .../at/gv/egiz/pdfas/impl/api/CheckHelper.java | 9 ++++ .../at/gv/egiz/pdfas/impl/api/PdfAsObject.java | 3 +- 4 files changed, 79 insertions(+), 3 deletions(-) (limited to 'src/main/java/at/gv/egiz/pdfas') diff --git a/src/main/java/at/gv/egiz/pdfas/api/sign/SignParameters.java b/src/main/java/at/gv/egiz/pdfas/api/sign/SignParameters.java index cc59cbd..54de38d 100644 --- a/src/main/java/at/gv/egiz/pdfas/api/sign/SignParameters.java +++ b/src/main/java/at/gv/egiz/pdfas/api/sign/SignParameters.java @@ -55,7 +55,36 @@ public class SignParameters * profile here instead of the profile id. *

*/ - protected String signatureProfileId = null;; + protected String signatureProfileId = null; + + /** + * The signature key identifier specifying which signature key should be used + * by the signature device to perform the signature. + * + *

+ * Providing a null value (default) means that no explicit signature key + * identifier is provided. The selected signature device will then use its + * default mechanism for retrieving this information (which is usually to read + * the key from the provided signature profile). + *

+ *

+ * Note that not all signature devices may support this parameter. + * If a signature device doesn't support this parameter the value should be null. + *

+ *

+ * This key is usually passed straight through to the signature device and + * thereby has to contain an appropriate value for the signature device + * chosen. + *

+ *

+ * Currently, only the {@link Constants#SIGNATURE_DEVICE_MOA} signature device + * evaluates this parameter and passes the provided String to MOA as the MOA + * key group identifier. If null is provided, the MOA signature device will + * determine the signature key identifier to be used from the provided profile + * and, if not specified there either, from the MOA default configuration. + *

+ */ + protected String signatureKeyIdentifier = null; /** * The signature position. Consult the PDF-AS documentation section @@ -170,4 +199,21 @@ public class SignParameters this.output = output; } + /** + * @return the signatureKeyIdentifier + */ + public String getSignatureKeyIdentifier() + { + return this.signatureKeyIdentifier; + } + + /** + * @param signatureKeyIdentifier the signatureKeyIdentifier to set + */ + public void setSignatureKeyIdentifier(String signatureKeyIdentifier) + { + this.signatureKeyIdentifier = signatureKeyIdentifier; + } + + } diff --git a/src/main/java/at/gv/egiz/pdfas/framework/ConnectorParameters.java b/src/main/java/at/gv/egiz/pdfas/framework/ConnectorParameters.java index 618624d..a7c5d7a 100644 --- a/src/main/java/at/gv/egiz/pdfas/framework/ConnectorParameters.java +++ b/src/main/java/at/gv/egiz/pdfas/framework/ConnectorParameters.java @@ -27,6 +27,18 @@ public class ConnectorParameters */ protected String profileId = null; + /** + * The signature key identifier to be used or null if it should be read from + * the profile. + * + *

+ * Currently this is only used by MOA connectors and identifies the MOA key + * group to be used when signing. If null, the MOA connector reads the key + * from the profile. + *

+ */ + protected String signatureKeyIdentifier = null; + /** * Tells, if the connector should ask the device to return the hash input * data. @@ -61,6 +73,16 @@ public class ConnectorParameters { this.profileId = profileId; } + + public String getSignatureKeyIdentifier() + { + return this.signatureKeyIdentifier; + } + + public void setSignatureKeyIdentifier(String signatureKeyIdentifier) + { + this.signatureKeyIdentifier = signatureKeyIdentifier; + } public boolean isReturnHashInputData() { diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/CheckHelper.java b/src/main/java/at/gv/egiz/pdfas/impl/api/CheckHelper.java index 9daae59..4466d8b 100644 --- a/src/main/java/at/gv/egiz/pdfas/impl/api/CheckHelper.java +++ b/src/main/java/at/gv/egiz/pdfas/impl/api/CheckHelper.java @@ -67,6 +67,7 @@ public final class CheckHelper { checkSignaturePositioning(sp.getSignaturePositioning()); } + checkSignatureKeyIdentifier(sp.getSignatureKeyIdentifier(), sp.getSignatureDevice()); } /** @@ -186,6 +187,14 @@ public final class CheckHelper throw new IllegalArgumentException(msg); } } + + protected static void checkSignatureKeyIdentifier (String signatureKeyIdentifier, String signatureDevice) + { + if (signatureKeyIdentifier != null && !Constants.SIGNATURE_DEVICE_MOA.equals(signatureDevice)) + { + log.warn("A signatureKeyIdentifier (" + signatureKeyIdentifier + ") was provided although the signatureDevice (" + signatureDevice + ") is not moa. Currently only the moa signature device evaluates the signatureKeyIdentifier parameter."); + } + } protected static void checkVerifyMode(String verifyMode) { 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 40da270..46157e3 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 @@ -14,7 +14,6 @@ import java.util.Vector; import org.apache.commons.lang.math.NumberUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.log4j.PropertyConfigurator; import at.gv.egiz.pdfas.api.PdfAs; import at.gv.egiz.pdfas.api.analyze.AnalyzeParameters; @@ -30,7 +29,6 @@ import at.gv.egiz.pdfas.api.verify.VerifyResult; import at.gv.egiz.pdfas.api.verify.VerifyResults; import at.gv.egiz.pdfas.commandline.CommandlineConnectorChooser; import at.gv.egiz.pdfas.exceptions.ErrorCode; -import at.gv.egiz.pdfas.framework.ConnectorFactory; import at.gv.egiz.pdfas.framework.config.SettingsHelper; import at.gv.egiz.pdfas.framework.input.ExtractionStage; import at.gv.egiz.pdfas.framework.signator.SignatorInformation; @@ -244,6 +242,7 @@ public class PdfAsObject implements PdfAs signatorId, connectorId, signParameters.getSignatureProfileId(), + signParameters.getSignatureKeyIdentifier(), pos ); -- cgit v1.2.3