aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/gv/egiz/pdfas/web/helper/SignServletHelper.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/gv/egiz/pdfas/web/helper/SignServletHelper.java')
-rw-r--r--src/main/java/at/gv/egiz/pdfas/web/helper/SignServletHelper.java39
1 files changed, 33 insertions, 6 deletions
diff --git a/src/main/java/at/gv/egiz/pdfas/web/helper/SignServletHelper.java b/src/main/java/at/gv/egiz/pdfas/web/helper/SignServletHelper.java
index 6fc7a1a..113169c 100644
--- a/src/main/java/at/gv/egiz/pdfas/web/helper/SignServletHelper.java
+++ b/src/main/java/at/gv/egiz/pdfas/web/helper/SignServletHelper.java
@@ -12,10 +12,12 @@ import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import at.gv.egiz.pdfas.api.commons.Constants;
import at.gv.egiz.pdfas.framework.SignatorFactory;
import at.gv.egiz.pdfas.framework.signator.Signator;
import at.gv.egiz.pdfas.impl.output.ByteArrayDataSink;
@@ -33,6 +35,7 @@ import at.knowcenter.wag.egov.egiz.sig.connectors.bku.SignSignatureObject;
import at.knowcenter.wag.egov.egiz.web.FormFields;
import at.knowcenter.wag.egov.egiz.web.LocalRequestHelper;
import at.knowcenter.wag.egov.egiz.web.PDFContainer;
+import at.knowcenter.wag.egov.egiz.web.SessionAttributes;
import at.knowcenter.wag.egov.egiz.web.servlets.ProvidePDFServlet;
/**
@@ -148,7 +151,7 @@ public class SignServletHelper
si.output = TempDirHelper.createTempDataSink(si.filename + "_signed.pdf");
signator.finishSign(si.si, si.output);
- returnSignResponse(si, response);
+ returnSignResponse(si, request, response);
log.debug("finishSign finished."); //$NON-NLS-1$
}
@@ -158,12 +161,13 @@ public class SignServletHelper
*
* @param si
* SessionInformation.
+ * @parem request The servlet request.
* @param response
* The servlet response.
* @throws IOException
* The IO Exception.
*/
- public static void returnSignResponse(SignSessionInformation si, HttpServletResponse response) throws IOException
+ public static void returnSignResponse(SignSessionInformation si, HttpServletRequest request, HttpServletResponse response) throws IOException
{
// SignResult sign_result = si.sign_result;
@@ -194,7 +198,13 @@ public class SignServletHelper
}
else
{
- // TODO @tzefferer: what is this code?
+ /**
+ * The following code handles an external invocation of pdf-as. External invocation is done by
+ * redirecting the user to the Sign-Servlet using the parameters defined in class
+ * at.knowcenter.wag.egov.egiz.web.FormFields.
+ * e.g. http://localhost:48080/pdf-as/Sign?preview=false&connector=bku&mode=textual&sig_type=SIGNATURBLOCK_DE&inline=false&filename=test.pdf&num-bytes=45916&pdf-url=http%3A%2F%2Flocalhost%3A8080%2Fmyapp%2FProvidePDF&pdf-id=1956507909008215134&invoke-app-url=https%3A%2F%2Flocalhost%3A8443%2Fmyapp%2FReturnSignedPDF&invoke-app-error-url=https%3A%2F%2Flocalhost%3A8443%2Fmyapp%2Fpdfaserror.do&session-id=9085B85B364BEC31E7D38047FE54577D&locale=de
+ */
+ log.debug("External webapp invocation detected.");
byte [] signed_pdf = null;
if (si.output instanceof FileBasedDataSink)
{
@@ -236,9 +246,26 @@ public class SignServletHelper
+ sep + FormFields.FIELD_PDF_URL + "=" + providePDFServlet + "&" + FormFields.FIELD_PDF_ID
+ "=" + pdf_id + "&" + FormFields.FIELD_FILE_LENGTH + "=" + signed_pdf.length;
- log.debug("Notifying external application by redirecting to \"" + query + "\".");
-
- response.sendRedirect(query);
+ /*
+ * Using the external web-interface of pdf-as (as described above) pdf-as should be run within
+ * an iframe. In case of a signature performed with a local citizen card software or with the
+ * server bku the result has to be provided outside an iframe. To break out of the iframe a
+ * helper jsp (redirect_to_parent) has to be used that redirects the user to the parent
+ * window.
+ */
+ if (Constants.SIGNATURE_DEVICE_BKU.equals(si.connector) || Constants.SIGNATURE_DEVICE_MOC.equals(si.connector)) {
+ HttpSession session = request.getSession();
+ log.debug("Local bku was used therefore pdf-as is supposed to run within an iframe.");
+ log.debug("Putting external application notify url (\"" + query + "\") in session (" + session.getId() + ") for later use.");
+ request.getSession().setAttribute(SessionAttributes.PARENT_WEBAPP_REDIRECT_URL, query);
+ String redirectHelper = response.encodeRedirectURL(request.getContextPath() + "/jsp/redirect_to_parent.jsp");
+ log.debug("Redirecting to " + redirectHelper);
+ response.sendRedirect(redirectHelper);
+ } else {
+ log.debug("Notifying external application by redirecting to \"" + query + "\".");
+ response.sendRedirect(query);
+ }
+
}
}