aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-web/src/main/java/at/gv/egiz
diff options
context:
space:
mode:
authorAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-07-21 12:52:45 +0200
committerAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-07-21 12:52:45 +0200
commit34289c5982ffdd59e33576a6b47316a6cfb14201 (patch)
treeae419c87de8c664f3eef32a8540bad0d083a3242 /pdf-as-web/src/main/java/at/gv/egiz
parentea4180c0a643ca741fd8432faf9913706935e4d6 (diff)
downloadpdf-as-4-34289c5982ffdd59e33576a6b47316a6cfb14201.tar.gz
pdf-as-4-34289c5982ffdd59e33576a6b47316a6cfb14201.tar.bz2
pdf-as-4-34289c5982ffdd59e33576a6b47316a6cfb14201.zip
removed imports, added logging information
Diffstat (limited to 'pdf-as-web/src/main/java/at/gv/egiz')
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java3
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/RemotePDFFetcher.java8
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java2
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/UIEntryPointServlet.java108
4 files changed, 70 insertions, 51 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 a5232acf..6b63255f 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
@@ -837,6 +837,7 @@ public class PdfAsHelper {
public static void setErrorURL(HttpServletRequest request,
HttpServletResponse response, String url) {
HttpSession session = request.getSession();
+ logger.debug("[" + session.getId() + "]: Setting Error URL to: " + url);
session.setAttribute(PDF_ERR_URL, url);
}
@@ -850,8 +851,8 @@ public class PdfAsHelper {
public static void setInvokeURL(HttpServletRequest request,
HttpServletResponse response, String url) {
HttpSession session = request.getSession();
+ logger.debug("[" + session.getId() + "]: Setting Invoke URL to: " + url);
session.setAttribute(PDF_INVOKE_URL, url);
- logger.debug("External Invoke URL: " + url);
}
public static String getInvokeURL(HttpServletRequest request,
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/RemotePDFFetcher.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/RemotePDFFetcher.java
index e48a4eee..f3c1c946 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/RemotePDFFetcher.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/RemotePDFFetcher.java
@@ -27,17 +27,24 @@ import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import at.gv.egiz.pdfas.common.utils.StreamUtils;
import at.gv.egiz.pdfas.web.config.WebConfiguration;
import at.gv.egiz.pdfas.web.exception.PdfAsWebException;
public class RemotePDFFetcher {
+ private static final Logger logger = LoggerFactory
+ .getLogger(RemotePDFFetcher.class);
+
public static byte[] fetchPdfFile(String pdfURL) throws PdfAsWebException {
URL url;
try {
url = new URL(pdfURL);
} catch (MalformedURLException e) {
+ logger.error("Not a valid URL!", e);
throw new PdfAsWebException("Not a valid URL!", e);
}
if (WebConfiguration.isProvidePdfURLinWhitelist(url.toExternalForm())) {
@@ -48,6 +55,7 @@ public class RemotePDFFetcher {
InputStream is = url.openStream();
return StreamUtils.inputStreamToByteArray(is);
} catch (Exception e) {
+ logger.error("Failed to fetch pdf document!", e);
throw new PdfAsWebException(
"Failed to fetch pdf document!", e);
}
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 39078529..121fbc88 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
@@ -89,6 +89,7 @@ public class ExternSignServlet extends HttpServlet {
String errorUrl = PdfAsParameterExtractor.getInvokeErrorURL(request);
PdfAsHelper.setErrorURL(request, response, errorUrl);
+
try {
// Mandatory Parameters on Get Request:
String invokeUrl = PdfAsParameterExtractor.getInvokeURL(request);
@@ -296,6 +297,7 @@ public class ExternSignServlet extends HttpServlet {
PdfAsHelper.startSignature(request, response, getServletContext(), pdfData, connector,
PdfAsHelper.buildPosString(request, response), transactionId, PdfAsParameterExtractor
.getSigType(request));
+ return;
} 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
index 85ee1897..544f6c83 100644
--- 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
@@ -30,12 +30,11 @@ 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.api.ws.PDFASSignRequest;
import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
import at.gv.egiz.pdfas.lib.api.verify.VerifyParameter.SignatureVerificationLevel;
import at.gv.egiz.pdfas.web.config.WebConfiguration;
@@ -43,7 +42,6 @@ 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 {
@@ -77,80 +75,90 @@ public class UIEntryPointServlet extends HttpServlet {
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");
+
+ 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 invokeTarget = pdfAsRequest.getParameters().getInvokeTarget();
+
+ String invokeTarget = pdfAsRequest.getParameters()
+ .getInvokeTarget();
PdfAsHelper.setInvokeTarget(req, resp, invokeTarget);
-
+
String errorUrl = pdfAsRequest.getParameters().getInvokeErrorURL();
PdfAsHelper.setErrorURL(req, resp, errorUrl);
-
+
SignatureVerificationLevel lvl = SignatureVerificationLevel.INTEGRITY_ONLY_VERIFICATION;
- if(pdfAsRequest.getVerificationLevel() != null) {
- switch (pdfAsRequest.getVerificationLevel()) {
- case INTEGRITY_ONLY:
- lvl = SignatureVerificationLevel.INTEGRITY_ONLY_VERIFICATION;
- break;
- default:
- lvl = SignatureVerificationLevel.FULL_VERIFICATION;
- break;
- }
+ if (pdfAsRequest.getVerificationLevel() != null) {
+ switch (pdfAsRequest.getVerificationLevel()) {
+ case INTEGRITY_ONLY:
+ lvl = SignatureVerificationLevel.INTEGRITY_ONLY_VERIFICATION;
+ break;
+ default:
+ lvl = SignatureVerificationLevel.FULL_VERIFICATION;
+ break;
+ }
}
PdfAsHelper.setVerificationLevel(req, lvl);
-
- if(pdfAsRequest.getInputData() == null) {
+
+ if (pdfAsRequest.getInputData() == null) {
throw new PdfAsException("No Signature data available");
}
-
- String pdfDataHash = DigestHelper.getHexEncodedHash(pdfAsRequest.getInputData());
-
+
+ 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)) {
+
+ // 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.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.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");
+
+ 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().getPosition(),
- pdfAsRequest.getParameters().getTransactionId(),
+
+ PdfAsHelper.startSignature(req, resp, getServletContext(),
+ pdfAsRequest.getInputData(), connector.toString(),
+ pdfAsRequest.getParameters().getPosition(),
+ pdfAsRequest.getParameters().getTransactionId(),
pdfAsRequest.getParameters().getProfile());
} else {
- throw new PdfAsWebException("Invalid connector (" + Connector.BKU + " | " + Connector.ONLINEBKU + " | " + Connector.MOBILEBKU + ")");
+ throw new PdfAsWebException("Invalid connector ("
+ + Connector.BKU + " | " + Connector.ONLINEBKU + " | "
+ + Connector.MOBILEBKU + ")");
}
-
-
+
} catch (Throwable e) {
logger.error("Failed to process Request: ", e);
PdfAsHelper.setSessionException(req, resp, e.getMessage(), e);