diff options
author | pdanner <pdanner@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c> | 2010-12-06 18:23:49 +0000 |
---|---|---|
committer | pdanner <pdanner@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c> | 2010-12-06 18:23:49 +0000 |
commit | 79777d04cf64aa06388bb2027f5e1001015471f3 (patch) | |
tree | 4c70ec8695659a14aa862f98d50f70b1299c090b /pdf-as-web/src/main/java/at/gv | |
parent | ebf049402a10f8a4cf5612496d5c6daf64a7081a (diff) | |
download | pdf-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')
16 files changed, 77 insertions, 1056 deletions
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/CurrentLocalOperation.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/CurrentLocalOperation.java index 96194bf..c65fc71 100644 --- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/CurrentLocalOperation.java +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/CurrentLocalOperation.java @@ -43,11 +43,6 @@ public class CurrentLocalOperation */
public int current_operation = 0;
-// /**
-// * Tells, if the current local request has been finished.
-// */
-// public boolean finished = false;
-
/**
* @see at.gv.egiz.pdfas.web.LocalOperation#isFinished()
*/
@@ -64,14 +59,6 @@ public class CurrentLocalOperation return this.requests[this.current_operation];
}
-// /**
-// * @see at.gv.egiz.pdfas.web.LocalOperation#getCurrentSignatureHolder()
-// */
-// public SignatureHolder getCurrentSignatureHolder()
-// {
-// return (SignatureHolder) this.holders_to_be_verified.get(this.current_operation);
-// }
-
/**
* @see at.gv.egiz.pdfas.web.LocalOperation#finishCurrentOperation(java.util.Properties)
*/
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/ApiHelper.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/ApiHelper.java index a0f22fd..04dabaa 100644 --- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/ApiHelper.java +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/ApiHelper.java @@ -22,6 +22,13 @@ public class ApiHelper { public static final String INTERNAL_PDF_AS_OBJECT = "INTERNAL_PDF_AS_OBJECT";
+ /**
+ * Instantiate the {@link PdfAs} implementation.
+ *
+ * @param file config directory
+ * @return
+ * @throws WebException
+ */
public static PdfAs createApiObject(File file) throws WebException {
try {
Class pdfAsClass = Class.forName("at.gv.egiz.pdfas.impl.api.PdfAsObject");
@@ -45,7 +52,13 @@ public class ApiHelper { throw new WebException(e);
}
}
-
+
+ /**
+ * Instantiate the {@link PdfAsInternal} implementation.
+ *
+ * @return
+ * @throws WebException
+ */
public static PdfAsInternal createInternalApiObject() throws WebException {
try {
Class pdfAsClass = Class.forName("at.gv.egiz.pdfas.impl.api.internal.PdfAsInternalObject");
@@ -62,10 +75,22 @@ public class ApiHelper { }
}
+ /**
+ * Retrieve the {@link PdfAs} object from the {@link ServletContext}
+ *
+ * @param servletContext
+ * @return
+ */
public static PdfAs getPdfAsFromContext(ServletContext servletContext) {
return (PdfAs)servletContext.getAttribute(PDF_AS_OBJECT);
}
+ /**
+ * Retrieve the {@link PdfAsInternal} object from the {@link ServletContext}
+ *
+ * @param servletContext
+ * @return
+ */
public static PdfAsInternal getPdfAsInternalFromContext(ServletContext servletContext) {
return (PdfAsInternal)servletContext.getAttribute(INTERNAL_PDF_AS_OBJECT);
}
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/LocalRequestHelper.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/LocalRequestHelper.java index 82b3983..9717662 100644 --- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/LocalRequestHelper.java +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/LocalRequestHelper.java @@ -21,7 +21,6 @@ import java.io.IOException; import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
-import java.util.Properties;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -84,19 +83,14 @@ public abstract class LocalRequestHelper public static String processLocalSign(PdfAsInternal pdfAsInternal, SignSessionInformation si, HttpServletRequest request, HttpServletResponse response) throws IOException, PresentableException
{
String host = request.getServerName();
-// URL loc_ref_URL = new URL(WebUtils.addJSessionID(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());
String sign_request = pdfAsInternal.prepareLocalSignRequest(si.signParameters, loc_ref_url, si.sdi);
-// LocalConnector c = ConnectorChooser.chooseLocalConnectorForSign(si.connector, si.type, loc_ref_url);
-// String sign_request = c.prepareSignRequest(si.si.getSignatureData());
String local_request_url = pdfAsInternal.getLocalServiceAddress(si.type, si.connector);
-// String local_request_url = getLocalServiceAddress(si.type, si.connector);
si.localRequest = new LocalRequest(local_request_url, sign_request);
si.outputAvailable = false;
-// si.response_properties = null;
URL data_URL = new URL(request.getScheme(), host, request.getServerPort(), WebUtils.addJSessionID(request.getContextPath() + "/DataURL", request));
String data_url = response.encodeURL(data_URL.toString());
@@ -106,46 +100,6 @@ public abstract class LocalRequestHelper request.setAttribute("data_url", data_url);
return NULL_REQUEST_PAGE_JSP;
-
- // TODO old code - remove
- //
- // LocalConnector local_conn = (LocalConnector)
- // ConnectorFactory.createConnector(si.connector);
- //
- //
- // // refactor WEB
- // String document_text = "fixme"; //si.iui.document_text;
- // String request_string = local_conn.prepareSignRequest(si.user_name,
- // document_text, si.type);
- // String request_url = local_conn.getSignURL(si.type);
- //
- // LocalRequest local_request = new LocalRequest(request_url,
- // request_string);
- // List local_requests = new ArrayList();
- // local_requests.add(local_request);
- //
- // // ByteArrayOutputStream baos = new ByteArrayOutputStream();
- // // ObjectOutputStream oos = new ObjectOutputStream(baos);
- // // oos.writeObject(local_requests);
- // // oos.close();
- // // baos.close();
- //
- // si.requests = new LocalRequest[1];
- // si.requests[0] = new LocalRequest(local_conn.getSignURL(si.type),
- // request_string);
- // si.current_operation = 0;
- // si.response_properties = new Properties[1];
- // si.response_properties[0] = null;
- //
- // // SessionTable.put(si);
- // request.getSession().setAttribute(SessionAttributes.ATTRIBUTE_SESSION_INFORMATION,
- // si);
- //
- // // byte [] requests_bytes = baos.toByteArray();
- // // String base64 = CodingHelper.encodeBase64(requests_bytes);
- //
- // LocalRequestHelper.prepareDispatchToLocalConnectionPage(si.requests[0],
- // request, response);
}
/**
@@ -177,10 +131,8 @@ public abstract class LocalRequestHelper si.currentLocalOperation.response_xmls = new String[si.currentLocalOperation.requests.length];
si.currentLocalOperation.current_operation = 0;
-// si.finished = false;
String host = request.getServerName();
-// URL loc_ref_URL = new URL(WebUtils.addJSessionID(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());
@@ -227,48 +179,6 @@ public abstract class LocalRequestHelper response.getWriter().println("<ok/>");
}
- /**
- * Prepares the dispatch to the local data connection page.
- *
- * <p>
- * The calling servlet just has to dispatch to the jsp after calling this
- * method.
- * </p>
- *
- * @param local_request
- * The local request. Basically this contains the local service's
- * target URL and the XML request string.
- * @param response
- * The HttpServletResponse to write this page to.
- * @throws IOException
- * Forwarded exception.
- * @throws SignatureException
- * Forwarded exception.
- * @throws NormalizeException
- * Forwarded exception.
- */
- public static void prepareDispatchToLocalConnectionPage(LocalRequest local_request, HttpServletRequest request, HttpServletResponse response) throws IOException, SignatureException,
- NormalizeException
- {
- response.setContentType("text/html");
- response.setCharacterEncoding("UTF-8");
-
- String local_request_url = local_request.getUrl();
-
- String quoted_request = makeStringHTMLReady(local_request.getRequestString());
-
- String host = request.getServerName(); // "129.27.153.77"
- URL data_URL = new URL(request.getScheme(), host, request.getServerPort(), request.getContextPath() + "/AsynchronousDataResponder");
- String data_url = response.encodeURL(data_URL.toString());
- URL redirect_URL = new URL(request.getScheme(), host, request.getServerPort(), request.getContextPath() + "/AsynchronousRedirectResponder");
- String redirect_url = response.encodeURL(redirect_URL.toString());
-
- request.setAttribute("local_request_url", local_request_url);
- request.setAttribute("quoted_request", quoted_request);
- request.setAttribute("data_url", data_url);
- request.setAttribute("redirect_url", redirect_url);
- }
-
public static String makeStringHTMLReady(String input)
{
String output = input;
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/SignServletHelper.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/SignServletHelper.java index 779b37b..3f2ac6c 100644 --- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/SignServletHelper.java +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/SignServletHelper.java @@ -206,35 +206,19 @@ public class SignServletHelper }
IOUtils.write(si.signedPdf, response.getOutputStream());
-// TempDirHelper.writeDataSinkToHttpResponse(si.output, response);
- //response.getOutputStream().write(sign_result.getData());
// tzefferer: added else-block
}
else
{
- /**
+ /*
* 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 = si.signedPdf;
-// byte [] signed_pdf = null;
-// if (si.output instanceof FileBasedDataSink)
-// {
-// FileBasedDataSink fbds = (FileBasedDataSink)si.output;
-// signed_pdf = new byte [(int)fbds.getFile().length()];
-// FileInputStream fis = new FileInputStream(fbds.getFile());
-// fis.read(signed_pdf);
-// fis.close();
-// }
-// else
-// {
-// ByteArrayDataSink bads = (ByteArrayDataSink)si.output;
-// signed_pdf = bads.getByteArray();
-// }
+ log.debug("External webapp invocation detected.");
+ byte [] signed_pdf = si.signedPdf;
HttpSession session = request.getSession();
PDFContainer entry = new PDFContainer(signed_pdf, si.exappinf.pdf_id);
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/io/ByteArrayDataSink.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/io/ByteArrayDataSink.java index 4bdb724..6338add 100644 --- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/io/ByteArrayDataSink.java +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/io/ByteArrayDataSink.java @@ -6,6 +6,12 @@ import java.io.OutputStream; import at.gv.egiz.pdfas.api.io.DataSink;
+/**
+ * A simple implementation of the {@link DataSink} interface writing to a byte[].
+ *
+ * @author exthex
+ *
+ */
public class ByteArrayDataSink implements DataSink {
private ByteArrayOutputStream baos;
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/io/ByteArrayPdfDataSource.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/io/ByteArrayPdfDataSource.java index ae53397..741cfce 100644 --- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/io/ByteArrayPdfDataSource.java +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/io/ByteArrayPdfDataSource.java @@ -6,6 +6,7 @@ import java.io.InputStream; import at.gv.egiz.pdfas.api.io.DataSource;
/**
+ * A simple implementation of the {@link DataSource} interface reading from a byte[].
*
* @author exthex
*
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/io/TextDataSource.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/io/TextDataSource.java index de5c7a8..2a2aa38 100644 --- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/io/TextDataSource.java +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/io/TextDataSource.java @@ -7,6 +7,7 @@ import java.io.UnsupportedEncodingException; import at.gv.egiz.pdfas.api.io.DataSource;
/**
+ * A simple implementation of the {@link DataSource} interface reading from a String.
*
* @author exthex
*
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ü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
- // übernehmen und prü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ü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;
}
/**
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/session/SignSessionInformation.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/session/SignSessionInformation.java index 94428a4..90378d9 100644 --- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/session/SignSessionInformation.java +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/session/SignSessionInformation.java @@ -101,11 +101,6 @@ public class SignSessionInformation implements HttpSessionBindingListener, Seria */
public LocalRequest localRequest = null;
-// /**
-// * The response properties of the local request.
-// */
-// public Properties response_properties = null;
-
/**
* Tells if the sign request has been processed and the signed document is
* available in the DataSink.
@@ -117,12 +112,24 @@ public class SignSessionInformation implements HttpSessionBindingListener, Seria */
public SignParameters signParameters;
+ /**
+ * The Result of the sign process
+ */
public SignResult signResult;
+ /**
+ * The signed pdf data.
+ */
public byte[] signedPdf;
+ /**
+ * The xml response of the local BKU/Mocca
+ */
public String xmlResponse;
+ /**
+ * Local BKU/Mocca parameters used to identify the BKU
+ */
public LocalBKUParams localBKUParams;
@@ -141,14 +148,5 @@ public class SignSessionInformation implements HttpSessionBindingListener, Seria {
log.debug("Unbound SignSessionInformation from session (ID=" + event.getSession().getId() + ").");
- //TODO needed?
-// if (this.pdfDataSource != null)
-// {
-// TempDirHelper.deleteDataSourceIfFileBased(this.pdfDataSource);
-// }
-// if (this.output != null)
-// {
-// TempDirHelper.deleteDataSinkIfFileBased(this.output);
-// }
}
}
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/session/VerifySessionInformation.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/session/VerifySessionInformation.java index bbaa647..fad3b8f 100644 --- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/session/VerifySessionInformation.java +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/session/VerifySessionInformation.java @@ -72,7 +72,6 @@ public class VerifySessionInformation implements HttpSessionBindingListener, Ser /**
* The original, uploaded pdf.
*/
- //public FileBasedPdfDataSourceImpl pdfDataSource = null;
public DataSource inputDataSource = null;
/**
@@ -80,21 +79,6 @@ public class VerifySessionInformation implements HttpSessionBindingListener, Ser */
public String type = null;
-// /**
-// * The user name.
-// */
-// public String user_name = null;
-//
-// /**
-// * The password.
-// */
-// public String user_password = null;
-
-// /**
-// * All SignatureHolders extracted from the document.
-// */
-// public List signature_holders;
-
/**
* Keeps track of the currently running local operation.
*
@@ -104,66 +88,22 @@ public class VerifySessionInformation implements HttpSessionBindingListener, Ser */
public CurrentLocalOperation currentLocalOperation = null;
-// /**
-// * This is used only for MOA loc-ref web verify.
-// */
-// public SignatureHolder moa_holder;
-
-
-// /**
-// * The incremental update information that has been extracted from the given
-// * PDF document.
-// */
-// public IncrementalUpdateInformation iui;
-
-// public SignatorInformation si = null;
-
-// public FileBasedDataSink output = null;
-
-
-// /**
-// * Copy of signature holders. It's needed by BKU when we try to verify single by single
-// * signature.
-// */
-// public List copy_of_signature_holders;
-
-// /**
-// * The suggested filename.
-// */
-// public String filename;
-//
-// /**
-// * Tells, if the file download should be done inline or as attachment.
-// */
-// public boolean download_inline;
-
-//// /**
-//// * The sign result to be passed back to the user.
-//// */
-//// public SignResult sign_result;
-//
-// public boolean isSignFinished = false;
-
-
-
/**
* Object containing information about the calling webapplication.
* @author: Thomas Zefferer
*/
public ExternAppInformation exappinf;
+ /**
+ * The result of the analyze call.
+ */
public AnalyzeResult analyzeResult;
+ /**
+ * Results of the verify process.
+ */
public VerifyResults verifyResults;
-// /**
-// * Information about the signature position
-// * @author: Thomas Zefferer
-// */
-// public TablePos pos ;
-
-
-
/**
* @see javax.servlet.http.HttpSessionBindingListener#valueBound(javax.servlet.http.HttpSessionBindingEvent)
*/
@@ -178,21 +118,6 @@ public class VerifySessionInformation implements HttpSessionBindingListener, Ser public void valueUnbound(HttpSessionBindingEvent event)
{
log.debug("Unbound SignSessionInformation from session.");
-
- //TODO needed?
-// if (this.inputDataSource != null)
-// {
-// TempDirHelper.deleteDataSourceIfFileBased(this.inputDataSource);
-// }
-// if (this.signature_holders != null)
-// {
-// Iterator it = this.signature_holders.iterator();
-// while (it.hasNext())
-// {
-// SignatureHolder sh = (SignatureHolder) it.next();
-// TempDirHelper.deleteDataSourceIfFileBased(sh.getDataSource());
-// }
-// }
}
}
|