aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/gv/egiz/pdfas/web
diff options
context:
space:
mode:
authortknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2009-02-04 09:10:02 +0000
committertknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2009-02-04 09:10:02 +0000
commit03875a41dd5b065c8ab0c04268ac9371f51a8639 (patch)
tree303ba406a04e0facb1c579e240c9372dd39c08c2 /src/main/java/at/gv/egiz/pdfas/web
parent1ed2786b85d6f7dac5c83a1ba0474b7f33fa237c (diff)
downloadpdf-as-3-03875a41dd5b065c8ab0c04268ac9371f51a8639.tar.gz
pdf-as-3-03875a41dd5b065c8ab0c04268ac9371f51a8639.tar.bz2
pdf-as-3-03875a41dd5b065c8ab0c04268ac9371f51a8639.zip
Some more log messages (e.g. encoding related issues).
Updating web application (in external invocation mode) enhancing support for being used within an iframe. Two new (optional) parameters for external invocation mode: locale: defines the locale being used for webapp (e.g. locale=de or locale=de_DE), invoke-app-error-url: can be used to declare a callback url to the calling web application in order to transfer error messages from pdf-as. In case of error pdf-as redirects the user to the error-page-url (if given) providing the error and the cause in url encoded parameters ("error", "cause"). Formatter for mocca signature params enhanced. git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@323 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
Diffstat (limited to 'src/main/java/at/gv/egiz/pdfas/web')
-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);
+ }
+
}
}