diff options
author | tknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c> | 2008-04-03 12:28:41 +0000 |
---|---|---|
committer | tknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c> | 2008-04-03 12:28:41 +0000 |
commit | f4c61a145d4f9a537c87fe67db36de8c28f2e352 (patch) | |
tree | 51e6b51375b1c19bf2a2ce332dd254fc5fddc3dd /src/main/java/at/knowcenter | |
parent | 861c81934a6596f6ec001248fc8f16476b816d2f (diff) | |
download | pdf-as-3-f4c61a145d4f9a537c87fe67db36de8c28f2e352.tar.gz pdf-as-3-f4c61a145d4f9a537c87fe67db36de8c28f2e352.tar.bz2 pdf-as-3-f4c61a145d4f9a537c87fe67db36de8c28f2e352.zip |
Web application adapted for Maven2 (/webapps -> /src/main/webapps).
Recognition of citizen card environment integrated.
New style sheets.
Web app classes adapted in order to avoid popup blocker of ie7 and to avoid an ITS bku bug.
Maven2 repository updated.
Eclipse project settings adapted in order to enable Eclipse Web Tools Platform usage.
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@256 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
Diffstat (limited to 'src/main/java/at/knowcenter')
5 files changed, 114 insertions, 77 deletions
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 02b6855..f4956be 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 @@ -43,4 +43,15 @@ public abstract class SessionAttributes * </p>
*/
public static final String ATTRIBUTE_SESSION_INFORMATION = "session_information";
+
+ /**
+ * The signed pdf document.
+ */
+ public static final String SIGNED_PDF_DOCUMENT = "at.gv.egiz.pdfas.web.SignSessionInformation:signedPDF";
+
+ /**
+ * The download URL for the signed pdf document.
+ */
+ public static final String DOWNLOAD_URL_FOR_SIGNED_PDF_DOCUMENT = "java.lang.String:downloadURL";
+
}
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 01e60fa..3c2ba28 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 @@ -16,6 +16,7 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServlet;
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;
@@ -40,6 +41,7 @@ import at.knowcenter.wag.egov.egiz.sig.connectors.LocalConnector; import at.knowcenter.wag.egov.egiz.sig.connectors.bku.BKUPostConnection;
import at.knowcenter.wag.egov.egiz.web.FormFields;
import at.knowcenter.wag.egov.egiz.web.LocalRequest;
+import at.knowcenter.wag.egov.egiz.web.SessionAttributes;
/**
* @author wprinz
@@ -162,7 +164,7 @@ public class DataURLServlet extends HttpServlet }
else
{
- log.debug("Recieved a normal response -> storing the response."); //$NON-NLS-1$
+ log.debug("Received a normal response -> storing the response."); //$NON-NLS-1$
Properties response_properties = new Properties();
response_properties.setProperty(BKUPostConnection.RESPONSE_STRING_KEY, xml_response);
@@ -203,7 +205,15 @@ public class DataURLServlet extends HttpServlet }
else
{
- SignServletHelper.returnSignResponse(si, response);
+ HttpSession session = request.getSession(true);
+ log.debug("Putting signed document into session (" + session.getId() + ").");
+ session.setAttribute(SessionAttributes.SIGNED_PDF_DOCUMENT, si);
+ session.setAttribute(SessionAttributes.DOWNLOAD_URL_FOR_SIGNED_PDF_DOCUMENT, response.encodeRedirectURL("/pdf-as/ProvidePDF"));
+ String redirectURL = response.encodeRedirectURL("/pdf-as/jsp/download.jsp");
+ log.debug("Redirecting to " + redirectURL + ".");
+ response.sendRedirect(redirectURL);
+ return;
+// SignServletHelper.returnSignResponse(si, response);
}
}
}
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 cd4cf43..6d486a5 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 @@ -8,66 +8,94 @@ import java.util.HashSet; import java.util.Iterator;
import java.util.Set;
+import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
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.web.SignSessionInformation;
+import at.gv.egiz.pdfas.web.helper.SignServletHelper;
+import at.knowcenter.wag.egov.egiz.exceptions.PresentableException;
import at.knowcenter.wag.egov.egiz.web.FormFields;
import at.knowcenter.wag.egov.egiz.web.PDFContainer;
+import at.knowcenter.wag.egov.egiz.web.SessionAttributes;
public class ProvidePDFServlet extends HttpServlet {
- /**
- * SVUID.
- */
- private static final long serialVersionUID = 1L;
-
- /**
- * The log.
- */
- private static Log log = LogFactory.getLog(ProvidePDFServlet.class);
-
- public static Set signedDocuments = Collections.synchronizedSet(new HashSet());
-
- public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
- {
-
- long pdfId = Long.parseLong(request.getParameter(FormFields.FIELD_PDF_ID));
-
- Iterator it = signedDocuments.iterator();
-
- while(it.hasNext()) {
- PDFContainer current = (PDFContainer) it.next();
- if(current.id == pdfId) {
- try {
- byte[] pdf = current.pdf;
-
- response.setContentType("application/pdf");
- response.setContentLength(pdf.length);
-
- InputStream is = new ByteArrayInputStream(pdf);
- final int bufferSize = 1024;
- byte[] buffer = new byte[bufferSize];
- int len = -1;
- while ((len = is.read(buffer)) != -1) {
- response.getOutputStream().write(buffer, 0, len);
- }
- response.getOutputStream().flush();
- signedDocuments.remove(current);
- } catch(IOException e) {
- log.warn("IO excepton while providing pdf document: " + e.getMessage());
- }
+ /**
+ * SVUID.
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * The log.
+ */
+ private static Log log = LogFactory.getLog(ProvidePDFServlet.class);
+
+ public static Set signedDocuments = Collections.synchronizedSet(new HashSet());
+
+ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+
+ String pdfIdString = request.getParameter(FormFields.FIELD_PDF_ID);
+
+ if (pdfIdString == null) {
+ HttpSession session = request.getSession(true);
+ log.debug("No " + FormFields.FIELD_PDF_ID + " provided. Trying to retrieve PDF from session (" + session.getId() + ").");
+ SignSessionInformation si = (SignSessionInformation) session.getAttribute(SessionAttributes.SIGNED_PDF_DOCUMENT);
+ if (si == null) {
+ log.warn("Unable to find signed pdf in session (" + session.getId() + ").");
+ SignServlet.prepareDispatchToErrorPage(new PresentableException(600, "Das signierte Dokument konnte nicht gefunden werden."), request);
+ response.setContentType("text/html");
+ response.setCharacterEncoding("UTF-8");
+ RequestDispatcher disp = super.getServletContext().getRequestDispatcher("/jsp/error.jsp");
+ disp.forward(request, response);
+ return;
+ } else {
+ log.debug("Signed pdf found. Removing from session.");
+ session.removeAttribute(SessionAttributes.SIGNED_PDF_DOCUMENT);
+ log.debug("Returning signed pdf to browser.");
+ SignServletHelper.returnSignResponse(si, response);
+ return;
+ }
+ } else {
+ long pdfId = Long.parseLong(pdfIdString);
+
+ Iterator it = signedDocuments.iterator();
+
+ while (it.hasNext()) {
+ PDFContainer current = (PDFContainer) it.next();
+ if (current.id == pdfId) {
+ try {
+ byte[] pdf = current.pdf;
+
+ response.setContentType("application/pdf");
+ response.setContentLength(pdf.length);
+
+ InputStream is = new ByteArrayInputStream(pdf);
+ final int bufferSize = 1024;
+ byte[] buffer = new byte[bufferSize];
+ int len = -1;
+ while ((len = is.read(buffer)) != -1) {
+ response.getOutputStream().write(buffer, 0, len);
+ }
+ response.getOutputStream().flush();
+ signedDocuments.remove(current);
+ } catch (IOException e) {
+ log.warn("IO excepton while providing pdf document: " + e.getMessage());
+ }
+ }
+ }
}
- }
- }
-
- public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
- {
- doPost(request, response);
- }
-
+
+ }
+
+ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ doPost(request, response);
+ }
+
}
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyPreviewServlet.java b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyPreviewServlet.java index 732e6cc..571a8e1 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyPreviewServlet.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyPreviewServlet.java @@ -315,14 +315,14 @@ public class VerifyPreviewServlet extends HttpServlet }
writer.println(" <tr>");
- writer.println(" <td width=\"10%\"><span class=\"sca\">" + caption + ":</span></td>");
+ writer.println(" <td width=\"10%\"><span>" + caption + ":</span></td>");
writer.println(" <td width=\"90%\">");
value = value.replaceAll("\\s", " ");
value = value.replaceAll("\\\"", "\\\"");
String input_key = name_prefix + key;
- writer.println(" <input class=\"sin\" name=\"" + input_key + "\" type=\"text\" value=\"" + (write_value ? value : "wird automatisch ausgefüllt") + "\" />");
+ writer.println(" <input size=\"70\" name=\"" + input_key + "\" type=\"text\" value=\"" + (write_value ? value : "wird automatisch ausgefüllt") + "\" />");
writer.println(" </td>");
writer.println(" </tr>");
@@ -337,25 +337,10 @@ public class VerifyPreviewServlet extends HttpServlet StringWriter sw = new StringWriter();
PrintWriter writer = new PrintWriter(sw);
- String title = "alte PDF-AS Signatur";
- try
- {
- PdfASID kz = signature_object.getKZ();
- if (kz != null)
- {
- title = kz.toString();
- }
- }
- catch (InvalidIDException e)
- {
- e.printStackTrace();
- }
- writer.println("<div class=\"listtype\">Signatur: " + title + "</div>");
- writer.println("<table cellpadding=\"1\" cellspacing=\"1\" class=\"listtable\">");
+ writer.println("<table cellpadding=\"2\" cellspacing=\"0\" class=\"pdfaslisttable\">");
// just render useful information
- String[] rkeys = { SignatureTypes.SIG_DATE, SignatureTypes.SIG_ISSUER,
- SignatureTypes.SIG_NUMBER, SignatureTypes.SIG_KZ}; // SignatureTypes.REQUIRED_SIG_KEYS;
+ String[] rkeys = { SignatureTypes.SIG_NAME, SignatureTypes.SIG_DATE, SignatureTypes.SIG_ISSUER, SignatureTypes.SIG_NUMBER}; // SignatureTypes.REQUIRED_SIG_KEYS;
for (int key_idx = 0; key_idx < rkeys.length; key_idx++)
{
@@ -363,15 +348,18 @@ public class VerifyPreviewServlet extends HttpServlet SignatureEntry entry = signature_object.getSigEntry(key);
String caption = entry.getCaption();
String value = entry.getValue();
-
- if (SignatureTypes.SIG_KZ.equals(key) && value == null)
- {
- continue;
+ if (caption == null || value == null) {
+ continue;
}
+// if (SignatureTypes.SIG_KZ.equals(key) && value == null)
+// {
+// continue;
+// }
+
writer.println(" <tr>");
- writer.println(" <td width=\"10%\">" + caption + ":</td>");
- writer.println(" <td width=\"90%\">");
+ writer.println(" <td class=\"pdfascaption\">" + caption + ":</td>");
+ writer.println(" <td class=\"pdfasvalue\">");
value = value.replaceAll("\\s", " ");
value = value.replaceAll("\\\"", "\\\"");
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyServlet.java b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyServlet.java index eb07828..001b8b3 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyServlet.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyServlet.java @@ -170,13 +170,13 @@ public class VerifyServlet extends HttpServlet {
request.setAttribute("error", "Fehler beim Upload der Daten");
request.setAttribute("cause", "Beim Upload der Daten ist ein Fehler aufgetreten.");
- dispatch(request, response, "/jsp/error.jsp");
+ dispatch(request, response, "/jsp/error_verify.jsp");
}
catch (PresentableException e)
{
e.printStackTrace();
SignServlet.prepareDispatchToErrorPage(e, request);
- dispatch(request, response, "/jsp/error.jsp");
+ dispatch(request, response, "/jsp/error_verify.jsp");
}
}
|