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 --- src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java | 5 +++-- .../java/at/knowcenter/wag/egov/egiz/commandline/Main.java | 2 +- .../at/knowcenter/wag/egov/egiz/framework/SignResult.java | 2 +- .../sig/connectors/moa/EnvelopingBase64MOAConnector.java | 13 ++++++++++--- .../sig/connectors/moa/MOASoapWithAttachmentConnector.java | 13 ++++++++++--- 5 files changed, 25 insertions(+), 10 deletions(-) (limited to 'src/main/java/at/knowcenter') 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; -- cgit v1.2.3