diff options
author | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2014-06-05 10:46:34 +0200 |
---|---|---|
committer | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2014-06-05 10:46:34 +0200 |
commit | 6ea2c1db26260c1f36e01c58fc6f8ef0220e577e (patch) | |
tree | 79fc40a581daa9269d9cd140bebef24fac475b56 /pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets | |
parent | 531124af765490a63c3a1121ba81fed21c6d7ab4 (diff) | |
download | pdf-as-4-6ea2c1db26260c1f36e01c58fc6f8ef0220e577e.tar.gz pdf-as-4-6ea2c1db26260c1f36e01c58fc6f8ef0220e577e.tar.bz2 pdf-as-4-6ea2c1db26260c1f36e01c58fc6f8ef0220e577e.zip |
SOAP Service for backend upload + transaction ID fixes
Diffstat (limited to 'pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets')
-rw-r--r-- | pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java | 4 | ||||
-rw-r--r-- | pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/UIEntryPointServlet.java | 117 |
2 files changed, 120 insertions, 1 deletions
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 153a69fe..a7d82c3e 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 @@ -238,6 +238,8 @@ public class ExternSignServlet extends HttpServlet { HttpServletResponse response, byte[] pdfData) throws Exception { // Get Connector String connector = PdfAsParameterExtractor.getConnector(request); + + String transactionId = PdfAsParameterExtractor.getTransactionId(request); String invokeUrl = PdfAsParameterExtractor.getInvokeURL(request); PdfAsHelper.setInvokeURL(request, response, invokeUrl); @@ -278,7 +280,7 @@ public class ExternSignServlet extends HttpServlet { } } - PdfAsHelper.startSignature(request, response, getServletContext(), pdfData); + PdfAsHelper.startSignature(request, response, getServletContext(), pdfData, connector, transactionId); } else if (connector.equals("jks") || connector.equals("moa")) { // start synchronous siganture creation diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/UIEntryPointServlet.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/UIEntryPointServlet.java new file mode 100644 index 00000000..3aad5abb --- /dev/null +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/UIEntryPointServlet.java @@ -0,0 +1,117 @@ +package at.gv.egiz.pdfas.web.servlets; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.http.HttpStatus; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.gv.egiz.pdfas.api.ws.PDFASSignRequest; +import at.gv.egiz.pdfas.api.ws.PDFASSignParameters.Connector; +import at.gv.egiz.pdfas.common.exceptions.PdfAsException; +import at.gv.egiz.pdfas.web.config.WebConfiguration; +import at.gv.egiz.pdfas.web.exception.PdfAsStoreException; +import at.gv.egiz.pdfas.web.exception.PdfAsWebException; +import at.gv.egiz.pdfas.web.helper.DigestHelper; +import at.gv.egiz.pdfas.web.helper.PdfAsHelper; +import at.gv.egiz.pdfas.web.helper.PdfAsParameterExtractor; +import at.gv.egiz.pdfas.web.store.RequestStore; + +public class UIEntryPointServlet extends HttpServlet { + private static final long serialVersionUID = 1L; + + public static final String REQUEST_ID_PARAM = "reqId"; + + private static final Logger logger = LoggerFactory + .getLogger(UIEntryPointServlet.class); + + public UIEntryPointServlet() { + } + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { + doProcess(req, resp); + } + + @Override + protected void doPost(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { + doProcess(req, resp); + } + + protected void doProcess(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { + try { + String storeId = req.getParameter(REQUEST_ID_PARAM); + + if (storeId == null) { + throw new PdfAsStoreException("Wrong Parameters"); + } + + PDFASSignRequest pdfAsRequest = RequestStore.getInstance() + .fetchStoreEntry(storeId); + + if(pdfAsRequest == null) { + throw new PdfAsStoreException("Invalid " + REQUEST_ID_PARAM + " value"); + } + + Connector connector = pdfAsRequest.getParameters().getConnector(); + + String invokeUrl = pdfAsRequest.getParameters().getInvokeURL(); + PdfAsHelper.setInvokeURL(req, resp, invokeUrl); + + String errorUrl = pdfAsRequest.getParameters().getInvokeErrorURL(); + PdfAsHelper.setErrorURL(req, resp, errorUrl); + + if(pdfAsRequest.getInputData() == null) { + throw new PdfAsException("No Signature data available"); + } + + String pdfDataHash = DigestHelper.getHexEncodedHash(pdfAsRequest.getInputData()); + + PdfAsHelper.setSignatureDataHash(req, pdfDataHash); + logger.debug("Storing signatures data hash: " + pdfDataHash); + + logger.debug("Starting signature creation with: " + connector); + + //IPlainSigner signer; + if (connector.equals(Connector.BKU) || connector.equals(Connector.ONLINEBKU) || connector.equals(Connector.MOBILEBKU)) { + // start asynchronous signature creation + + if(connector.equals(Connector.BKU)) { + if(WebConfiguration.getLocalBKUURL() == null) { + throw new PdfAsWebException("Invalid connector bku is not supported"); + } + } + + if(connector.equals(Connector.ONLINEBKU)) { + if(WebConfiguration.getLocalBKUURL() == null) { + throw new PdfAsWebException("Invalid connector onlinebku is not supported"); + } + } + + if(connector.equals(Connector.MOBILEBKU)) { + if(WebConfiguration.getLocalBKUURL() == null) { + throw new PdfAsWebException("Invalid connector mobilebku is not supported"); + } + } + + PdfAsHelper.startSignature(req, resp, getServletContext(), pdfAsRequest.getInputData(), + connector.toString(), pdfAsRequest.getParameters().getTransactionId()); + } else { + throw new PdfAsWebException("Invalid connector (" + Connector.BKU + " | " + Connector.ONLINEBKU + " | " + Connector.MOBILEBKU + ")"); + } + + + } catch (Throwable e) { + PdfAsHelper.setSessionException(req, resp, e.getMessage(), e); + PdfAsHelper.gotoError(getServletContext(), req, resp); + } + } +} |