aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/gv/egiz/pdfas/utils/ConfigUtils.java3
-rw-r--r--src/main/java/at/gv/egiz/pdfas/web/helper/SignServletHelper.java39
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java2
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/cfg/SettingsReader.java1
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/BKUHelper.java1
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/mocca/LocRefDetachedMOCCAConnector.java6
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/sigid/DetachedMOCIdFormatter.java2
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/web/ExternAppInformation.java6
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/web/FormFields.java2
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/web/SessionAttributes.java5
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/DataURLServlet.java2
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/ProvidePDFServlet.java2
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/SignServlet.java3
13 files changed, 60 insertions, 14 deletions
diff --git a/src/main/java/at/gv/egiz/pdfas/utils/ConfigUtils.java b/src/main/java/at/gv/egiz/pdfas/utils/ConfigUtils.java
index a7bca3f..34de789 100644
--- a/src/main/java/at/gv/egiz/pdfas/utils/ConfigUtils.java
+++ b/src/main/java/at/gv/egiz/pdfas/utils/ConfigUtils.java
@@ -260,6 +260,7 @@ public final class ConfigUtils {
String infoConfiguration = " configuration path = \"" + SettingsReader.CONFIG_PATH + "\"";
String infoCertStore = " certstore path = \"" + SettingsReader.CERT_PATH + "\"";
String infoTempPath = " temporary path = \"" + SettingsReader.TMP_PATH + "\"";
+ String encoding = " file.encoding = \"" + System.getProperty("file.encoding") + "\"";
if (logger != null) {
logger.info(separator);
@@ -267,6 +268,7 @@ public final class ConfigUtils {
logger.info(infoConfiguration);
logger.info(infoCertStore);
logger.info(infoTempPath);
+ logger.info(encoding);
logger.info(separator);
} else {
StringBuffer buffer = new StringBuffer();
@@ -275,6 +277,7 @@ public final class ConfigUtils {
buffer.append(infoConfiguration).append(SystemUtils.LINE_SEPARATOR);
buffer.append(infoCertStore).append(SystemUtils.LINE_SEPARATOR);
buffer.append(infoTempPath).append(SystemUtils.LINE_SEPARATOR);
+ buffer.append(encoding).append(SystemUtils.LINE_SEPARATOR);
buffer.append(separator);
System.out.println(buffer.toString());
}
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);
+ }
+
}
}
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java b/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java
index 302e8cb..d150f70 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java
@@ -96,7 +96,7 @@ public abstract class PdfAS
* The current version of the pdf-as library. This version string is logged on every invocation
* of the api or the web application.
*/
- public static final String PDFAS_VERSION = "3.0.9-20090129";
+ public static final String PDFAS_VERSION = "3.0.9-20090203";
/**
* The key of the strict mode setting.
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/cfg/SettingsReader.java b/src/main/java/at/knowcenter/wag/egov/egiz/cfg/SettingsReader.java
index 6cd5e61..bca5b17 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/cfg/SettingsReader.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/cfg/SettingsReader.java
@@ -394,6 +394,7 @@ public class SettingsReader implements Serializable
logger_.info(" configuration path = \"" + CONFIG_PATH + "\"");
logger_.info(" certstore path = \"" + CERT_PATH + "\"");
logger_.info(" temporary path = \"" + TMP_PATH + "\"");
+ logger_.info(" file.encoding = \"" + System.getProperty("file.encoding") + "\"");
logger_.info(StringUtils.repeat("*", length + 25));
IAIK.addAsProvider();
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/BKUHelper.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/BKUHelper.java
index cec8d6f..af155a1 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/BKUHelper.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/BKUHelper.java
@@ -110,6 +110,7 @@ public final class BKUHelper
*/
public static void checkResponseForError(String response_string) throws ConnectorException
{
+ log.debug("Checking response for error: " + response_string);
Pattern erc_p_s = Pattern.compile("<[\\w]*:?ErrorCode>"); //$NON-NLS-1$
Pattern erc_p_e = Pattern.compile("</[\\w]*:?ErrorCode>"); //$NON-NLS-1$
Matcher erc_m_s = erc_p_s.matcher(response_string);
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/mocca/LocRefDetachedMOCCAConnector.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/mocca/LocRefDetachedMOCCAConnector.java
index fcfe006..30212eb 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/mocca/LocRefDetachedMOCCAConnector.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/mocca/LocRefDetachedMOCCAConnector.java
@@ -547,10 +547,10 @@ public class LocRefDetachedMOCCAConnector implements Connector, LocalConnector {
* @return The common part of all id attributes.
*/
protected String parseSigId(String sigIdString) {
- int pos = sigIdString.indexOf("@");
+ String[] parts = sigIdString.split("@");
String result = null;
- if (pos != -1) {
- result = sigIdString.substring(pos+1).trim();
+ if (parts != null && parts.length > 1) {
+ result = parts[1].trim();
}
return result;
}
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/sigid/DetachedMOCIdFormatter.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/sigid/DetachedMOCIdFormatter.java
index c942b73..ae46225 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/sigid/DetachedMOCIdFormatter.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/sigid/DetachedMOCIdFormatter.java
@@ -16,7 +16,7 @@ import at.knowcenter.wag.egov.egiz.exceptions.SettingsException;
*/
public class DetachedMOCIdFormatter implements IdFormatter {
- public static String SIG_ID_PREFIX = "etsi-moc-1.0";
+ public static final String SIG_ID_PREFIX = "etsi-moc-1.0";
/**
* Key value in property file
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/web/ExternAppInformation.java b/src/main/java/at/knowcenter/wag/egov/egiz/web/ExternAppInformation.java
index 73f10aa..d00ec61 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/web/ExternAppInformation.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/web/ExternAppInformation.java
@@ -12,11 +12,17 @@ public class ExternAppInformation implements Serializable {
public String invoke_url;
public long pdf_id;
public String session_id;
+ public String invoke_error_url;
public ExternAppInformation(String url, String id, String session_id) {
+ this(url, id, session_id, null);
+ }
+
+ public ExternAppInformation(String url, String id, String session_id, String errorUrl) {
this.invoke_url = url;
this.pdf_id = Long.parseLong(id);
this.session_id = session_id;
+ this.invoke_error_url = errorUrl;
}
}
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/web/FormFields.java b/src/main/java/at/knowcenter/wag/egov/egiz/web/FormFields.java
index ad480cc..7b8164a 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/web/FormFields.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/web/FormFields.java
@@ -88,6 +88,8 @@ public abstract class FormFields
public static final String FIELD_FILE_LENGTH = "num-bytes";
public static final String FIELD_INVOKE_APP_URL = "invoke-app-url";
+
+ public static final String FIELD_INVOKE_APP_ERROR_URL = "invoke-app-error-url";
public static final String FIELD_SESSION_ID = "session-id";
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/web/SessionAttributes.java b/src/main/java/at/knowcenter/wag/egov/egiz/web/SessionAttributes.java
index f4956be..1a7d90f 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/web/SessionAttributes.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/web/SessionAttributes.java
@@ -54,4 +54,9 @@ public abstract class SessionAttributes
*/
public static final String DOWNLOAD_URL_FOR_SIGNED_PDF_DOCUMENT = "java.lang.String:downloadURL";
+ /**
+ * The notification url of an external webapplication.
+ */
+ public static final String PARENT_WEBAPP_REDIRECT_URL = "java.lang.String:parentWebAppRedirectURL";
+
}
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/DataURLServlet.java b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/DataURLServlet.java
index 16352de..f74bd1c 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/DataURLServlet.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/DataURLServlet.java
@@ -277,7 +277,7 @@ public class DataURLServlet extends HttpServlet
// redirect to download.jsp but return the sign-response immediately
if (si.exappinf != null) {
log.debug("Entering external application interface mode. Skipping redirection to download page.");
- SignServletHelper.returnSignResponse(si, response);
+ SignServletHelper.returnSignResponse(si, request, response);
// Not needed due to redirection of returnSignResponse.
// Just to clarify that there must not be any code after returnSignResponse.
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/ProvidePDFServlet.java b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/ProvidePDFServlet.java
index 1efc64f..c40f3c6 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/ProvidePDFServlet.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/ProvidePDFServlet.java
@@ -61,7 +61,7 @@ public class ProvidePDFServlet extends HttpServlet {
log.debug("Returning signed pdf to browser.");
// log.debug("Invalidating session.");
// session.invalidate();
- SignServletHelper.returnSignResponse(si, response);
+ SignServletHelper.returnSignResponse(si, request, response);
return;
}
} else {
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/SignServlet.java b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/SignServlet.java
index 589de7c..792a3e1 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/SignServlet.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/SignServlet.java
@@ -184,6 +184,7 @@ public class SignServlet extends HttpServlet
String pdf_id = (String) request.getParameter(FormFields.FIELD_PDF_ID);
String pdf_length = (String) request.getParameter(FormFields.FIELD_FILE_LENGTH);
String invoke_url = (String) request.getParameter(FormFields.FIELD_INVOKE_APP_URL);
+ String invoke_error_url = (String) request.getParameter(FormFields.FIELD_INVOKE_APP_ERROR_URL);
String session_id = (String) request.getParameter(FormFields.FIELD_SESSION_ID);
String sig_pos_y = (String) request.getParameter(FormFields.FIELD_SIGPOS_Y);
String sig_pos_p = (String) request.getParameter(FormFields.FIELD_SIGPOS_P);
@@ -227,7 +228,7 @@ public class SignServlet extends HttpServlet
ud = ud_extern;
- exappinf = new ExternAppInformation(invoke_url, pdf_id, session_id);
+ exappinf = new ExternAppInformation(invoke_url, pdf_id, session_id, invoke_error_url);
}
else
{