aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwprinz <wprinz@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2009-01-29 13:47:42 +0000
committerwprinz <wprinz@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2009-01-29 13:47:42 +0000
commit1ed2786b85d6f7dac5c83a1ba0474b7f33fa237c (patch)
tree6eaed3c4665508fd7da4eb035467d667523f392f
parent4bf06456b7fb2613d962aec705d77844512af09a (diff)
downloadpdf-as-3-1ed2786b85d6f7dac5c83a1ba0474b7f33fa237c.tar.gz
pdf-as-3-1ed2786b85d6f7dac5c83a1ba0474b7f33fa237c.tar.bz2
pdf-as-3-1ed2786b85d6f7dac5c83a1ba0474b7f33fa237c.zip
api signatureKeyIdentifier override added, brz distribution assembly for maven, mime-type argument checking in SignResult constructor fixedREL-3.0.9-20090129-rev322@329
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@322 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
-rw-r--r--pom.xml9
-rw-r--r--src/main/assembly/assemble_distribution_brz.xml44
-rw-r--r--src/main/distribution/pdf-as.bat1
-rw-r--r--src/main/java/at/gv/egiz/pdfas/api/sign/SignParameters.java48
-rw-r--r--src/main/java/at/gv/egiz/pdfas/framework/ConnectorParameters.java22
-rw-r--r--src/main/java/at/gv/egiz/pdfas/impl/api/CheckHelper.java9
-rw-r--r--src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java3
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java5
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/commandline/Main.java2
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/framework/SignResult.java2
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/EnvelopingBase64MOAConnector.java13
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/MOASoapWithAttachmentConnector.java13
-rw-r--r--src/site/changes.xml6
13 files changed, 160 insertions, 17 deletions
diff --git a/pom.xml b/pom.xml
index 5943617..de615c5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
<groupId>knowcenter</groupId>
<artifactId>pdf-as</artifactId>
<name>PDF-AS</name>
- <version>3.0.8-20090113</version>
+ <version>3.0.9-20090129</version>
<!-- don't forget to set the version string at.knowcenter.wag.egov.egiz.PdfAS.PDFAS_VERSION accordingly -->
<description>Amtssignatur fuer elektronische Aktenfuehrung</description>
@@ -32,8 +32,8 @@
<developer>
<id>wprinz</id>
<name>Wolfgang Prinz</name>
- <email>wprinz@iicm.edu</email>
- <organization>KnowCenter</organization>
+ <email>w.prinz@netconomy.net</email>
+ <organization>Netconomy</organization>
<roles>
<role>developer</role>
</roles>
@@ -129,8 +129,9 @@
<descriptor>src/main/assembly/assemble_libraries.xml</descriptor>
<descriptor>src/main/assembly/assemble_distribution_ws.xml</descriptor>
<descriptor>src/main/assembly/assemble_repository.xml</descriptor>
- -->
<descriptor>src/main/assembly/assemble_repository.xml</descriptor>
+ -->
+ <descriptor>src/main/assembly/assemble_distribution_brz.xml</descriptor>
</descriptors>
</configuration>
</plugin>
diff --git a/src/main/assembly/assemble_distribution_brz.xml b/src/main/assembly/assemble_distribution_brz.xml
new file mode 100644
index 0000000..ca31425
--- /dev/null
+++ b/src/main/assembly/assemble_distribution_brz.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <!-- http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html -->
+<assembly xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/assembly-1.0.0.xsd">
+ <id>distribution_brz</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+ <includeBaseDirectory>true</includeBaseDirectory>
+
+ <dependencySets>
+ <dependencySet>
+ <unpack>false</unpack>
+ <scope>runtime</scope>
+ <outputDirectory>lib</outputDirectory>
+ <excludes>
+ <exclude>*:${project.artifactId}:jar</exclude>
+ </excludes>
+ </dependencySet>
+ </dependencySets>
+
+ <files>
+ <file>
+ <source>src/main/distribution/pdf-as.bat</source>
+ <outputDirectory />
+ <filtered>true</filtered>
+ </file>
+ </files>
+ <fileSets>
+ <fileSet>
+ <directory>target</directory>
+ <outputDirectory />
+ <includes>
+ <include>${project.build.finalName}.jar</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>dok</directory>
+ <outputDirectory>doc</outputDirectory>
+ <includes>
+ <include>*.pdf</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+</assembly>
diff --git a/src/main/distribution/pdf-as.bat b/src/main/distribution/pdf-as.bat
new file mode 100644
index 0000000..4f9d641
--- /dev/null
+++ b/src/main/distribution/pdf-as.bat
@@ -0,0 +1 @@
+java -Dpdf-as.work-dir=. -jar ${project.build.finalName}.jar %* \ No newline at end of file
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.
* </p>
*/
- 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.
+ *
+ * <p>
+ * 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).
+ * </p>
+ * <p>
+ * Note that not all signature devices may support this parameter.
+ * If a signature device doesn't support this parameter the value should be null.
+ * </p>
+ * <p>
+ * This key is usually passed straight through to the signature device and
+ * thereby has to contain an appropriate value for the signature device
+ * chosen.
+ * </p>
+ * <p>
+ * 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.
+ * </p>
+ */
+ 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
@@ -28,6 +28,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.
+ *
+ * <p>
+ * 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.
+ * </p>
+ */
+ 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
);
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 3824a98..302e8cb 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java
@@ -96,7 +96,7 @@ public abstract class PdfAS
* The current version of the pdf-as library. This version string is logged on every invocation
* of the api or the web application.
*/
- public static final String PDFAS_VERSION = "3.0.8-20090113";
+ public static final String PDFAS_VERSION = "3.0.9-20090129";
/**
* The key of the strict mode setting.
@@ -1033,12 +1033,13 @@ public abstract class PdfAS
// signCommandline(pdfDataSource, dataSink, signatorId, connectorId, profile, pos);
// }
- public static SignatorInformation signCommandline(PdfDataSource pdfDataSource, DataSink dataSink, PdfASID signatorId, String connectorId, final String profile, TablePos pos) throws PresentableException
+ public static SignatorInformation signCommandline(PdfDataSource pdfDataSource, DataSink dataSink, PdfASID signatorId, String connectorId, final String profile, final String signatureKeyIdentifier, TablePos pos) throws PresentableException
{
at.gv.egiz.pdfas.framework.signator.Signator signator = at.gv.egiz.pdfas.framework.SignatorFactory.createSignator(signatorId);
ConnectorParameters cp = new ConnectorParameters();
cp.setProfileId(profile);
+ cp.setSignatureKeyIdentifier(signatureKeyIdentifier);
Connector c = at.gv.egiz.pdfas.framework.ConnectorFactory.createConnector(connectorId, cp);
// SignatorInformation si = signator.prepareSign(pdfDataSource, profile, pos, ConnectorFactory.needsSIG_ID(connector));
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/commandline/Main.java b/src/main/java/at/knowcenter/wag/egov/egiz/commandline/Main.java
index 9e45469..577d05f 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/commandline/Main.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/commandline/Main.java
@@ -612,7 +612,7 @@ public abstract class Main
String connectorId = CommandlineConnectorChooser.chooseCommandlineConnectorForSign(connector);
- PdfAS.signCommandline(pdfDataSource, dataSink, signatorId, connectorId, signature_type, pos);
+ PdfAS.signCommandline(pdfDataSource, dataSink, signatorId, connectorId, signature_type, null, pos);
// PdfAS.sign(algorithm, pdfDataSource, dataSink, signature_type, connector, pos);
}
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/framework/SignResult.java b/src/main/java/at/knowcenter/wag/egov/egiz/framework/SignResult.java
index c7dfcdb..05beac0 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/framework/SignResult.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/framework/SignResult.java
@@ -52,7 +52,7 @@ public class SignResult implements Serializable
*/
public SignResult(String document_mime_type, byte[] document_data)
{
- if (document_mime_type == null && document_mime_type.length() == 0)
+ if (document_mime_type == null || document_mime_type.length() == 0)
{
throw new IllegalArgumentException("Please provide a valid Mime Type for the SignResult. " + document_mime_type);
}
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/EnvelopingBase64MOAConnector.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/EnvelopingBase64MOAConnector.java
index 7d58d79..a6db63c 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/EnvelopingBase64MOAConnector.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/EnvelopingBase64MOAConnector.java
@@ -63,7 +63,7 @@ public class EnvelopingBase64MOAConnector implements Connector
public EnvelopingBase64MOAConnector(ConnectorParameters connectorParameters) throws ConnectorException
{
this.params = connectorParameters;
- this.environment = new Environment(connectorParameters.getProfileId());
+ this.environment = new Environment(connectorParameters.getProfileId(), connectorParameters.getSignatureKeyIdentifier());
}
/**
@@ -419,7 +419,7 @@ public class EnvelopingBase64MOAConnector implements Connector
* @throws ConnectorException
* f.e.
*/
- public Environment(String profile) throws ConnectorException
+ public Environment(String profile, String signKeyIdentifier) throws ConnectorException
{
this.profile = profile;
@@ -433,7 +433,14 @@ public class EnvelopingBase64MOAConnector implements Connector
throw new ConnectorException(300, e);
}
- this.sign_key_identifier = getConnectorValueFromProfile(settings, profile, SIGN_KEY_IDENTIFIER_KEY);
+ if (signKeyIdentifier != null)
+ {
+ this.sign_key_identifier = signKeyIdentifier;
+ }
+ else
+ {
+ this.sign_key_identifier = getConnectorValueFromProfile(settings, profile, SIGN_KEY_IDENTIFIER_KEY);
+ }
String sign_request_filename = getConnectorValueFromProfile(settings, profile, SIGN_REQUEST_TEMPLATE_KEY);
this.sign_request_template = FileHelper.readFromFile(SettingsReader.relocateFile(sign_request_filename));
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/MOASoapWithAttachmentConnector.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/MOASoapWithAttachmentConnector.java
index b45303d..7776698 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/MOASoapWithAttachmentConnector.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/MOASoapWithAttachmentConnector.java
@@ -77,7 +77,7 @@ public class MOASoapWithAttachmentConnector implements Connector
public MOASoapWithAttachmentConnector(ConnectorParameters connectorParameters) throws ConnectorException
{
this.params = connectorParameters;
- this.environment = new Environment(this.params.getProfileId(), MULTIPART_LOC_REF_CONTENT);
+ this.environment = new Environment(this.params.getProfileId(), this.params.getSignatureKeyIdentifier(), MULTIPART_LOC_REF_CONTENT);
}
protected String prepareSignRequest(SignatureData data) throws ConnectorException
@@ -445,7 +445,7 @@ public class MOASoapWithAttachmentConnector implements Connector
* @throws ConnectorException
* f.e.
*/
- public Environment(String profile, String signature_data_url) throws ConnectorException
+ public Environment(String profile, String signKeyIdentifier, String signature_data_url) throws ConnectorException
{
this.profile = profile;
@@ -461,7 +461,14 @@ public class MOASoapWithAttachmentConnector implements Connector
throw new ConnectorException(300, e);
}
- this.sign_key_identifier = getConnectorValueFromProfile(settings, profile, SIGN_KEY_IDENTIFIER_KEY);
+ if (signKeyIdentifier != null)
+ {
+ this.sign_key_identifier = signKeyIdentifier;
+ }
+ else
+ {
+ this.sign_key_identifier = getConnectorValueFromProfile(settings, profile, SIGN_KEY_IDENTIFIER_KEY);
+ }
String sign_request_filename = TEMPLATE_FILE_PREFIX + settings.getValueFromKey("default.moa.algorithm.id") + SIGN_TEMPLATE_FILE_SUFIX;
diff --git a/src/site/changes.xml b/src/site/changes.xml
index 50f3c54..347cbae 100644
--- a/src/site/changes.xml
+++ b/src/site/changes.xml
@@ -13,6 +13,12 @@
</release>
-->
+ <release version="3.0.9-20090129" date="2009-01-29" description="BRZ release">
+ <action dev="wprinz" type="add">Added signatureKeyIdentifier to SignParameters in the API, which allows to override the one specified in the profile (MOA Connector only).</action>
+ <action dev="wprinz" type="add">Added maven assembly and batch file for BRZ distribution.</action>
+ <action dev="wprinz" type="fix">Corrected faulty mime-type argument checking in SignResult constructor.</action>
+ </release>
+
<release version="3.0.8-20090113" date="2009-01-13" description="subsequent release">
<action dev="tknall" type="update">Switching to itext-2.1.5-rev3628.</action>
<action dev="gfliess" type="update">itext library: minor adjustments for pdf-as</action>