aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper
diff options
context:
space:
mode:
authorAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2015-03-20 13:55:15 +0100
committerAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2015-03-20 13:55:15 +0100
commit0b46b0b5cbdbdcf11859365891cff57e227eff1c (patch)
tree6791a27626328be33abd2b2d6d3d023ba277b183 /pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper
parentfdac75e81499c11dbb0273292af89faee3297051 (diff)
downloadpdf-as-4-0b46b0b5cbdbdcf11859365891cff57e227eff1c.tar.gz
pdf-as-4-0b46b0b5cbdbdcf11859365891cff57e227eff1c.tar.bz2
pdf-as-4-0b46b0b5cbdbdcf11859365891cff57e227eff1c.zip
added KeyIdentifier selection for MOA via PDF-AS-WEB
Diffstat (limited to 'pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper')
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java44
1 files changed, 41 insertions, 3 deletions
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java
index 2e337f04..b1dd3831 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java
@@ -61,6 +61,7 @@ import at.gv.egiz.pdfas.api.ws.PDFASVerificationResponse;
import at.gv.egiz.pdfas.common.exceptions.PDFASError;
import at.gv.egiz.pdfas.lib.api.ByteArrayDataSource;
import at.gv.egiz.pdfas.lib.api.Configuration;
+import at.gv.egiz.pdfas.lib.api.IConfigurationConstants;
import at.gv.egiz.pdfas.lib.api.PdfAs;
import at.gv.egiz.pdfas.lib.api.PdfAsFactory;
import at.gv.egiz.pdfas.lib.api.StatusRequest;
@@ -375,6 +376,27 @@ public class PdfAsHelper {
IPlainSigner signer;
if (connector.equals("moa")) {
+
+ String keyIdentifier = PdfAsParameterExtractor.getKeyIdentifier(request);
+
+ if (keyIdentifier != null) {
+ if(!WebConfiguration.isMoaEnabled(keyIdentifier)) {
+ throw new PdfAsWebException("MOA connector [" + keyIdentifier + "] disabled or not existing.");
+ }
+
+ String url = WebConfiguration.getMoaURL(keyIdentifier);
+ String keyId = WebConfiguration.getMoaKeyID(keyIdentifier);
+ String certificate = WebConfiguration.getMoaCertificate(keyIdentifier);
+
+ config.setValue(IConfigurationConstants.MOA_SIGN_URL, url);
+ config.setValue(IConfigurationConstants.MOA_SIGN_KEY_ID, keyId);
+ config.setValue(IConfigurationConstants.MOA_SIGN_CERTIFICATE, certificate);
+ } else {
+ if (!WebConfiguration.getMOASSEnabled()) {
+ throw new PdfAsWebException("MOA connector disabled.");
+ }
+ }
+
signer = new PAdESSigner(new MOAConnector(config));
} else if (connector.equals("jks")) {
@@ -491,10 +513,26 @@ public class PdfAsHelper {
IPlainSigner signer;
if (params.getConnector().equals(Connector.MOA)) {
- if (!WebConfiguration.getMOASSEnabled()) {
- throw new PdfAsWebException("MOA connector disabled.");
- }
+ String keyIdentifier = params.getKeyIdentifier();
+ if (keyIdentifier != null) {
+ if(!WebConfiguration.isMoaEnabled(keyIdentifier)) {
+ throw new PdfAsWebException("MOA connector [" + keyIdentifier + "] disabled or not existing.");
+ }
+
+ String url = WebConfiguration.getMoaURL(keyIdentifier);
+ String keyId = WebConfiguration.getMoaKeyID(keyIdentifier);
+ String certificate = WebConfiguration.getMoaCertificate(keyIdentifier);
+
+ config.setValue(IConfigurationConstants.MOA_SIGN_URL, url);
+ config.setValue(IConfigurationConstants.MOA_SIGN_KEY_ID, keyId);
+ config.setValue(IConfigurationConstants.MOA_SIGN_CERTIFICATE, certificate);
+ } else {
+ if (!WebConfiguration.getMOASSEnabled()) {
+ throw new PdfAsWebException("MOA connector disabled.");
+ }
+ }
+
signer = new PAdESSigner(new MOAConnector(config));
} else if (params.getConnector().equals(Connector.JKS)) {
String keyIdentifier = params.getKeyIdentifier();