diff options
5 files changed, 52 insertions, 19 deletions
diff --git a/pdf-as-cli/src/main/java/at/gv/egiz/pdfas/cli/Main.java b/pdf-as-cli/src/main/java/at/gv/egiz/pdfas/cli/Main.java index 62efe965..076d3ff3 100644 --- a/pdf-as-cli/src/main/java/at/gv/egiz/pdfas/cli/Main.java +++ b/pdf-as-cli/src/main/java/at/gv/egiz/pdfas/cli/Main.java @@ -100,7 +100,7 @@ public class Main { Option connectorOption = new Option(CLI_ARG_CONNECTOR_SHORT, CLI_ARG_CONNECTOR, true, - "Connector to use (bku | ks (Keystore) | moa(not available yet))"); + "Connector to use (bku | ks (Keystore) | moa)"); cliOptions.addOption(connectorOption); Option keystoreFileOption = new Option(CLI_ARG_KEYSTORE_FILE_SHORT, diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/MOAConnector.java b/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/MOAConnector.java index 61b11d29..bd8f5d8d 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/MOAConnector.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/MOAConnector.java @@ -7,23 +7,19 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; -import java.io.InputStream; import java.io.InputStreamReader; import java.io.StringReader; import java.security.cert.CertificateException; -import javax.activation.DataHandler; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; -import org.apache.axis2.databinding.types.Token; import org.apache.commons.codec.binary.Base64; import org.apache.http.HttpResponse; import org.apache.http.client.entity.EntityBuilder; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ContentType; -import org.apache.http.entity.mime.MultipartEntityBuilder; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.slf4j.Logger; @@ -34,22 +30,8 @@ import org.w3c.dom.NodeList; import org.xml.sax.InputSource; import org.xml.sax.SAXException; -import at.gv.egiz.moa.ByteArrayDataSource; -import at.gv.egiz.moa.SignatureCreationServiceStub; -import at.gv.egiz.moa.SignatureCreationServiceStub.CMSContentBaseType; -import at.gv.egiz.moa.SignatureCreationServiceStub.CreateCMSSignatureRequest; -import at.gv.egiz.moa.SignatureCreationServiceStub.CreateCMSSignatureResponse; -import at.gv.egiz.moa.SignatureCreationServiceStub.CreateSignatureInfo_type0; -import at.gv.egiz.moa.SignatureCreationServiceStub.DataObjectInfo_type1; -import at.gv.egiz.moa.SignatureCreationServiceStub.DataObject_type1; -import at.gv.egiz.moa.SignatureCreationServiceStub.KeyIdentifierType; -import at.gv.egiz.moa.SignatureCreationServiceStub.MetaInfoType; -import at.gv.egiz.moa.SignatureCreationServiceStub.MimeTypeType; -import at.gv.egiz.moa.SignatureCreationServiceStub.SingleSignatureInfo_type1; -import at.gv.egiz.moa.SignatureCreationServiceStub.Structure_type1; import at.gv.egiz.pdfas.common.exceptions.PdfAsException; import at.gv.egiz.pdfas.common.exceptions.PdfAsMOAException; -import at.gv.egiz.pdfas.common.utils.StreamUtils; import at.gv.egiz.pdfas.lib.api.Configuration; public class MOAConnector implements ISignatureConnector { diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java index c7520347..b978b361 100644 --- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java @@ -20,6 +20,8 @@ public class WebConfiguration { public static final String ERROR_DETAILS = "error.showdetails"; public static final String PDF_AS_WORK_DIR = "pdfas.dir"; + public static final String MOA_SS_ENABLED = "moa.enabled"; + public static final String KEYSTORE_ENABLED = "ks.enabled"; public static final String KEYSTORE_FILE = "ks.file"; public static final String KEYSTORE_TYPE = "ks.type"; @@ -116,6 +118,15 @@ public class WebConfiguration { return properties.getProperty(KEYSTORE_KEY_PASS); } + public static boolean getMOASSEnabled() { + String value = properties.getProperty(MOA_SS_ENABLED); + if(value != null) { + if(value.equals("true")) { + return true; + } + } + return false; + } public static boolean getKeystoreEnabled() { String value = properties.getProperty(KEYSTORE_ENABLED); diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java index dddd80dd..fe26f097 100644 --- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java @@ -235,9 +235,41 @@ public class ExternSignServlet extends HttpServlet { IPlainSigner signer; if (connector.equals("bku") || connector.equals("onlinebku") || connector.equals("mobilebku")) { // start asynchronous signature creation + + if(connector.equals("bku")) { + if(WebConfiguration.getLocalBKUURL() == null) { + throw new PdfAsWebException("Invalid connector bku is not supported"); + } + } + + if(connector.equals("onlinebku")) { + if(WebConfiguration.getLocalBKUURL() == null) { + throw new PdfAsWebException("Invalid connector onlinebku is not supported"); + } + } + + if(connector.equals("mobilebku")) { + if(WebConfiguration.getLocalBKUURL() == null) { + throw new PdfAsWebException("Invalid connector mobilebku is not supported"); + } + } + PdfAsHelper.startSignature(request, response, getServletContext(), pdfData); } else if (connector.equals("jks") || connector.equals("moa")) { // start synchronous siganture creation + + if(connector.equals("jks")) { + if(!WebConfiguration.getKeystoreEnabled()) { + throw new PdfAsWebException("Invalid connector jks is not supported"); + } + } + + if(connector.equals("moa")) { + if(!WebConfiguration.getMOASSEnabled()) { + throw new PdfAsWebException("Invalid connector moa is not supported"); + } + } + byte[] pdfSignedData = PdfAsHelper.synchornousSignature(request, response, pdfData); PdfAsHelper.setSignedPdf(request, response, pdfSignedData); diff --git a/pdf-as-web/src/main/webapp/index.jsp b/pdf-as-web/src/main/webapp/index.jsp index 355c7838..6383f8a3 100644 --- a/pdf-as-web/src/main/webapp/index.jsp +++ b/pdf-as-web/src/main/webapp/index.jsp @@ -51,6 +51,14 @@ <% } %> + <% + if (WebConfiguration.getMOASSEnabled()) { + %> + <button type="submit" value="moa" name="connector" + id="moa">MOA-SS</button> + <% + } + %> </form> </body> </html>
\ No newline at end of file |