aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets
diff options
context:
space:
mode:
authorpdanner <pdanner@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2010-12-06 18:23:49 +0000
committerpdanner <pdanner@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2010-12-06 18:23:49 +0000
commit79777d04cf64aa06388bb2027f5e1001015471f3 (patch)
tree4c70ec8695659a14aa862f98d50f70b1299c090b /pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets
parentebf049402a10f8a4cf5612496d5c6daf64a7081a (diff)
downloadpdf-as-3-79777d04cf64aa06388bb2027f5e1001015471f3.tar.gz
pdf-as-3-79777d04cf64aa06388bb2027f5e1001015471f3.tar.bz2
pdf-as-3-79777d04cf64aa06388bb2027f5e1001015471f3.zip
javadoc an cleanup of unneeded code (mainly already out-commented)
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@690 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
Diffstat (limited to 'pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets')
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/AsynchronousDataResponder.java157
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/AsynchronousRedirectResponder.java184
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/DataURLServlet.java72
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/RetrieveSignatureDataServlet.java1
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/SignServlet.java65
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/VerifyPreviewServlet.java262
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/VerifyServlet.java119
7 files changed, 22 insertions, 838 deletions
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/AsynchronousDataResponder.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/AsynchronousDataResponder.java
deleted file mode 100644
index 26f1670..0000000
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/AsynchronousDataResponder.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/**
- * <copyright> Copyright (c) 2006 by Know-Center, Graz, Austria </copyright>
- *
- * This software is the confidential and proprietary information of Know-Center,
- * Graz, Austria. You shall not disclose such Confidential Information and shall
- * use it only in accordance with the terms of the license agreement you entered
- * into with Know-Center.
- *
- * KNOW-CENTER MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
- * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
- * NON-INFRINGEMENT. KNOW-CENTER SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY
- * LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
- * DERIVATIVES.
- *
- * $Id: AsynchronousDataResponder.java,v 1.3 2006/08/30 14:02:35 wprinz Exp $
- */
-package at.gv.egiz.pdfas.web.servlets;
-
-import javax.servlet.http.HttpServlet;
-
-/**
- * Servlet that responds to the data post requests of the local service (e.g.
- * BKU).
- *
- * @deprecated
- *
- * @author wprinz
- */
-public class AsynchronousDataResponder extends HttpServlet
-{
-
- /**
- * SVUID.
- */
- private static final long serialVersionUID = -4992297156381763174L;
-
-// /**
-// * The logger definition.
-// */
-// private static final Logger logger_ = ConfigLogger.getLogger(AsynchronousDataResponder.class);
-//
-// protected void doGet(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException
-// {
-// logger_.debug("AsyncDataResp GET REQUEST.");
-// super.doGet(arg0, arg1);
-// }
-//
-// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
-// {
-// logger_.debug("AsyncDataResp !!!!!!!!!!!!!!!!!!!!!!");
-//
-// HttpSession session = request.getSession(false);
-// if (session == null)
-// {
-// throw new ServletException("There is no session associated with this request.");
-// }
-//
-// // String session_id_string = request.getParameter("session");
-// // if (session_id_string == null)
-// // {
-// // throw new ServletException("The session parameter is missing.");
-// // }
-//
-// SessionInformation si = (SessionInformation) session.getAttribute(SessionAttributes.ATTRIBUTE_SESSION_INFORMATION);
-// // long session_id = Long.parseLong(session_id_string);
-// // SessionInformation si = SessionTable.get(session_id);
-// if (si == null)
-// {
-// throw new ServletException("The session is not found or no longer valid.");
-// }
-//
-// // InputStream is = request.getInputStream();
-// // byte [] data = new byte[request.getContentLength()];
-// // is.read(data);
-// // is.close();
-// // String enc = request.getCharacterEncoding();
-// // String ct = request.getContentType();
-// // Enumeration enum = request.getHeaderNames();
-// //
-// // String dat = new String(data, "US-ASCII");
-// // // dat looks like: XMLResponse=blablabla ...
-// // // so the actual XMLResponse begins after the =
-// // String resp = URLDecoder.decode(dat, "UTF-8");
-//
-// logger_.debug("Answer from local service: content-type = '" + request.getContentType() + "', character encoding = '" + request.getCharacterEncoding() + "'");
-//
-// // .getParameter will use the character encoding specified by the
-// // content-type header.
-// // Unfortunately BKU forgets to specify a chatacter encoding.
-// // Therefor, .getParameter will assume US-ASCII or something.
-// // ==> we explicitely set UTF-8
-// if (request.getCharacterEncoding() == null)
-// {
-// request.setCharacterEncoding("UTF-8");
-// logger_.debug(" no character encoding specified - set to UTF-8");
-// }
-//
-// logger_.debug("AsyncDataResponder: si.current_operation = " + si.current_operation);
-//
-// String resp_string = request.getParameter("XMLResponse");
-// if (resp_string == null)
-// {
-// logger_.debug("response String is null => trying multipart form");
-//
-// DiskFileItemFactory fif = new DiskFileItemFactory();
-// fif.setRepository(SettingsReader.getTemporaryDirectory());
-// ServletFileUpload sfu = new ServletFileUpload(fif);
-//
-// try
-// {
-// List items = sfu.parseRequest(request);
-//
-// for (int i = 0; i < items.size(); i++)
-// {
-// FileItem item = (FileItem) items.get(i);
-// logger_.debug("item = " + item.getFieldName());
-//
-// if (item.getFieldName().equals("XMLResponse"))
-// {
-// resp_string = item.getString("UTF-8");
-// }
-// }
-// }
-// catch (FileUploadException e)
-// {
-// throw new ServletException("File Upload exception. cannot parse POST data");
-// }
-//
-// }
-//
-// // TODO hotfix - already deprecated
-// if (logger_.isDebugEnabled())
-// {
-// Enumeration header_names = request.getHeaderNames();
-// while (header_names.hasMoreElements())
-// {
-// String header_name = (String)header_names.nextElement();
-// String header_value = request.getHeader(header_name);
-// logger_.debug("header: name = " + header_name + ", value = " +header_value);
-// }
-// }
-// String user_agent = request.getHeader("User-Agent");
-// logger_.debug("User-Agent header = " + user_agent);
-// Properties response_properties = new Properties();
-// BKUPostConnection.parseBKUVersion(user_agent, response_properties);
-// response_properties.setProperty("response_string", resp_string);
-// si.response_properties[si.current_operation] = response_properties; //request.getParameter("XMLResponse");
-// //logger_.debug("AsyncDataResponder: si.response_string[si.current_operation] = " + si.response_string[si.current_operation]);
-//
-// si.current_operation++;
-//
-// si.finished = true;
-//
-// LocalRequestHelper.formatBKUOkResponse(response);
-// }
-}
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/AsynchronousRedirectResponder.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/AsynchronousRedirectResponder.java
deleted file mode 100644
index 80078ed..0000000
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/AsynchronousRedirectResponder.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/**
- * <copyright> Copyright (c) 2006 by Know-Center, Graz, Austria </copyright>
- *
- * This software is the confidential and proprietary information of Know-Center,
- * Graz, Austria. You shall not disclose such Confidential Information and shall
- * use it only in accordance with the terms of the license agreement you entered
- * into with Know-Center.
- *
- * KNOW-CENTER MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
- * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
- * NON-INFRINGEMENT. KNOW-CENTER SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY
- * LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
- * DERIVATIVES.
- *
- * $Id: AsynchronousRedirectResponder.java,v 1.4 2006/10/11 07:39:13 wprinz Exp $
- */
-package at.gv.egiz.pdfas.web.servlets;
-
-import javax.servlet.http.HttpServlet;
-
-/**
- * Servlet that responds to the redirect requests of the local service (e.g.
- * BKU).
- *
- * @deprecated remove this
- *
- * @author wprinz
- */
-public class AsynchronousRedirectResponder extends HttpServlet
-{
-
- /**
- * SVUID.
- */
- private static final long serialVersionUID = -682360466333727236L;
-
-// /**
-// * The logger definition.
-// */
-// private static final Logger logger_ = ConfigLogger.getLogger(AsynchronousRedirectResponder.class);
-//
-// protected void dispatch(HttpServletRequest request,
-// HttpServletResponse response, String resource) throws ServletException, IOException
-// {
-// response.setContentType("text/html");
-// response.setCharacterEncoding("UTF-8");
-//
-// RequestDispatcher disp = getServletContext().getRequestDispatcher(resource);
-// disp.forward(request, response);
-// }
-//
-// protected void dispatchToResults(List results, HttpServletRequest request,
-// HttpServletResponse response) throws ServletException, IOException
-// {
-// request.setAttribute("results", results);
-// dispatch(request, response, "/jsp/results.jsp");
-// }
-//
-// protected void dispatchToRedirectRefreshPage (HttpServletRequest request,
-// HttpServletResponse response, String refresh_url) throws ServletException, IOException
-// {
-// request.setAttribute("refresh_url", refresh_url);
-// dispatch(request, response, LocalRequestHelper.REDIRECT_REFRESH_PAGE_JSP);
-// }
-//
-// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
-// {
-// logger_.debug("AsyncRedirResp");
-//
-// SessionInformation si = null;
-//
-// HttpSession session = null;
-// try
-// {
-// session = request.getSession(false);
-// //String session_id_string = request.getParameter("session");
-// if (session == null)
-// {
-// throw new ErrorCodeException(600, "The session is missing.");
-// }
-//
-// si = (SessionInformation) session.getAttribute(SessionAttributes.ATTRIBUTE_SESSION_INFORMATION);
-//// long session_id = Long.parseLong(session_id_string);
-//// si = SessionTable.get(session_id);
-// if (si == null)
-// {
-// throw new ErrorCodeException(600, "The session is not found or is no longer valid.");
-// }
-//
-// }
-// catch (PresentableException e)
-// {
-// e.printStackTrace();
-// SignServlet.prepareDispatchToErrorPage(e, request);
-// dispatch(request, response, "/jsp/error.jsp");
-//
-// return;
-// }
-//
-// try
-// {
-// if (si.finished == false)
-// {
-// String url = request.getRequestURL().toString();
-// logger_.debug("RequestURL = " + url);
-// String refresh_url = response.encodeURL(url);
-// logger_.debug("RefreshURL = " + refresh_url);
-// dispatchToRedirectRefreshPage(request, response, refresh_url);
-// return;
-// }
-//
-// // si.finished is true, but maybe there are more requests to process.
-// if (si.current_operation < si.requests.length)
-// {
-// si.finished = false;
-//
-// LocalRequestHelper.prepareDispatchToLocalConnectionPage(si.requests[si.current_operation], request, response);
-// dispatch(request, response, LocalRequestHelper.LOCAL_CONNECTION_PAGE_JSP);
-// return;
-// }
-//
-// // all requests have been carried out.
-//
-// BKUConnector local_conn = (BKUConnector) ConnectorFactory.createConnector(si.connector);
-//
-// if (si.application.equals("verify"))
-// {
-// List results = new ArrayList();
-//
-// for (int i = 0; i < si.response_properties.length; i++)
-// {
-// SignatureResponse sig_resp = local_conn.analyzeVerifyResponse(si.response_properties[i]);
-// results.add(sig_resp);
-// }
-//
-// dispatchToResults(results, request, response);
-// }
-// else
-// {
-// //logger_.debug("AsyncRedirResponder: si.response_string[0] = " + si.response_string[0]);
-// logger_.debug("AsyncRedirResponder: si.current_op = " + si.current_operation);
-//
-// // The response string must not be null here - otherwise finished mustn't have been set!
-//// if (si.response_string[0] == null)
-//// {
-//// String url = request.getRequestURL().toString();
-//// logger_.debug("RequestURL = " + url);
-//// String refresh_url = response.encodeURL(url);
-//// logger_.debug("RefreshURL = " + refresh_url);
-//// dispatchToRedirectRefreshPage(request, response, refresh_url);
-//// return ;
-//// }
-//
-// // A download blocker may have blocked the first download.
-// // So, if the user asks for the document a second time and the sign_result
-// // has already been computed - don't recompute it.
-// if (si.sign_result == null)
-// {
-// // refactor WEB
-// si.iui.signed_signature_object = null; //local_conn.analyzeSignResponse(si.response_properties[0], si.type);
-//
-// PdfASID algorithm = FormFields.translateSignatureModeToPdfASID(si.mode);
-// Signator signator = SignatorFactory.createSignator(algorithm);
-//
-// si.sign_result = signator.finishSign(si.iui);
-// }
-//
-// SignServlet.returnSignResponse(si, response);
-// }
-//
-// }
-// catch (PresentableException e)
-// {
-// session.removeAttribute(SessionAttributes.ATTRIBUTE_SESSION_INFORMATION);
-// //SessionTable.remove(si.session_id);
-//
-// e.printStackTrace();
-// SignServlet.prepareDispatchToErrorPage(e, request);
-// dispatch(request, response, "/jsp/error.jsp");
-// }
-//
-// }
-}
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/DataURLServlet.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/DataURLServlet.java
index 2f6a76c..51a2d6e 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/DataURLServlet.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/DataURLServlet.java
@@ -203,17 +203,6 @@ public class DataURLServlet extends HttpServlet
si.localBKUParams = bkuParams;
pdfAsInternal.verifyBKUSupport(bkuParams);
-
-// Properties response_properties = BKUHelper.getBKUProperties(request);
-//
-// String bkuIdentifier = BKUHelper.getBKUIdentifier(response_properties);
-// log.debug("BKU identifier: \"" + bkuIdentifier + "\"");
-//
-// try {
-// SignatureLayoutHandlerFactory.verifyBKUSupport(bkuIdentifier);
-// } catch (SettingsException e) {
-// throw new ConnectorException(e.getErrorCode(), e.getMessage());
-// }
if (isNullResponse(xml_response))
{
@@ -237,9 +226,6 @@ public class DataURLServlet extends HttpServlet
{
log.debug("Received a normal response -> storing the response."); //$NON-NLS-1$
-// response_properties.setProperty(BKUPostConnection.RESPONSE_STRING_KEY, xml_response);
-//
-// si.response_properties = response_properties;
si.xmlResponse = xml_response;
log.debug("All requests have been processed -> processing the responses."); //$NON-NLS-1$
@@ -248,23 +234,9 @@ public class DataURLServlet extends HttpServlet
if (!si.outputAvailable)
{
- PdfAs pdfAs = ApiHelper.getPdfAsFromContext(getServletContext());
- SignServletHelper.finishLocalSign(pdfAs, pdfAsInternal, si);
- SigningTimeHelper.checkSigningTimeAgainstHostTime(si.sdi.getSignDate());
-// LocalConnector c = ConnectorChooser.chooseLocalConnectorForSign(si.connector, si.type, "loc ref content not needed here"); //$NON-NLS-1$
-//
-// si.si.setSignSignatureObject(c.analyzeSignResponse(si.response_properties));
-//
-// // workaround for invalid signing time
-// SigningTimeHelper.checkSigningTimeAgainstHostTime(si.sdi.getSignDate());
-//
-// PdfASID algorithm = FormFields.translateSignatureModeToPdfASID(si.mode);
-// Signator signator = SignatorFactory.createSignator(algorithm);
-//
-// si.output = TempDirHelper.createTempDataSink(si.filename + "_signed.pdf");
-//
-// signator.finishSign(si.si, si.output);
-
+ PdfAs pdfAs = ApiHelper.getPdfAsFromContext(getServletContext());
+ SignServletHelper.finishLocalSign(pdfAs, pdfAsInternal, si);
+ SigningTimeHelper.checkSigningTimeAgainstHostTime(si.sdi.getSignDate());
si.outputAvailable = true;
}
@@ -279,7 +251,6 @@ public class DataURLServlet extends HttpServlet
response.setContentType("text/plain");
response.setCharacterEncoding("UTF-8");
response.getWriter().println("Das detached XML kann nicht direkt durch die BKU geschliffen werden, weil diese es als Request interpretieren würde. Daher das XML als Text:");
- //response.getWriter().println(si.sdi.getSignSignatureObject().response_properties.getProperty(BKUPostConnection.RESPONSE_STRING_KEY));
response.getWriter().println(new String(si.signedPdf, "UTF-8"));
}
else
@@ -332,9 +303,6 @@ public class DataURLServlet extends HttpServlet
{
log.debug("Recieved a normal response -> storing the response."); //$NON-NLS-1$
-// Properties response_properties = new Properties();
-// response_properties.setProperty(BKUPostConnection.RESPONSE_STRING_KEY, xml_response);
-
si.currentLocalOperation.finishCurrentOperation(xml_response);
}
@@ -360,31 +328,21 @@ public class DataURLServlet extends HttpServlet
for (int i = 0; i < si.currentLocalOperation.response_xmls.length; i++)
{
SignatureInformation sigInfo = (SignatureInformation) si.currentLocalOperation.signaturesToBeverified.get(i);
-
-// PdfASID sig_kz = sh.getSignatureObject().getKZ();
-// String sig_id = sh.getSignatureObject().getSignationIds();
-//
-// LocalConnector c = ConnectorChooser.chooseLocalConnectorForVerify(si.connector, sig_kz, sig_id, si.type, "loc ref content not needed here"); //$NON-NLS-1$
-
VerifyResult result = pdfAsInternal.finishLocalVerify(sigInfo, si.connector, si.type, "loc ref content not needed here", si.currentLocalOperation.response_xmls[i]);
resList.add(result);
-// SignatureResponse sig_resp = c.analyzeVerifyResponse(si.currentLocalOperation.response_xmls[i]);
-// results.add(sig_resp);
- }
+ }
- si.currentLocalOperation = null;
-
- URL btlURL = new URL(LocalRequestHelper.getLocalContextAddress(request, response) + "/jsp/verifylist.jsp");
- String backToListURL = response.encodeURL(btlURL.toString());
-
- VerifyResults results = new VerifyResults() {
-
- public List getResults() {
- return resList;
- }
- };
- dispatchToResults(results, request, response, backToListURL);
- }
+ si.currentLocalOperation = null;
+
+ URL btlURL = new URL(LocalRequestHelper.getLocalContextAddress(request, response) + "/jsp/verifylist.jsp");
+ String backToListURL = response.encodeURL(btlURL.toString());
+ VerifyResults results = new VerifyResults() {
+ public List getResults() {
+ return resList;
+ }
+ };
+ dispatchToResults(results, request, response, backToListURL);
+ }
}
}
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/RetrieveSignatureDataServlet.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/RetrieveSignatureDataServlet.java
index c7fe841..f841fdc 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/RetrieveSignatureDataServlet.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/RetrieveSignatureDataServlet.java
@@ -122,7 +122,6 @@ public class RetrieveSignatureDataServlet extends HttpServlet
// [tknall] content length must be set, otherwise ITS BKU for Mac rejects the request.
response.setContentLength(ds.getLength());
IOUtils.copy(ds.createInputStream(), response.getOutputStream());
- // response.getOutputStream().write(sd.getData());
log.trace("Writing SignatureData finished."); //$NON-NLS-1$
}
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/SignServlet.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/SignServlet.java
index acd71b0..45f7e8f 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/SignServlet.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/SignServlet.java
@@ -102,62 +102,6 @@ public class SignServlet extends HttpServlet
disp.forward(request, response);
}
- // The sign servlet is used for processing the upload only.
- // Authentication is deactivated. if required - make an own servlet.
- // /**
- // * @author modified by tknall
- // */
- // public void doGet(HttpServletRequest request, HttpServletResponse response)
- // throws ServletException, IOException
- // {
- // String authenticate = request.getHeader(AUTH);
- // if (authenticate != null)
- // {
- // logger_.info("authenticate:" + authenticate);
- // if (authenticate.indexOf(AUTH_BASIC) == 0)
- // {
- // authenticate = authenticate.substring(AUTH_BASIC.length() + 1);
- // logger_.info("authenticate:" + authenticate);
- // authenticate = new String(CodingHelper.decodeBase64(authenticate),
- // "UTF-8");
- // logger_.info("authenticate:" + authenticate);
- //
- // String[] auth_value = authenticate.split(":");
- // String user_name = auth_value[0];
- // String user_password = auth_value[1];
- // logger_.info("username:" + user_name);
- // // start modification tknall
- // // logger_.info("password:" + user_password);
- // logger_.info("password:XXXXXXXXXXXX");
- // // stop modification tknall
- //
- // HttpSession session = request.getSession();
- // session.setAttribute(SessionAttributes.ATTRIBUTE_USER_NAME, user_name);
- // session.setAttribute(SessionAttributes.ATTRIBUTE_USER_PASSWORD,
- // user_password);
- //
- // dispatch(request, response, "/jsp/signupload.jsp");
- // return;
- // }
- // // start modification tknall
- // } else {
- // String user_name = "";
- // String user_password = "";
- // logger_.info("authenticate:User has not been authenticated!");
- // logger_.info("username: UNKNOWN");
- // logger_.info("password: XXXXXXXXXXXX");
- // HttpSession session = request.getSession();
- // session.setAttribute("uname", user_name);
- // session.setAttribute("upass", user_password);
- // dispatch(request, response, "/jsp/signupload.jsp");
- // }
-
- // request.setAttribute("error", "Falsche Authentifikation");
- // request.setAttribute("cause", "Passwort oder Benutzername ist falsch");
- // dispatch(request, response, "/jsp/error.jsp");
- // // stop modification tknall
- // }
-
/**
* Processes the sign upload.
*
@@ -168,7 +112,6 @@ public class SignServlet extends HttpServlet
{
UploadedData ud = null;
ExternAppInformation exappinf = null;
-// TablePos pos = null;
SignaturePositioning sigpos = null;
// for performance measurement
@@ -176,8 +119,6 @@ public class SignServlet extends HttpServlet
if (statLog.isInfoEnabled()) {
startTime = System.currentTimeMillis();
}
-
-
// check if pdf-as has been called by external webapp
if (request.getParameter(FormFields.FIELD_PDF_URL) != null)
@@ -201,7 +142,6 @@ public class SignServlet extends HttpServlet
if (sig_pos_y != null && sig_pos_p != null) {
try
{
-// pos = new TablePos("y:" + sig_pos_y + ";p:" + sig_pos_p);
sigpos = new SignaturePositioning("y:" + sig_pos_y + ";p:" + sig_pos_p);
}
catch (PDFDocumentException e)
@@ -229,8 +169,6 @@ public class SignServlet extends HttpServlet
ud_extern.file_name = filename;
ud_extern.pdfDataSource = new ByteArrayPdfDataSource(IOUtils.toByteArray(is));
- // ud_extern.pdf = extern_pdf;
-// ud_extern.preview = preview.equalsIgnoreCase("true") ? true : false;
ud_extern.preview = "true".equalsIgnoreCase(preview);
ud_extern.sig_app = sig_app;
ud_extern.sig_mode = sig_mode;
@@ -242,10 +180,8 @@ public class SignServlet extends HttpServlet
}
else
{
-
try
{
-
// tzefferer: modified
// UploadedData ud = retrieveUploadedDataFromRequest(request);
UploadedData ud_form = retrieveUploadedDataFromRequest(request);
@@ -299,7 +235,6 @@ public class SignServlet extends HttpServlet
if (ud.preview)
{
String submit_url = response.encodeURL(request.getContextPath() + "/SignPreview");
-// String signature_data_url = response.encodeURL(WebUtils.addJSessionID(request.getContextPath() + "/RetrieveSignatureData", request));
String signature_data_url = response.encodeURL(WebUtils.buildRetrieveSignatureDataURL(request, response));
request.setAttribute("submit_url", submit_url);
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/VerifyPreviewServlet.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/VerifyPreviewServlet.java
index 243e762..fff6767 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/VerifyPreviewServlet.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/VerifyPreviewServlet.java
@@ -115,150 +115,6 @@ public class VerifyPreviewServlet extends HttpServlet
return SIG_INPUT_PREFIX + num + "_";
}
- // public static void formatPreview(List signature_holders, String connector,
- // HttpServletRequest request, HttpServletResponse response) throws
- // ServletException, IOException
- // {
- // response.setContentType("text/html");
- // response.setCharacterEncoding("UTF-8");
- //
- // PrintWriter writer = response.getWriter();
- //
- // writer.println("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0
- // Transitional//EN\"
- // \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
- // writer.println("<html>");
- // writer.println("<head>");
- // writer.println("<meta http-equiv=\"content-type\" content=\"text/html;
- // charset=UTF-8\" />");
- // writer.println("<title>PDF-AS Amtssignaturen Vorschau</title>");
- // writer.println("<link rel=\"stylesheet\" type=\"text/css\"
- // href=\"/pdf-as/css/styles.css\" />");
- //
- // writer.println("<script type=\"text/javascript\">");
- // writer.println(" function initSigValues()");
- // writer.println(" {");
- // for (int num = 0; num < signature_holders.size(); num++)
- // {
- // SignatureHolder signature_holder = (SignatureHolder)
- // signature_holders.get(num);
- // String name_prefix = generateNamePrefix(num);
- // String java_script =
- // renderRequiredKeysJavaScript(signature_holder.signature_object,
- // name_prefix);
- // writer.println(java_script);
- //
- // }
- // writer.println(" }");
- // writer.println("</script>");
- //
- // writer.println("</head>");
- //
- // writer.println("<body onload=\"initSigValues()\">");
- // writer.println("<div>");
- //
- // writer.println("<h1>PDF-AS Amtssignaturen</h1>");
- //
- // writer.println("<div id=\"nav\">");
- // writer.println("<div id=\"nh\">Vorschau: Dokument Pr&uuml;fen</div>");
- // writer.println("<form action=\"" +
- // response.encodeURL(request.getContextPath() + "/VerifyPreview") + "\"");
- // writer.println(" name=\"submitform\"");
- // writer.println(" enctype=\"multipart/form-data\"");
- // writer.println(" accept-charset=\"UTF-8\"");
- // writer.println(" method=\"post\">");
- // writer.println("<div id=\"ct\">");
- //
- // // writer.println("<input type=\"hidden\" name=\"" + FormFields.FIELD_MODE
- // +
- // // "\" value=\"" + mode + "\" />");
- // writer.println("<input type=\"hidden\" name=\"" +
- // FormFields.FIELD_CONNECTOR + "\" value=\"" + connector + "\" />");
- //
- // // if (mode.equals(FormFields.VALUE_MODE_TEXTUAL))
- // // {
- // // String raw_document_text = ((SignatureHolder)
- // // signature_holders.get(0)).signed_text;
- // // writer.println("<textarea class=\"pr\" cols=\"80\" rows=\"14\" name=\""
- // +
- // // FormFields.FIELD_RAW_DOCUMENT_TEXT + "\">" + raw_document_text +
- // // "</textarea>");
- // // writer.println("<br/>");
- // // }
- //
- // if (signature_holders.size() == 1)
- // {
- // writer.println("<div id=\"sh\">Rekonstruktion der Signaturmarke:</div>");
- // }
- // else
- // {
- // writer.println("<div id=\"sh\">Rekonstruktion der Signaturmarken:</div>");
- // }
- //
- // // this special <div> is only needed because internet explorer doesn't
- // // format the width of the
- // // tables right when the div is not given.
- // // probably this is because the table then tries to calculate the relative
- // // width from the surrounding form object.
- // writer.println("<div class=\"sigprevtablediv\">");
- // int num = 0;
- // Iterator it = signature_holders.iterator();
- // while (it.hasNext())
- // {
- // SignatureHolder signature_holder = (SignatureHolder) it.next();
- //
- // String name_prefix = generateNamePrefix(num);
- //
- // String input_key = name_prefix + FormFields.FIELD_RAW_DOCUMENT_TEXT;
- // if (signature_holder.signature_object.isBinary())
- // {
- // writer.println("<input type=\"hidden\" name=\"" + input_key + "\" value=\""
- // + signature_holder.signed_text + "\" />");
- // }
- // else
- // {
- // writer.println("<div>");
- // writer.println("<textarea class=\"pr\" cols=\"80\" rows=\"14\" name=\"" +
- // input_key + "\">" + signature_holder.signed_text + "</textarea>");
- // writer.println("</div>");
- // }
- //
- // String html = renderRequiredKeys(signature_holder.signature_object,
- // name_prefix, false);
- // writer.println(html);
- //
- // writer.println("<input class=\"ip\" type=\"submit\" value=\"Werte
- // &uuml;bernehmen und pr&uuml;fen...\" onclick=\"document.submitform." +
- // FormFields.FIELD_VERIFY_WHICH + ".value='" + num + "'\" />");
- //
- // num++;
- // }
- // writer.println("</div>");
- //
- // writer.println("<input type=\"hidden\" name=\"" +
- // FormFields.FIELD_VERIFY_WHICH + "\" value=\"xxx\" />");// +
- // // FormFields.VALUE_VERIFY_WHICH_ALL
- // // +
- // // "\"
- // // />");
- // writer.println("<input class=\"ip\" type=\"submit\" value=\"Alle
- // pr&uuml;fen...\" onclick=\"document.submitform." +
- // FormFields.FIELD_VERIFY_WHICH + ".value='" +
- // FormFields.VALUE_VERIFY_WHICH_ALL + "'\" />");
- //
- // writer.println("</div>");
- // writer.println("</form>");
- // writer.println("</div>");
- //
- // writer.println("<a class=\"big\" href=\"/pdf-as/\">zurück</a>");
- //
- // writer.println("</div>");
- // writer.println("</body>");
- //
- // writer.println("</html>");
- //
- // }
-
public static String renderRequiredKeysJavaScript(ServletContext sc,
SignatureInformation signatureInfo, String name_prefix)
{
@@ -368,11 +224,6 @@ public class VerifyPreviewServlet extends HttpServlet
continue;
}
-// if (SignatureTypes.SIG_KZ.equals(key) && value == null)
-// {
-// continue;
-// }
-
writer.println(" <tr>");
writer.println(" <td class=\"pdfascaption\">" + caption + ":</td>");
writer.println(" <td class=\"pdfasvalue\">");
@@ -399,96 +250,6 @@ public class VerifyPreviewServlet extends HttpServlet
dispatch(request, response, "/jsp/results.jsp");
}
- // public static void formatVerifyResults(List results,
- // HttpServletResponse response) throws IOException, SettingNotFoundException
- // {
- // response.setContentType("text/html");
- // response.setCharacterEncoding("UTF-8");
- //
- // PrintWriter writer = response.getWriter();
- //
- // writer.println("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0
- // Transitional//EN\"
- // \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
- // writer.println("<html>");
- // writer.println("<head>");
- // writer.println("<meta http-equiv=\"content-type\" content=\"text/html;
- // charset=UTF-8\" />");
- // writer.println("<title>PDF-AS Amtssignaturen Resultat</title>");
- // writer.println("<link rel=\"stylesheet\" type=\"text/css\"
- // href=\"/pdf-as/css/styles.css\" />");
- // writer.println("</head>");
- //
- // writer.println("<body>");
- // writer.println("<div>");
- //
- // writer.println("<h1>PDF-AS Amtssignaturen</h1>");
- //
- // writer.println("<div id=\"nav\">");
- // writer.println("<div id=\"nh\">Resultat</div>");
- // writer.println("<div id=\"res\">");
- //
- // Iterator it = results.iterator();
- // while (it.hasNext())
- // {
- // SignatureResponse result = (SignatureResponse) it.next();
- // formatSignatureResponse(result, writer);
- //
- // if (it.hasNext())
- // {
- // writer.println("<br />");
- // }
- // }
- //
- // writer.println("</div>");
- // writer.println("</div>");
- //
- // writer.println("<a class=\"big\" href=\"/pdf-as/\">zurück</a>");
- //
- // writer.println("</div>");
- // writer.println("</body>");
- //
- // writer.println("</html>");
- //
- // }
- //
- // public static void formatSignatureResponse(SignatureResponse result,
- // PrintWriter writer) throws SettingNotFoundException
- // {
- // writer.println("<fieldset><legend><b>Zertifikat</b></legend>");
- // writer.println("<table class=\"srt\">");
- // writer.println(" <tr><td>Signator:</td><td class=\"srtd\">" +
- // result.getX509SubjectName() + "</td></tr>");
- // writer.println(" <tr><td>Aussteller:</td><td class=\"srtd\">" +
- // result.getX509IssuerName() + "</td></tr>");
- // writer.println(" <tr><td>Seriennummer:</td><td class=\"srtd\">" +
- // result.getX509SerialNumber() + "</td></tr>");
- // List public_properties = result.getPublicProperties();
- // Iterator it = public_properties.iterator();
- // while (it.hasNext())
- // {
- // String public_property = (String) it.next();
- // writer.println(" <tr><td> Eigenschaft:</td><td class=\"srtd\">" +
- // public_property + "</td></tr>");
- // }
- //
- // writer.println(" <tr><td>Zertifikat:</td><td class=\"srcc_" +
- // result.getCertificateCheckCode() + "\">" + result.getCertificateCheckInfo()
- // + "</td></tr>");
- //
- // writer.println("</table>");
- // writer.println("</fieldset>");
- // writer.println("<fieldset><legend><b>Signatur-Check</b></legend>");
- // writer.println("<div class=\"srsc_" + result.getSignatureCheckCode() +
- // "\">" + result.getSignatureCheckInfo() + "</div>");
- // writer.println("</fieldset>");
- // writer.println("<fieldset><legend><b>Manifest-Check</b></legend>");
- // writer.println("<div class=\"srmc_" +
- // result.getSignatureManifestCheckCode() + "\">" +
- // result.getSignatureManifestCheckInfo() + "</div>");
- // writer.println("</fieldset>");
- // }
-
/**
* Form field name prefix for signature table names
*/
@@ -536,9 +297,6 @@ public class VerifyPreviewServlet extends HttpServlet
{
throw new SignatureException(312, "The selected signature to be verified doesn't exist.");
}
-
-// SignatureHolder holder = (SignatureHolder) si.signature_holders.get(verify_which);
-// si.current_operation = verify_which;
SignatureInformation sigInfo = (SignatureInformation) si.analyzeResult.getSignatures().get(verify_which);
holders_to_verify = new ArrayList();
@@ -548,18 +306,11 @@ public class VerifyPreviewServlet extends HttpServlet
{
if (sigInfo.getSignatureType() == Constants.SIGNATURE_TYPE_BINARY)
{
-// BinarySignatureHolder binary_holder = (BinarySignatureHolder) holder;
response.setContentType("application/pdf");
IOUtils.copy(sigInfo.getSignedData().createInputStream(), response.getOutputStream());
-// StreamUtils.writeInputStreamToOutputStream(binary_holder.getSignedPdf().createInputStream(), response.getOutputStream());
-// response.getOutputStream().write(binary_holder.getSignedPdf(), 0, binary_holder.getSignedPdfLength());
}
else
- // if (holder.getSignatureObject().isTextual())
{
- // formatPreview(holders_to_verify, si.connector, request,
- // response);
-// request.setAttribute(FormFields.FIELD_VERIFY_WHICH, new Integer(verify_which));
PdfAsInternal pdfAsInternal = ApiHelper.getPdfAsInternalFromContext(getServletContext());
String signedText = pdfAsInternal.getSignedText(sigInfo);
dispatchToPreview(request, response, signedText, verify_which);
@@ -638,9 +389,7 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
if (item.getFieldName().equals(FormFields.FIELD_RAW_DOCUMENT_TEXT))
{
- text_to_be_verified = item.getString("UTF-8");
-// String raw_document_text = item.getString("UTF-8");
-// text_to_be_verified = pdfAsInternal.normalizeText(raw_document_text);
+ text_to_be_verified = item.getString("UTF-8");
continue;
}
@@ -663,19 +412,10 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
String key = item.getFieldName();
String value = item.getString("UTF-8");
-// signature_object.setSigValue(key, value);
sigValues.put(key, value);
logger_.debug("sig_obj_number" + key + " = " + value);
}
-// SignatureHolder old_holder = (SignatureHolder) si.signature_holders.get(verify_which);
-// TempDirHelper.deleteDataSourceIfFileBased(old_holder.getDataSource());
-
-// TextDataSource tds = TempDirHelper.placeTextIntoTempDir(text_to_be_verified, "_previewholder.utf8.txt");
-// SignatureHolder new_holder = new TextualSignatureHolder(tds, signature_object);
-
-// si.signature_holders.set(verify_which, new_holder);
-
si.analyzeResult = pdfAsInternal.analyzeFromRawText(text_to_be_verified, sigValues);
if (verify == false)
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/VerifyServlet.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/VerifyServlet.java
index 938f7bf..fbfbcab 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/VerifyServlet.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/VerifyServlet.java
@@ -19,7 +19,6 @@ package at.gv.egiz.pdfas.web.servlets;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
-import java.net.URL;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
@@ -51,7 +50,6 @@ import at.gv.egiz.pdfas.web.FormFields;
import at.gv.egiz.pdfas.web.helper.ApiHelper;
import at.gv.egiz.pdfas.web.helper.LocalRequestHelper;
import at.gv.egiz.pdfas.web.helper.WebSettingsReader;
-import at.gv.egiz.pdfas.web.helper.WebUtils;
import at.gv.egiz.pdfas.web.io.ByteArrayPdfDataSource;
import at.gv.egiz.pdfas.web.io.TextDataSource;
import at.gv.egiz.pdfas.web.session.SessionAttributes;
@@ -103,12 +101,12 @@ public class VerifyServlet extends HttpServlet
*/
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
- // for performance measurement
- long startTime = 0;
- long fileSize = 0;
- if (log.isInfoEnabled()) {
- startTime = System.currentTimeMillis();
- }
+ // for performance measurement
+ long startTime = 0;
+ if (log.isInfoEnabled()) {
+ startTime = System.currentTimeMillis();
+ }
+
try
{
UploadedData ud = retrieveUploadedDataFromRequest(request);
@@ -130,21 +128,11 @@ public class VerifyServlet extends HttpServlet
AnalyzeResult analyzeResult = pdfAs.analyze(analyzeParameters);
si.analyzeResult = analyzeResult;
- // List signature_holders = extractSignatureHoldersFromFile(ud.file_name,
- // ud.file_data);
-// List signature_holders = extractSignatureHolders(ud.dataSource);
-//
-// TempDirHelper.storeTextSignatureHoldersIfApplicable(signature_holders, "_textholder.utf8.txt");
-//
-// si.signature_holders = signature_holders;
-
request.getSession().setAttribute(SessionAttributes.ATTRIBUTE_SESSION_INFORMATION, si);
if (ud.preview)
{
dispatch(request, response, "/jsp/verifylist.jsp");
- // VerifyPreview.formatPreview(signature_holders, connector, request,
- // response);
}
else
{
@@ -156,12 +144,6 @@ public class VerifyServlet extends HttpServlet
return;
}
-// String host = request.getServerName();
- // TODO still required for old communication with MOA-SS/SP
-// URL loc_ref_URL = new URL(WebUtils.addJSessionID(LocalRequestHelper.getLocalContextAddress(request, response) + "/RetrieveSignatureData", request));
-// URL loc_ref_URL = new URL(WebUtils.buildRetrieveSignatureDataURL(request, response));
-// String loc_ref_url = response.encodeURL(loc_ref_URL.toString());
-
VerifyAfterAnalysisParameters verifyAfterAnalysisParameters = new VerifyAfterAnalysisParameters();
verifyAfterAnalysisParameters.setAnalyzeResult(si.analyzeResult);
verifyAfterAnalysisParameters.setSignatureDevice(si.connector);
@@ -243,12 +225,6 @@ public class VerifyServlet extends HttpServlet
continue;
}
- // if (item.getFieldName().equals(FormFields.FIELD_MODE))
- // {
- // mode_fi = item;
- // continue;
- // }
-
if (item.getFieldName().equals(FormFields.FIELD_PREVIEW))
{
preview_fi = item;
@@ -266,13 +242,6 @@ public class VerifyServlet extends HttpServlet
String connector = connector_fi.getString("UTF-8"); //$NON-NLS-1$
- // String mode = mode_fi.getString("UTF-8");
- // if (!mode.equals(FormFields.VALUE_MODE_BINARY) &&
- // !mode.equals(FormFields.VALUE_MODE_TEXTUAL))
- // {
- // throw new ServletException("The mode '" + mode + "' is unrecognized.");
- // }
-
String preview_str = preview_fi.getString("UTF-8"); //$NON-NLS-1$
if (!preview_str.equals(FormFields.VALUE_TRUE) && !preview_str.equals(FormFields.VALUE_FALSE))
{
@@ -311,17 +280,6 @@ public class VerifyServlet extends HttpServlet
if ((upload_fi.getContentType() != null ) && ((upload_fi.getContentType().startsWith("application/pdf") || upload_fi.getContentType().startsWith("application/x-download") )))
{
return new ByteArrayPdfDataSource(upload_fi.get());
-// try
-// {
-// String fileNameSuffix = TempDirHelper.extractFileNameSuffix(upload_fi.getName());
-// PdfDataSource pdfDataSource = TempDirHelper.placePdfIntoTempDir(upload_fi.getInputStream(), fileNameSuffix);
-// return pdfDataSource;
-// }
-// catch (IOException e)
-// {
-// throw new PDFDocumentException(201, "The document could not be placed in the temp dir.", e); //$NON-NLS-1$
-// }
- // byte[] document_bytes = upload_fi.get();
}
try
@@ -336,70 +294,6 @@ public class VerifyServlet extends HttpServlet
throw new PDFDocumentException(201, e);
}
}
-//
-// protected List extractSignatureHolders(DataSource dataSource) throws PresentableException
-// {
-// VerificationFilterParameters parameters = SettingsHelper.readVerificationFilterParametersFromSettings();
-//
-// ExtractionStage es = new ExtractionStage();
-// List signature_holders = es.extractSignatureHolders(dataSource, parameters);
-//
-// // filter out NoSignatureHolders that are possibly present due to the direct call method extractSignatureHolders()
-// List filtered_signature_holders = new ArrayList();
-// Iterator it = signature_holders.iterator();
-// while(it.hasNext()) {
-// SignatureHolder current = (SignatureHolder) it.next();
-// if(!(current instanceof NoSignatureHolder)) {
-// filtered_signature_holders.add(current);
-// }
-// }
-//
-// if (filtered_signature_holders.size() == 0)
-// {
-// throw new PDFDocumentException(ErrorCode.DOCUMENT_NOT_SIGNED, "PDF document not signed."); //$NON-NLS-1$
-// }
-//
-// return filtered_signature_holders;
-// }
-
- // TODO obsolete method - remove
- // protected List extractSignatureHoldersFromFile(String file_name, byte[]
- // data) throws UnsupportedEncodingException, PresentableException
- // {
- // VerificationFilterParameters parameters = new
- // VerificationFilterParametersImpl(false, false, true);
- // ExtractionStage es = new ExtractionStage();
- // // VerificationFilter vf = new VerificationFilter();
- // List signature_holders = null;
- //
- // String extension = extractExtension(file_name);
- //
- // String raw_text = null;
- // if (file_name == null || (extension != null && extension.equals("txt")))
- // //$NON-NLS-1$
- // {
- // raw_text = new String(data, "UTF-8"); //$NON-NLS-1$
- //
- // signature_holders = es.extractSignatureHolders(new
- // TextDataSourceImpl(raw_text), parameters);
- // // signature_holders = vf.extractSignaturesFromPlainText(raw_text);
- // }
- // else
- // {
- // signature_holders = es.extractSignatureHolders(new
- // ByteArrayPdfDataSourceImpl(data), parameters);
- //
- // // signature_holders = vf.extractSignaturesFromPdf(data);
- // }
- //
- // if (signature_holders.size() == 0)
- // {
- // throw new PDFDocumentException(206, "PDF document not signed.");
- // //$NON-NLS-1$
- // }
- //
- // return signature_holders;
- // }
/**
* Extracts the extension from a file name string.
@@ -438,7 +332,6 @@ public class VerifyServlet extends HttpServlet
protected String file_name = null;
protected DataSource dataSource = null;
- // protected byte[] file_data = null;
}
/**