aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/DataURLServlet.java808
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/SignServlet.java192
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/VerifyServlet.java45
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/session/SignSessionInformation.java24
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/session/VerifySessionInformation.java17
5 files changed, 612 insertions, 474 deletions
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 8fa058b..b167541 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
@@ -74,347 +74,471 @@ import at.knowcenter.wag.egov.egiz.exceptions.SignatureException;
/**
* @author wprinz
- *
+ *
*/
-public class DataURLServlet extends HttpServlet
-{
-
- /**
- * SVUID.
- */
- private static final long serialVersionUID = -5846618335843762752L;
-
- /**
- * The log.
- */
- private static Log log = LogFactory.getLog(DataURLServlet.class);
-
- protected void dispatch(HttpServletRequest request,
- HttpServletResponse response, String resource) throws ServletException, IOException
- {
- dispatch(request, response, resource, getServletContext());
- }
-
- protected static void dispatch(HttpServletRequest request,
- HttpServletResponse response, String resource, ServletContext context) throws ServletException, IOException
- {
- response.setContentType("text/html");
- response.setCharacterEncoding("UTF-8");
-
- RequestDispatcher disp = context.getRequestDispatcher(resource);
- disp.forward(request, response);
- }
-
- protected void dispatchToResults(VerifyResults results, HttpServletRequest request,
- HttpServletResponse response, String backToListURL) throws ServletException, IOException
- {
- request.setAttribute("results", results);
- request.setAttribute("btlurl", backToListURL);
- dispatch(request, response, "/jsp/results.jsp");
- }
-
- protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- this.doPost(req, resp);
- }
-
- private static void temporaryRedirect(String redirectURL, HttpServletResponse response) throws IOException {
- String encodedRedirect = response.encodeRedirectURL(redirectURL);
- response.addHeader("Location", encodedRedirect);
- response.setContentType("text/xml");
- response.setStatus(HttpServletResponse.SC_TEMPORARY_REDIRECT);
- String nop = "<?xml version='1.0' encoding='UTF-8'?><NullOperationRequest xmlns='http://www.buergerkarte.at/namespaces/securitylayer/1.2#'/>";
- PrintWriter pw = response.getWriter();
- response.setCharacterEncoding("UTF-8");
- response.setContentLength(nop.getBytes("UTF-8").length);
- log.debug("Redirecting via NullOperationRequest to " + encodedRedirect + ".");
- pw.println(nop);
- pw.flush();
- pw.close();
- }
-
-/**
- * @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest,
- * javax.servlet.http.HttpServletResponse)
- */
- protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
- {
- log.debug("Data URL is accessed."); //$NON-NLS-1$
-
- try
- {
- Object sessionObject = SessionHelper.getSession(request);
- // obsolete since EncodingFilter is set in web.xml
- checkRequestCharacterEncoding(request);
-
- if (sessionObject instanceof SignSessionInformation)
- {
- SignSessionInformation si = (SignSessionInformation)sessionObject;
- log.debug("Vor process sign:...");
- processSign(request, response, si);
- log.debug("Nach process sign...");
- }
- else
- {
- VerifySessionInformation si = (VerifySessionInformation) sessionObject;
- processVerify(request, response, si);
- }
-
- }
- catch (ExternalErrorException f) {
- log.error(f.getMessage(), f);
- HttpSession session = request.getSession(true);
- session.setAttribute(SignServlet.ERROR_WITHIN_IFRAME, "false");
- log.debug("Attribute ERROR_WITHIN_IFRAME: "+session.getAttribute(SignServlet.ERROR_WITHIN_IFRAME));
- SignServlet.prepareDispatchToErrorPage(f, request);
- dispatch(request, response, "/jsp/error.jsp");
- }
- catch (PdfAsException e)
- {
- log.error(e.getMessage(), e);
- SignServlet.prepareDispatchToErrorPage(e, request);
- dispatch(request, response, "/jsp/error.jsp");
- }
-
- log.debug("DataURL access finished."); //$NON-NLS-1$
- }
-
- protected void checkRequestCharacterEncoding(HttpServletRequest request) throws UnsupportedEncodingException
- {
- if (request.getCharacterEncoding() == null || request.getCharacterEncoding().length() <= 0) //$NON-NLS-1$
- {
- log.info("The BKU didn't set a character encoding for the request."); //$NON-NLS-1$
-
- log.info("Manually setting character encoding to UTF-8"); //$NON-NLS-1$
- request.setCharacterEncoding("UTF-8"); //$NON-NLS-1$
- }
- }
-
- protected boolean isNullResponse(String xml_response)
- {
- return xml_response != null && xml_response.indexOf("NullOperationResponse") != -1;
- }
-
- private static String retrieveXMLResponse(HttpServletRequest request) throws ServletException {
- log.debug("Trying to fetch XMLResponse...");
- String xml_response = null;
- if (ServletFileUpload.isMultipartContent(request)) {
- log.debug("Response is multipart.");
- FileItemFactory factory = new DiskFileItemFactory();
- ServletFileUpload upload = new ServletFileUpload(factory);
- try {
- List items = upload.parseRequest(request);
- Iterator iter = items.iterator();
- while (iter.hasNext()) {
- FileItem item = (FileItem) iter.next();
- if (item.isFormField() && "XMLResponse".equals(item.getFieldName())) {
- log.debug("XMLResponse part found.");
- xml_response = item.getString();
- break;
- }
- }
- } catch (FileUploadException e) {
- throw new ServletException(e);
- }
- } else {
- xml_response = request.getParameter("XMLResponse");
- }
- log.debug("XMLResponse = " + xml_response);
- return xml_response;
- }
-
- protected void processSign(HttpServletRequest request, HttpServletResponse response, SignSessionInformation si) throws ServletException, IOException, PdfAsException
- {
- log.trace("processSign");
-
- String xml_response = retrieveXMLResponse(request);
-
- PdfAsInternal pdfAsInternal = ApiHelper.getPdfAsInternalFromContext(getServletContext());
-
- String server = request.getHeader("server");
- String userAgent = request.getHeader("user-agent");
- String signatureLayout = request.getHeader(Constants.BKU_HEADER_SIGNATURE_LAYOUT);
-
- String connector = si.connector;
- String url = "";
-
- if (si.connector.equals(Constants.SIGNATURE_DEVICE_BKU)) {
- url = SettingsReader.getInstance().getSetting("bku.sign.url");
- }
- else if (si.connector.equals(Constants.SIGNATURE_DEVICE_MOC)) {
- url = SettingsReader.getInstance().getSetting("moc.sign.url");
- }
- else if (si.connector.equals(Constants.SIGNATURE_DEVICE_MOBILE)) {
- url = SettingsReader.getInstance().getSetting("mobile.sign.url");
- }
- else {
- url = SettingsReader.getInstance().getSetting("mobiletest.sign.url");
- }
-
- log.debug("Url ist: "+url);
- log.debug("Server ist: "+server);
- log.debug("UserAgent: "+userAgent);
- log.debug("Layout ist: "+signatureLayout);
-
- //rpiazzi added
- //When choosing local CCS (a-trust 1.3.3.3 and higher) it seems that more requests to this servlet are sent from
- //CCS. Therefore the first request (with no information about CCS in the headers) has to be ignored...
- if (((server==null) && (userAgent==null) && (signatureLayout==null) || (xml_response==null))) {
- log.debug("Received response with none of the following header fields: \"server\", \"user-agent\", \""+Constants.BKU_HEADER_SIGNATURE_LAYOUT+"\"");
- log.debug("This is probably the empty servlet call when local CCS and a-trust CCS version >1.3.3.2 is choosen. In this case the right call of this servlet will follow soon!");
- log.debug("Server is: "+server);
- log.debug("UserAgent is: "+userAgent);
- log.debug("SignatureLayout is: "+signatureLayout);
- log.debug("xml_response is: "+xml_response);
- }
- //end added
- else {
- LocalBKUParams bkuParams = new LocalBKUParams(server, userAgent, signatureLayout);
- si.localBKUParams = bkuParams;
-
- pdfAsInternal.verifyBKUSupport(bkuParams);
-
- if (isNullResponse(xml_response))
- {
- log.debug("Received a NullOperationResponse -> answering with the first request."); //$NON-NLS-1$
-
- //assert si.outputAvailable == false;
- //assert si.xmlResponse == null;
-
- log.debug("There are still requests to be performed -> answering with request."); //$NON-NLS-1$
-
- LocalRequest local_request = si.localRequest;
-
- String request_string = local_request.getRequestString();
-
- log.debug("request = " + request_string);
- response.setContentType("text/xml");
- response.setCharacterEncoding("UTF-8");
- response.getWriter().println(request_string);
- }
- else if (xml_response != null)
- {
- log.debug("Received a normal response -> storing the response."); //$NON-NLS-1$
-
- si.xmlResponse = xml_response;
-
- log.debug("All requests have been processed -> processing the responses."); //$NON-NLS-1$
-
- // Sign
-
- if (!si.outputAvailable)
- {
- PdfAs pdfAs = ApiHelper.getPdfAsFromContext(getServletContext());
- SignServletHelper.finishLocalSign(pdfAs, pdfAsInternal, si);
- SigningTimeHelper.checkSigningTimeAgainstHostTime(si.sdi.getSignDate());
- si.outputAvailable = true;
- }
-
- if (si.output.getMimeType().equals("text/xml") && si.outputAvailable)
- {
- // For "detached" signatures, the return value (data sink) is the response xml,
- // but when passed through the BKU it is interpreted as another request
- // which will generate a return code 1501
- // Then PDF-AS would answer with the response as well generating
- // another 1501 and so forth.
- // Therefor return it as TXT.
- 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(new String(si.signedPdf, "UTF-8"));
- }
- else
- {
- // tzefferer: If PDF-AS has been called by an external web-application, we do not
- // redirect to download.jsp but return the sign-response immediately
- if (si.exappinf != null) {
- log.debug("Entering external application interface mode. Skipping redirection to download page.");
- SignServletHelper.returnSignResponse(si, request, response);
-
- // Not needed due to redirection of returnSignResponse.
- // Just to clarify that there must not be any code after returnSignResponse.
- return;
- } else {
- log.debug("Preparing download page.");
- HttpSession session = request.getSession(true);
- log.debug("Putting signed document into session (" + session.getId() + ").");
- session.setAttribute(SessionAttributes.SIGNED_PDF_DOCUMENT, si);
- String downloadURL = response.encodeRedirectURL(LocalRequestHelper.getLocalContextAddress(request, response) + "/ProvidePDF");
- log.debug("Creating download URL \"" + downloadURL + "\".");
- session.setAttribute(SessionAttributes.DOWNLOAD_URL_FOR_SIGNED_PDF_DOCUMENT, downloadURL);
- temporaryRedirect(response.encodeRedirectURL(LocalRequestHelper.getLocalContextAddress(request, response) + "/jsp/download.jsp") , response);
-
- // Not needed due to temporaryRedirect.
- // Just to clarify that there must not be any code after temporaryRedirect.
- return;
- }
-
- // do not insert any code within this else block !
- }
- } else {
- log.debug("No XMLResponse found. Do nothing.");
- }
- }
-
-
- }
-
- protected void processVerify(HttpServletRequest request, HttpServletResponse response, VerifySessionInformation si) throws ServletException, IOException, ConnectorException, SignatureException
- {
- log.trace("processVerify");
-
- String xml_response = request.getParameter("XMLResponse"); //$NON-NLS-1$
- log.debug("xml_response = " + xml_response); //$NON-NLS-1$
-
- if (isNullResponse(xml_response))
- {
- log.debug("Received a NullOperationResponse -> answering with the first request."); //$NON-NLS-1$
-
- //assert si.currentLocalOperation.current_operation == 0;
- }
- else
- {
- log.debug("Recieved a normal response -> storing the response."); //$NON-NLS-1$
-
- si.currentLocalOperation.finishCurrentOperation(xml_response);
- }
-
- if (!si.currentLocalOperation.isFinished())
- {
- log.debug("There are still requests to be performed -> answering with request #" + si.currentLocalOperation.current_operation); //$NON-NLS-1$
-
- LocalRequest local_request = si.currentLocalOperation.getCurrentLocalRequest();
-
- String request_string = local_request.getRequestString();
-
- response.setContentType("text/xml");
- response.setCharacterEncoding("UTF-8");
- response.getWriter().println(request_string);
- }
- else
- {
- log.debug("All requests have been processed -> processing the responses."); //$NON-NLS-1$
-
-
- PdfAsInternal pdfAsInternal = ApiHelper.getPdfAsInternalFromContext(getServletContext());
- final ArrayList resList = new ArrayList();
- for (int i = 0; i < si.currentLocalOperation.response_xmls.length; i++)
- {
- SignatureInformation sigInfo = (SignatureInformation) si.currentLocalOperation.signaturesToBeverified.get(i);
- VerifyResult result = pdfAsInternal.finishLocalVerify(sigInfo, si.connector, si.type, "loc ref content not needed here", si.currentLocalOperation.response_xmls[i]);
- resList.add(result);
- }
-
- 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);
- }
- }
+public class DataURLServlet extends HttpServlet {
+
+ /**
+ * SVUID.
+ */
+ private static final long serialVersionUID = -5846618335843762752L;
+
+ /**
+ * The log.
+ */
+ private static Log log = LogFactory.getLog(DataURLServlet.class);
+
+ // stat Log
+ private static Log statLog = LogFactory.getLog("statistic");
+
+ protected void dispatch(HttpServletRequest request,
+ HttpServletResponse response, String resource)
+ throws ServletException, IOException {
+ dispatch(request, response, resource, getServletContext());
+ }
+
+ protected static void dispatch(HttpServletRequest request,
+ HttpServletResponse response, String resource,
+ ServletContext context) throws ServletException, IOException {
+ response.setContentType("text/html");
+ response.setCharacterEncoding("UTF-8");
+
+ RequestDispatcher disp = context.getRequestDispatcher(resource);
+ disp.forward(request, response);
+ }
+
+ protected void dispatchToResults(VerifyResults results,
+ HttpServletRequest request, HttpServletResponse response,
+ String backToListURL) throws ServletException, IOException {
+ request.setAttribute("results", results);
+ request.setAttribute("btlurl", backToListURL);
+ dispatch(request, response, "/jsp/results.jsp");
+ }
+
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ this.doPost(req, resp);
+ }
+
+ private static void temporaryRedirect(String redirectURL,
+ HttpServletResponse response) throws IOException {
+ String encodedRedirect = response.encodeRedirectURL(redirectURL);
+ response.addHeader("Location", encodedRedirect);
+ response.setContentType("text/xml");
+ response.setStatus(HttpServletResponse.SC_TEMPORARY_REDIRECT);
+ String nop = "<?xml version='1.0' encoding='UTF-8'?><NullOperationRequest xmlns='http://www.buergerkarte.at/namespaces/securitylayer/1.2#'/>";
+ PrintWriter pw = response.getWriter();
+ response.setCharacterEncoding("UTF-8");
+ response.setContentLength(nop.getBytes("UTF-8").length);
+ log.debug("Redirecting via NullOperationRequest to " + encodedRedirect
+ + ".");
+ pw.println(nop);
+ pw.flush();
+ pw.close();
+ }
+
+ /**
+ * @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest,
+ * javax.servlet.http.HttpServletResponse)
+ */
+ protected void doPost(HttpServletRequest request,
+ HttpServletResponse response) throws ServletException, IOException {
+ log.debug("Data URL is accessed."); //$NON-NLS-1$
+
+ Object sessionObject = null;
+ Long startTime = Long.valueOf(0);
+ try {
+ startTime = (Long) request.getAttribute("START_TIME_STAT");
+ sessionObject = SessionHelper.getSession(request);
+ // obsolete since EncodingFilter is set in web.xml
+ checkRequestCharacterEncoding(request);
+
+ if (sessionObject instanceof SignSessionInformation) {
+ SignSessionInformation si = (SignSessionInformation) sessionObject;
+ log.debug("Vor process sign:...");
+ processSign(request, response, si);
+ log.debug("Nach process sign...");
+ } else {
+ VerifySessionInformation si = (VerifySessionInformation) sessionObject;
+ processVerify(request, response, si);
+ }
+ } catch (ExternalErrorException f) {
+ log.error(f.getMessage(), f);
+ HttpSession session = request.getSession(true);
+ session.setAttribute(SignServlet.ERROR_WITHIN_IFRAME, "false");
+ log.debug("Attribute ERROR_WITHIN_IFRAME: "
+ + session.getAttribute(SignServlet.ERROR_WITHIN_IFRAME));
+ SignServlet.prepareDispatchToErrorPage(f, request);
+ dispatch(request, response, "/jsp/error.jsp");
+ if (statLog.isInfoEnabled()) {
+ long endTime = System.currentTimeMillis();
+ // String toReport = "SIGN;" + si.mode + ";" + si.filename +
+ // ";"+ fileSize + ";" +
+
+ String toReport = null;
+ if (sessionObject != null) {
+ if (sessionObject instanceof SignSessionInformation) {
+ SignSessionInformation si = (SignSessionInformation) sessionObject;
+ toReport = "SIGN;" + si.mode + ";" + si.connector + ";"
+ + si.pdfDataSource.getLength() + ";"
+ + (endTime - si.startTime) + ";ERROR";
+ } else {
+ VerifySessionInformation si = (VerifySessionInformation) sessionObject;
+ toReport = "VERIFY;" + si.mode + ";" + si.connector
+ + ";" + (endTime - si.startTime) + ";ERROR";
+ }
+ }
+
+ statLog.info(toReport);
+ }
+ } catch (PdfAsException e) {
+ log.error(e.getMessage(), e);
+ SignServlet.prepareDispatchToErrorPage(e, request);
+ dispatch(request, response, "/jsp/error.jsp");
+ if (statLog.isInfoEnabled()) {
+ long endTime = System.currentTimeMillis();
+ // String toReport = "SIGN;" + si.mode + ";" + si.filename +
+ // ";"+ fileSize + ";" +
+ String toReport = null;
+ if (sessionObject != null) {
+ if (sessionObject instanceof SignSessionInformation) {
+ SignSessionInformation si = (SignSessionInformation) sessionObject;
+ toReport = "SIGN;" + si.mode + ";" + si.connector + ";"
+ + si.pdfDataSource.getLength() + ";"
+ + (endTime - si.startTime) + ";ERROR";
+ } else {
+ VerifySessionInformation si = (VerifySessionInformation) sessionObject;
+ toReport = "VERIFY;" + si.mode + ";" + si.connector
+ + ";" + (endTime - si.startTime) + ";ERROR";
+ }
+ }
+
+ statLog.info(toReport);
+ }
+ }
+
+ log.debug("DataURL access finished."); //$NON-NLS-1$
+ }
+
+ protected void checkRequestCharacterEncoding(HttpServletRequest request)
+ throws UnsupportedEncodingException {
+ if (request.getCharacterEncoding() == null
+ || request.getCharacterEncoding().length() <= 0) //$NON-NLS-1$
+ {
+ log.info("The BKU didn't set a character encoding for the request."); //$NON-NLS-1$
+
+ log.info("Manually setting character encoding to UTF-8"); //$NON-NLS-1$
+ request.setCharacterEncoding("UTF-8"); //$NON-NLS-1$
+ }
+ }
+
+ protected boolean isNullResponse(String xml_response) {
+ return xml_response != null
+ && xml_response.indexOf("NullOperationResponse") != -1;
+ }
+
+ private static String retrieveXMLResponse(HttpServletRequest request)
+ throws ServletException {
+ log.debug("Trying to fetch XMLResponse...");
+ String xml_response = null;
+ if (ServletFileUpload.isMultipartContent(request)) {
+ log.debug("Response is multipart.");
+ FileItemFactory factory = new DiskFileItemFactory();
+ ServletFileUpload upload = new ServletFileUpload(factory);
+ try {
+ List items = upload.parseRequest(request);
+ Iterator iter = items.iterator();
+ while (iter.hasNext()) {
+ FileItem item = (FileItem) iter.next();
+ if (item.isFormField()
+ && "XMLResponse".equals(item.getFieldName())) {
+ log.debug("XMLResponse part found.");
+ xml_response = item.getString();
+ break;
+ }
+ }
+ } catch (FileUploadException e) {
+ throw new ServletException(e);
+ }
+ } else {
+ xml_response = request.getParameter("XMLResponse");
+ }
+ log.debug("XMLResponse = " + xml_response);
+ return xml_response;
+ }
+
+ protected void processSign(HttpServletRequest request,
+ HttpServletResponse response, SignSessionInformation si)
+ throws ServletException, IOException, PdfAsException {
+ log.trace("processSign");
+
+ String xml_response = retrieveXMLResponse(request);
+
+ PdfAsInternal pdfAsInternal = ApiHelper
+ .getPdfAsInternalFromContext(getServletContext());
+
+ String server = request.getHeader("server");
+ String userAgent = request.getHeader("user-agent");
+ String signatureLayout = request
+ .getHeader(Constants.BKU_HEADER_SIGNATURE_LAYOUT);
+
+ String connector = si.connector;
+ String url = "";
+
+ if (si.connector.equals(Constants.SIGNATURE_DEVICE_BKU)) {
+ url = SettingsReader.getInstance().getSetting("bku.sign.url");
+ } else if (si.connector.equals(Constants.SIGNATURE_DEVICE_MOC)) {
+ url = SettingsReader.getInstance().getSetting("moc.sign.url");
+ } else if (si.connector.equals(Constants.SIGNATURE_DEVICE_MOBILE)) {
+ url = SettingsReader.getInstance().getSetting("mobile.sign.url");
+ } else {
+ url = SettingsReader.getInstance()
+ .getSetting("mobiletest.sign.url");
+ }
+
+ log.debug("Url ist: " + url);
+ log.debug("Server ist: " + server);
+ log.debug("UserAgent: " + userAgent);
+ log.debug("Layout ist: " + signatureLayout);
+
+ // rpiazzi added
+ // When choosing local CCS (a-trust 1.3.3.3 and higher) it seems that
+ // more requests to this servlet are sent from
+ // CCS. Therefore the first request (with no information about CCS in
+ // the headers) has to be ignored...
+ if (((server == null) && (userAgent == null)
+ && (signatureLayout == null) || (xml_response == null))) {
+ log.debug("Received response with none of the following header fields: \"server\", \"user-agent\", \""
+ + Constants.BKU_HEADER_SIGNATURE_LAYOUT + "\"");
+ log.debug("This is probably the empty servlet call when local CCS and a-trust CCS version >1.3.3.2 is choosen. In this case the right call of this servlet will follow soon!");
+ log.debug("Server is: " + server);
+ log.debug("UserAgent is: " + userAgent);
+ log.debug("SignatureLayout is: " + signatureLayout);
+ log.debug("xml_response is: " + xml_response);
+ }
+ // end added
+ else {
+ LocalBKUParams bkuParams = new LocalBKUParams(server, userAgent,
+ signatureLayout);
+ si.localBKUParams = bkuParams;
+
+ pdfAsInternal.verifyBKUSupport(bkuParams);
+
+ if (isNullResponse(xml_response)) {
+ log.debug("Received a NullOperationResponse -> answering with the first request."); //$NON-NLS-1$
+
+ // assert si.outputAvailable == false;
+ // assert si.xmlResponse == null;
+
+ log.debug("There are still requests to be performed -> answering with request."); //$NON-NLS-1$
+
+ LocalRequest local_request = si.localRequest;
+
+ String request_string = local_request.getRequestString();
+
+ log.debug("request = " + request_string);
+ response.setContentType("text/xml");
+ response.setCharacterEncoding("UTF-8");
+ response.getWriter().println(request_string);
+ } else if (xml_response != null) {
+ log.debug("Received a normal response -> storing the response."); //$NON-NLS-1$
+
+ si.xmlResponse = xml_response;
+
+ log.debug("All requests have been processed -> processing the responses."); //$NON-NLS-1$
+
+ // Sign
+
+ if (!si.outputAvailable) {
+ PdfAs pdfAs = ApiHelper
+ .getPdfAsFromContext(getServletContext());
+ SignServletHelper.finishLocalSign(pdfAs, pdfAsInternal, si);
+ SigningTimeHelper.checkSigningTimeAgainstHostTime(si.sdi
+ .getSignDate());
+ si.outputAvailable = true;
+ }
+
+ if (si.output.getMimeType().equals("text/xml")
+ && si.outputAvailable) {
+ // For "detached" signatures, the return value (data sink)
+ // is the response xml,
+ // but when passed through the BKU it is interpreted as
+ // another request
+ // which will generate a return code 1501
+ // Then PDF-AS would answer with the response as well
+ // generating
+ // another 1501 and so forth.
+ // Therefor return it as TXT.
+ 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(
+ new String(si.signedPdf, "UTF-8"));
+ if (statLog.isInfoEnabled()) {
+ long endTime = System.currentTimeMillis();
+ // String toReport = "SIGN;" + si.mode + ";" +
+ // si.filename + ";"+ fileSize + ";" +
+ String toReport = "SIGN;" + si.mode + ";"
+ + si.connector + ";"
+ + si.pdfDataSource.getLength() + ";"
+ + (endTime - si.startTime) + ";OK";
+
+ statLog.info(toReport);
+ }
+ } else {
+ // tzefferer: If PDF-AS has been called by an external
+ // web-application, we do not
+ // redirect to download.jsp but return the sign-response
+ // immediately
+ if (si.exappinf != null) {
+ log.debug("Entering external application interface mode. Skipping redirection to download page.");
+ // afitzek
+ if (statLog.isInfoEnabled()) {
+ long endTime = System.currentTimeMillis();
+ // String toReport = "SIGN;" + si.mode + ";" +
+ // si.filename + ";"+ fileSize + ";" +
+ String toReport = "SIGN;" + si.mode + ";"
+ + si.connector + ";"
+ + si.pdfDataSource.getLength() + ";"
+ + (endTime - si.startTime) + ";OK";
+
+ statLog.info(toReport);
+ }
+ SignServletHelper.returnSignResponse(si, request,
+ response);
+
+ // Not needed due to redirection of returnSignResponse.
+ // Just to clarify that there must not be any code after
+ // returnSignResponse.
+ return;
+ } else {
+ log.debug("Preparing download page.");
+ HttpSession session = request.getSession(true);
+ log.debug("Putting signed document into session ("
+ + session.getId() + ").");
+ session.setAttribute(
+ SessionAttributes.SIGNED_PDF_DOCUMENT, si);
+ String downloadURL = response
+ .encodeRedirectURL(LocalRequestHelper
+ .getLocalContextAddress(request,
+ response)
+ + "/ProvidePDF");
+ /*
+ * afitzek: changing log message to info level to see in
+ * log files if signature process was ok
+ */
+ log.info("Creating download URL \"" + downloadURL
+ + "\".");
+ session.setAttribute(
+ SessionAttributes.DOWNLOAD_URL_FOR_SIGNED_PDF_DOCUMENT,
+ downloadURL);
+ // afitzek
+ if (statLog.isInfoEnabled()) {
+ long endTime = System.currentTimeMillis();
+ String timeDiff = "----";
+ // String toReport = "SIGN;" + si.mode + ";" +
+ // si.filename + ";"+ fileSize + ";" +
+ String toReport = "SIGN;" + si.mode + ";"
+ + si.connector + ";"
+ + si.pdfDataSource.getLength() + ";"
+ + (endTime - si.startTime) + ";OK";
+
+ statLog.info(toReport);
+ }
+ temporaryRedirect(
+ response.encodeRedirectURL(LocalRequestHelper
+ .getLocalContextAddress(request,
+ response)
+ + "/jsp/download.jsp"), response);
+
+ // Not needed due to temporaryRedirect.
+ // Just to clarify that there must not be any code after
+ // temporaryRedirect.
+ return;
+ }
+
+ // do not insert any code within this else block !
+ }
+ } else {
+ log.debug("No XMLResponse found. Do nothing.");
+ }
+ }
+
+ }
+
+ protected void processVerify(HttpServletRequest request,
+ HttpServletResponse response, VerifySessionInformation si)
+ throws ServletException, IOException, ConnectorException,
+ SignatureException {
+ log.trace("processVerify");
+
+ String xml_response = request.getParameter("XMLResponse"); //$NON-NLS-1$
+ log.debug("xml_response = " + xml_response); //$NON-NLS-1$
+
+ if (isNullResponse(xml_response)) {
+ log.debug("Received a NullOperationResponse -> answering with the first request."); //$NON-NLS-1$
+
+ // assert si.currentLocalOperation.current_operation == 0;
+ } else {
+ log.debug("Recieved a normal response -> storing the response."); //$NON-NLS-1$
+
+ si.currentLocalOperation.finishCurrentOperation(xml_response);
+ }
+
+ if (!si.currentLocalOperation.isFinished()) {
+ log.debug("There are still requests to be performed -> answering with request #" + si.currentLocalOperation.current_operation); //$NON-NLS-1$
+
+ LocalRequest local_request = si.currentLocalOperation
+ .getCurrentLocalRequest();
+
+ String request_string = local_request.getRequestString();
+
+ response.setContentType("text/xml");
+ response.setCharacterEncoding("UTF-8");
+ response.getWriter().println(request_string);
+ } else {
+ log.debug("All requests have been processed -> processing the responses."); //$NON-NLS-1$
+
+ PdfAsInternal pdfAsInternal = ApiHelper
+ .getPdfAsInternalFromContext(getServletContext());
+ final ArrayList resList = new ArrayList();
+ for (int i = 0; i < si.currentLocalOperation.response_xmls.length; i++) {
+ SignatureInformation sigInfo = (SignatureInformation) si.currentLocalOperation.signaturesToBeverified
+ .get(i);
+ VerifyResult result = pdfAsInternal.finishLocalVerify(sigInfo,
+ si.connector, si.type,
+ "loc ref content not needed here",
+ si.currentLocalOperation.response_xmls[i]);
+ resList.add(result);
+ }
+
+ 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);
+
+ Long startTime = Long.valueOf(0);
+ startTime = (Long) request.getAttribute("START_TIME_STAT");
+
+ if (statLog.isInfoEnabled()) {
+ long endTime = System.currentTimeMillis();
+ // String toReport = "SIGN;" + si.mode + ";" + si.filename +
+ // ";"+ fileSize + ";" +
+ String toReport = "VERIFY;" + si.mode + ";" + si.connector
+ + ";" + (endTime - si.startTime) + ";OK";
+
+ statLog.info(toReport);
+ }
+ }
+ }
}
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 1c594dd..c60ecf0 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
@@ -83,7 +83,7 @@ import com.lowagie.text.DocumentException;
* This method is the sign servlet for the pdf-as web application. It takes get
* and post requests fill out jsp templates and give the user feedback about the
* results of the sign process
- *
+ *
* @author wlackner
* @author wprinz
*/
@@ -100,9 +100,9 @@ public class SignServlet extends HttpServlet
*/
private static Log log = LogFactory.getLog(SignServlet.class);
private static Log statLog = LogFactory.getLog("statistic");
-
-
-
+
+
+
public static final String SUBMITFORM_SIGNATURE_TYPE_KEY = "signupload.jsp:signatureType";
public static final String SUBMITFORM_SIGNATURE_MODE_KEY = "signupload.jsp:signatureMode";
public static final String SUBMITFORM_SIGNATURE_DEVICE_KEY = "signupload.jsp:signatureKey";
@@ -113,10 +113,10 @@ public class SignServlet extends HttpServlet
public static final String SUBMITFORM_FILE_KEY = "signupload.jsp:fileKey";
public static final String SUBMITFORM_FILENAME_KEY = "signupload.jsp:filenameKey";
public static final String SUBMITFORM_PREVIEW = "signupload.jsp:previewKey";
-
-
-
+
+
+
//Added by rpiazzi to know if an error occured within IFrame because this calls for
//a different display of the error
public static final String ERROR_WITHIN_IFRAME = "error_within_iframe";
@@ -124,7 +124,7 @@ public class SignServlet extends HttpServlet
public static final String HEIGHT_SIGN_DIV = "height_sign_div";
//Added by rpiazzi
public static HttpSession session = null;
-
+
protected void dispatch(HttpServletRequest request, HttpServletResponse response, String resource) throws ServletException, IOException
{
dispatch(request, response, resource, getServletContext());
@@ -141,7 +141,7 @@ public class SignServlet extends HttpServlet
/**
* Processes the sign upload.
- *
+ *
* @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest,
* javax.servlet.http.HttpServletResponse)
*/
@@ -150,12 +150,12 @@ public class SignServlet extends HttpServlet
UploadedData ud = null;
ExternAppInformation exappinf = null;
SignaturePositioning sigpos = null;
-
-
+
+
// for performance measurement
- long startTime = 0;
+ long startTime = 0;
if (statLog.isInfoEnabled()) {
- startTime = System.currentTimeMillis();
+ startTime = System.currentTimeMillis();
}
// check if pdf-as has been called by external webapp
@@ -176,7 +176,7 @@ public class SignServlet extends HttpServlet
String sig_pos_x = (String) request.getParameter(FormFields.FIELD_SIGPOS_X);
String sig_pos_w = (String) request.getParameter(FormFields.FIELD_SIGPOS_W);
String note = (String) request.getParameter(FormFields.FIELD_NOTE_ENABLED);
-
+
//Added by rpiazzi
log.debug("Received external request from "+request.getRemoteAddr());
log.debug("Parameter preview: "+preview);
@@ -195,7 +195,7 @@ public class SignServlet extends HttpServlet
log.debug("Parameter sig_pos_w: "+sig_pos_w);
log.debug("Parameter note: "+note);
//end added
-
+
// added by tknall
if (sig_pos_y != null && sig_pos_p != null && sig_pos_x != null) {
if (sig_pos_w != null) {
@@ -222,14 +222,14 @@ public class SignServlet extends HttpServlet
log.debug("No signature position provided.");
}
-
+
// fixed by tknall: if we already have parameters "&" must be used instead of "?"
- String paramSeparator = (pdf_url.indexOf("?") != -1) ? "&" : "?";
+ String paramSeparator = (pdf_url.indexOf("?") != -1) ? "&" : "?";
String query = pdf_url + "/" + filename + paramSeparator + FormFields.FIELD_PDF_ID + "=" + pdf_id;
//query = pdf_url;
-
+
log.debug("Query string for loading pdf: "+query);
-
+
// wprinz: rem: this allocation is useless
// byte[] extern_pdf = new byte[Integer.parseInt(pdf_length)];
URL source_url = new URL(query);
@@ -261,14 +261,14 @@ public class SignServlet extends HttpServlet
ud_extern.note=true;
ud_extern.sig_type = ud_extern.sig_type + "_NOTE";
}
-
-
+
+
ud_extern.pdfa = false;
-
+
ud = ud_extern;
-
+
exappinf = new ExternAppInformation(invoke_url, pdf_id, session_id, invoke_error_url);
-
+
}
else
{
@@ -276,7 +276,7 @@ public class SignServlet extends HttpServlet
{
// tzefferer: modified
// UploadedData ud = retrieveUploadedDataFromRequest(request);
-
+
UploadedData ud_form = retrieveUploadedDataFromRequest(request);
ud = ud_form;
// end modify
@@ -285,7 +285,7 @@ public class SignServlet extends HttpServlet
catch (PdfAsException e)
{
log.error(e);
-
+
//Added by rpiazzi to check if this attribute is still null
HttpSession session = request.getSession();
String error_within_iframe = (String)session.getAttribute(SUBMITFORM_SIGNATURE_DEVICE_KEY);
@@ -293,18 +293,18 @@ public class SignServlet extends HttpServlet
session.setAttribute(SignServlet.ERROR_WITHIN_IFRAME, "no");
}
//end added
-
+
prepareDispatchToErrorPage(e, request);
dispatch(request, response, "/jsp/error.jsp");
-
-
-
-
+
+
+
+
return;
}
catch (FileUploadException e) {
log.error(e);
-
+
//Added by rpiazzi to check if this attribute is still null
HttpSession session = request.getSession();
String error_within_iframe = (String)session.getAttribute(SUBMITFORM_SIGNATURE_DEVICE_KEY);
@@ -312,7 +312,7 @@ public class SignServlet extends HttpServlet
session.setAttribute(SignServlet.ERROR_WITHIN_IFRAME, "no");
}
//end added
-
+
request.setAttribute("error", e.getMessage());
request.setAttribute("cause", e.getCause());
request.setAttribute("resourcebundle", Boolean.TRUE);
@@ -320,7 +320,7 @@ public class SignServlet extends HttpServlet
}
catch (IOException e) {
log.error(e);
-
+
//Added by rpiazzi to check if this attribute is still null
HttpSession session = request.getSession();
String error_within_iframe = (String)session.getAttribute(SUBMITFORM_SIGNATURE_DEVICE_KEY);
@@ -328,7 +328,7 @@ public class SignServlet extends HttpServlet
session.setAttribute(SignServlet.ERROR_WITHIN_IFRAME, "no");
}
//end added
-
+
request.setAttribute("error", e.getMessage());
request.setAttribute("cause", e.getCause());
request.setAttribute("resourcebundle", Boolean.TRUE);
@@ -343,19 +343,19 @@ public class SignServlet extends HttpServlet
SignSessionInformation si = new SignSessionInformation(); // SessionTable.generateSessionInformationObject();
si.connector = ud.sig_app;
-
+
if ((ud.mobileTestEnabled) && (si.connector.equals("mobile"))) {
si.connector = Constants.SIGNATURE_DEVICE_MOBILETEST;
session.setAttribute(SignServlet.SUBMITFORM_SIGNATURE_DEVICE_KEY, si.connector);
}
-
+
si.application = "sign";
si.mode = ud.sig_mode;
si.pdfDataSource = ud.pdfDataSource;
si.type = ud.sig_type;
-
+
si.filename = formatFileName(ud.file_name);
-
+
si.download_inline = ud.download_inline;
si.pdfa = ud.pdfa;
si.note = ud.note;
@@ -365,6 +365,9 @@ public class SignServlet extends HttpServlet
si.pos = sigpos;
// end add
+ // added afitzek
+ si.startTime = startTime;
+
log.info("Putting signature data into session " + session.getId());
session.setAttribute(SessionAttributes.ATTRIBUTE_SESSION_INFORMATION, si);
@@ -393,18 +396,19 @@ public class SignServlet extends HttpServlet
return;
}*/
-
-
+
+
SignServletHelper.finishSign(si, request, response, getServletContext());
-
+
+ // afitzek: moved to DataURL to provide status information OK - ERROR
// for performance measurement
- if (statLog.isInfoEnabled()) {
+ /*if (statLog.isInfoEnabled()) {
long endTime = System.currentTimeMillis();
-// String toReport = "SIGN;" + si.mode + ";" + si.filename + ";"+ fileSize + ";" +
- String toReport = "SIGN;" + si.mode + ";" + si.connector + ";" + si.pdfDataSource.getLength() + ";" + (endTime - startTime);
-
+// String toReport = "SIGN;" + si.mode + ";" + si.filename + ";"+ fileSize + ";" +
+ String toReport = "SIGN;" + si.mode + ";" + si.connector + ";" + si.pdfDataSource.getLength() + ";" + (endTime - startTime);
+
statLog.info(toReport);
- }
+ }*/
}
catch (PresentableException e)
{
@@ -443,7 +447,7 @@ public class SignServlet extends HttpServlet
FileItem source_fi = null;
FileItem sig_type_fi = null;
FileItem sig_app_fi = null;
-
+
boolean pdfaEnabled=false;
boolean noteEnabled=false;
String sig_type="";
@@ -452,21 +456,21 @@ public class SignServlet extends HttpServlet
String doc_file_name;
DataSource pdfDataSource;
boolean mobileTestEnabled=false;
-
+
Iterator it = items.iterator();
session = request.getSession(true);
-
-
-
+
+
+
//Added by rpiazzi. If servlet was called for preview data was already written into
//session.
//Now commented out because the preview function is no more supported
/*if ((((FileItem)items.get(0)).getFieldName().equals(SignServlet.SUBMITFORM_PREVIEW))) {
FileItem fi = (FileItem)items.get(1);
-
+
sig_app_fi = fi;
session.setAttribute(SUBMITFORM_SIGNATURE_DEVICE_KEY, sig_app_fi.getString("UTF-8"));
-
+
if (((String)session.getAttribute(SUBMITFORM_PDFA_KEY))!=null) {
if (((String)session.getAttribute(SUBMITFORM_PDFA_KEY)).equals("on")) {
pdfaEnabled = true;
@@ -477,18 +481,18 @@ public class SignServlet extends HttpServlet
noteEnabled = true;
}
}
-
+
sig_type = (String)session.getAttribute(SUBMITFORM_SIGNATURE_TYPE_KEY);
sig_app = sig_app_fi.getString("UTF-8");
-
+
mode = (String)session.getAttribute(SUBMITFORM_SIGNATURE_MODE_KEY);
doc_file_name = (String)session.getAttribute(SUBMITFORM_FILENAME_KEY);
pdfDataSource = (DataSource)session.getAttribute(SUBMITFORM_FILE_KEY);
-
+
}
//end added
else {*/
-
+
//Added by rpiazzi to check wheter local bku button was hit. In this case the parameters
//were already put into session because before local bku, online bku has to be called
//and therefore this servlet was already called.
@@ -502,14 +506,14 @@ public class SignServlet extends HttpServlet
}
positionLocal++;
}
-
+
if (localFound) {
-
+
session.setAttribute(SignServlet.ERROR_WITHIN_IFRAME, "no");
pdfaEnabled = "on".equalsIgnoreCase((String)session.getAttribute(SUBMITFORM_PDFA_KEY));
sig_type = (String)session.getAttribute(SUBMITFORM_SIGNATURE_TYPE_KEY);
noteEnabled = "on".equalsIgnoreCase((String)session.getAttribute(SUBMITFORM_NOTE_KEY));
-
+
session.setAttribute(SUBMITFORM_SIGNATURE_DEVICE_KEY, "bku");
sig_app = "bku";
mode = (String)session.getAttribute(SUBMITFORM_SIGNATURE_MODE_KEY);
@@ -525,7 +529,7 @@ public class SignServlet extends HttpServlet
{
FileItem item = (FileItem) it.next();
log.debug("item = " + item.getFieldName()); //$NON-NLS-1$
-
+
if (log.isDebugEnabled())
{
if (item.isFormField())
@@ -539,7 +543,7 @@ public class SignServlet extends HttpServlet
log.debug(" filesize = " + item.getSize()); //$NON-NLS-1$
}
}
-
+
if (item.getFieldName().equals(FormFields.FIELD_SIGNATURE_TYPE))
{
sig_type_fi = item;
@@ -580,7 +584,7 @@ public class SignServlet extends HttpServlet
file_upload_fi = item;
}
continue;
-
+
}
//Added by rpiazzi to ignore the form fields for the inactive mode
@@ -589,14 +593,14 @@ public class SignServlet extends HttpServlet
continue;
}*/
//end added
-
+
/*Commented out by rpiazzi because not more needed
* if (item.getFieldName().equals(FormFields.FIELD_DOWNLOAD))
{
download_fi = item;
continue;
}*/
-
+
if (FormFields.FIELD_PDFA_ENABLED.equals(item.getFieldName())) {
if (item.getString("UTF-8")!=null) {
session.setAttribute(SUBMITFORM_PDFA_KEY, "on");
@@ -608,7 +612,7 @@ public class SignServlet extends HttpServlet
}
continue;
}
-
+
if (FormFields.FIELD_SOURCE_FREETEXT.equals(item.getFieldName())) {
freeText_fi = item;
String value = freeText_fi.getString("UTF-8");
@@ -617,13 +621,13 @@ public class SignServlet extends HttpServlet
}
continue;
}
-
+
if (FormFields.FIELD_SOURCE.equals(item.getFieldName())) {
source_fi = item;
session.setAttribute(SUBMITFORM_SOURCE_KEY, item.getString("UTF-8"));
continue;
}
-
+
//Added by rpiazzi. Feature added for inserting note into signature block
if (FormFields.FIELD_NOTE_ENABLED.equals(item.getFieldName())) {
if (item.getString("UTF-8")!=null) {
@@ -637,14 +641,14 @@ public class SignServlet extends HttpServlet
continue;
}
//end added
-
+
//Added by rpiazzi to let later jsp's know the height of the div elements
if (FormFields.FIELD_HEIGHT_SIGNDIV.equals(item.getFieldName())) {
session.setAttribute(HEIGHT_SIGN_DIV, item.getString("UTF-8"));
continue;
}
//end added
-
+
if (FormFields.FIELD_MOBILETEST_ENABLED.equals(item.getFieldName())) {
if (item.getString("UTF-8")!=null) {
if (item.getString("UTF-8").equals("on")) {
@@ -653,7 +657,7 @@ public class SignServlet extends HttpServlet
}
continue;
}
-
+
throw new ServletException("Unrecognized POST data."); //$NON-NLS-1$
}
@@ -669,7 +673,7 @@ public class SignServlet extends HttpServlet
throw new ServletException("The mode '" + mode + "' is unrecognized."); //$NON-NLS-1$ //$NON-NLS-2$
}
-
+
//Commented out by rpiazzi because not more needed
/*boolean download_inline = true;
if (download_fi.getString("UTF-8").equals(FormFields.VALUE_DOWNLOAD_ATTACHMENT)) //$NON-NLS-1$
@@ -677,7 +681,7 @@ public class SignServlet extends HttpServlet
download_inline = false;
}*/
-
+
// distinguish between file and freetext
if (source_fi.getString("UTF-8").equals(FormFields.VALUE_SOURCE_FILE)) {
log.debug("Processing file.");
@@ -700,7 +704,7 @@ public class SignServlet extends HttpServlet
{
pdfDataSource = new ByteArrayPdfDataSource(IOUtils.toByteArray(file_upload_fi.getInputStream()));
session.setAttribute(SUBMITFORM_FILE_KEY, pdfDataSource);
- session.setAttribute(SUBMITFORM_FILENAME_KEY, doc_file_name);
+ session.setAttribute(SUBMITFORM_FILENAME_KEY, doc_file_name);
}
catch (IOException e)
{
@@ -719,16 +723,16 @@ public class SignServlet extends HttpServlet
} catch (IOException e) {
throw new PDFDocumentException(201, "Unable to create PDF document.", e);
}
-
+
//}
// byte[] pdf = file_upload_fi.get();
}
}
-
-
-
-
-
+
+
+
+
+
UploadedData ud = new UploadedData();
@@ -747,13 +751,13 @@ public class SignServlet extends HttpServlet
ud.sig_type += "_NOTE";
session.setAttribute(SUBMITFORM_SIGNATURE_TYPE_KEY, ud.sig_type);
}
-
+
if (mobileTestEnabled) {
ud.mobileTestEnabled=true;
}
-
+
//end added
-
+
return ud;
}
@@ -769,7 +773,7 @@ public class SignServlet extends HttpServlet
request.setAttribute("error", "Fehler " + pe.getErrorCode());
String cause = ErrorCodeHelper.getMessageForErrorCode(pe.getErrorCode());
-
+
if (pe instanceof ExternalErrorException)
{
ExternalErrorException eee = (ExternalErrorException) pe;
@@ -791,7 +795,7 @@ public class SignServlet extends HttpServlet
request.setAttribute("cause", "Der Platzhalter des Feldes " + phe.getField() + " ist um " + phe.getMissing() + " Bytes zu kurz. " + cause);
}
-
+
//Added by rpiazzi to know if error happened when request was within iframe
//In this case the visualization of the error has to be done differently
/*HttpSession session = request.getSession();
@@ -802,8 +806,8 @@ public class SignServlet extends HttpServlet
request.setAttribute(ERROR_WITHIN_IFRAME, "yes");
}*/
//end added
-
-
+
+
// }
// else
// {
@@ -814,7 +818,7 @@ public class SignServlet extends HttpServlet
/**
* Formats the file name so that it is suitable for content disposition.
- *
+ *
* @param file_name
* The file name.
* @return Returns the formatted file name.
@@ -863,7 +867,7 @@ public class SignServlet extends HttpServlet
}
// end add
-
+
protected static class UploadedData
{
protected boolean preview = false;
@@ -881,13 +885,13 @@ public class SignServlet extends HttpServlet
protected String file_name = null;
protected DataSource pdfDataSource = null;
-
+
protected boolean mobileTestEnabled = false;
-
+
//added by rpiazzi
protected boolean note = false;
// protected byte[] pdf = null;
}
-}
-
+}
+
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 dbb478d..ab3a24e 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
@@ -69,7 +69,7 @@ import at.knowcenter.wag.egov.egiz.exceptions.SettingNotFoundException;
* This method is the verify servlet for the pdf-as web application. It takes
* get and post requests fill out jsp templates and give the user feedback about
* the results of the verify process.
- *
+ *
* @author wlackner
* @author wprinz
*/
@@ -103,18 +103,18 @@ public class VerifyServlet extends HttpServlet
/**
* Processes the verify upload.
- *
+ *
* @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest,
* javax.servlet.http.HttpServletResponse)
*/
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
// for performance measurement
- long startTime = 0;
+ long startTime = 0;
if (log.isInfoEnabled()) {
- startTime = System.currentTimeMillis();
+ startTime = System.currentTimeMillis();
}
-
+
try
{
UploadedData ud = retrieveUploadedDataFromRequest(request);
@@ -125,6 +125,9 @@ public class VerifyServlet extends HttpServlet
si.mode = null;
si.inputDataSource = ud.dataSource;
si.type = null;
+
+ //afitzek
+ si.startTime = startTime;
// si.user_name = null;
// si.user_password = null;
@@ -135,7 +138,7 @@ public class VerifyServlet extends HttpServlet
analyzeParameters.setVerifyMode(Constants.VERIFY_MODE_FULL_CONSERVATIVE);
AnalyzeResult analyzeResult = pdfAs.analyze(analyzeParameters);
si.analyzeResult = analyzeResult;
-
+
request.getSession().setAttribute(SessionAttributes.ATTRIBUTE_SESSION_INFORMATION, si);
if (ud.preview)
@@ -160,14 +163,14 @@ public class VerifyServlet extends HttpServlet
si.verifyResults = verifyResults;
dispatchToResults(verifyResults, request, response);
-
+
// for performance measurement
if (log.isInfoEnabled()) {
long endTime = System.currentTimeMillis();
- String toReport = "VERIFY;"+ ud.file_name + ";"+ 0 + ";" + (endTime - startTime) + ";" + debugVerifyResults(verifyResults);
+ String toReport = "VERIFY;"+ ud.file_name + ";"+ 0 + ";" + (endTime - startTime) + ";" + debugVerifyResults(verifyResults);
log.info(toReport);
}
-
+
}
}
@@ -190,7 +193,7 @@ public class VerifyServlet extends HttpServlet
{
DiskFileItemFactory fif = new DiskFileItemFactory();
fif.setRepository(WebSettingsReader.getTemporaryDirectory());
-
+
ServletFileUpload sfu = new ServletFileUpload(fif);
List items = sfu.parseRequest(request);
@@ -199,7 +202,7 @@ public class VerifyServlet extends HttpServlet
FileItem connector_fi = null;
// FileItem mode_fi = null;
FileItem preview_fi = null;
-
+
String characterEncoding = request.getCharacterEncoding();
log.debug("request character encoding = " + characterEncoding);
@@ -305,11 +308,11 @@ public class VerifyServlet extends HttpServlet
/**
* Extracts the extension from a file name string.
- *
+ *
* <p>
* The extension of a file name is whatever text follows the last '.'.
* </p>
- *
+ *
* @param file_name
* The file name.
* @return Returns the extension. If the file name ends with the '.', then an
@@ -341,12 +344,12 @@ public class VerifyServlet extends HttpServlet
protected DataSource dataSource = null;
}
-
+
/**
* Formats the verification results for debugging. Returns 0 if no error occurs or the sum of all error-codes.
- *
+ *
* @param verifyResults
- *
+ *
* @param writer
* The output sink to write the formatted text to.
* @throws SettingNotFoundException
@@ -359,14 +362,14 @@ public class VerifyServlet extends HttpServlet
while (it.hasNext())
{
VerifyResult result = (VerifyResult) it.next();
-
+
toreturn += result.getValueCheckCode().getCode();
}
return toreturn;
}
-
+
public boolean isPDF(byte[] data) {
- final byte[] PDF_MAGIC_NUMBER = { (byte) 0x25, (byte) 0x50, (byte)
+ final byte[] PDF_MAGIC_NUMBER = { (byte) 0x25, (byte) 0x50, (byte)
0x44, (byte) 0x46 }; // %PDF
if (data == null || data.length < PDF_MAGIC_NUMBER.length) {
return false;
@@ -375,6 +378,6 @@ public class VerifyServlet extends HttpServlet
System.arraycopy(data, 0, documentHeader, 0, documentHeader.length);
return Arrays.equals(documentHeader, PDF_MAGIC_NUMBER);
}
-
-
+
+
} \ No newline at end of file
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 684048a..11efbc1 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
@@ -43,7 +43,7 @@ import at.gv.egiz.pdfas.web.LocalRequest;
/**
* @author wprinz
- *
+ *
*/
public class SignSessionInformation implements HttpSessionBindingListener, Serializable
{
@@ -94,32 +94,32 @@ public class SignSessionInformation implements HttpSessionBindingListener, Seria
/**
* Object containing information about the calling webapplication.
- *
+ *
* @author: Thomas Zefferer
*/
public ExternAppInformation exappinf;
-
+
/**
* Information about the signature position
- *
+ *
* @author exthex
*/
public SignaturePositioning pos;
/**
* <code>true</code> if pdf/a is enabled
- *
+ *
* @author tknall
*/
public boolean pdfa;
/**
* <code>true</code> if note is enabled
- *
+ *
* @author rpiazzi
*/
public boolean note;
-
+
/**
* The SignatureDetailInformation.
*/
@@ -134,7 +134,7 @@ public class SignSessionInformation implements HttpSessionBindingListener, Seria
* The local request to be sent to the device.
*/
public LocalRequest localRequest = null;
-
+
/**
* Tells if the sign request has been processed and the signed document is
* available in the DataSink.
@@ -166,8 +166,10 @@ public class SignSessionInformation implements HttpSessionBindingListener, Seria
*/
public LocalBKUParams localBKUParams;
-
-
+ /**
+ * Start time of session (afitzek)
+ */
+ public long startTime;
/**
* @see javax.servlet.http.HttpSessionBindingListener#valueBound(javax.servlet.http.HttpSessionBindingEvent)
@@ -183,6 +185,6 @@ public class SignSessionInformation implements HttpSessionBindingListener, Seria
public void valueUnbound(HttpSessionBindingEvent event)
{
log.debug("Unbound SignSessionInformation from session (ID=" + event.getSession().getId() + ").");
-
+
}
}
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 30f5650..7cc3f4d 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
@@ -42,11 +42,11 @@ import at.gv.egiz.pdfas.web.ExternAppInformation;
/**
* This class is a collection of various session parameters that are passed
* between the servlets and jsps.
- *
+ *
* <p>
* The SessionInformation class contains type safe references to the objects.
* </p>
- *
+ *
* @author wprinz
*/
public class VerifySessionInformation implements HttpSessionBindingListener, Serializable
@@ -89,17 +89,17 @@ public class VerifySessionInformation implements HttpSessionBindingListener, Ser
/**
* Keeps track of the currently running local operation.
- *
+ *
* <p>
* Only valid during local verify.
* </p>
*/
public CurrentLocalOperation currentLocalOperation = null;
-
+
/**
* Object containing information about the calling webapplication.
* @author: Thomas Zefferer
- */
+ */
public ExternAppInformation exappinf;
/**
@@ -111,7 +111,12 @@ public class VerifySessionInformation implements HttpSessionBindingListener, Ser
* Results of the verify process.
*/
public VerifyResults verifyResults;
-
+
+ /**
+ * Start time of session (afitzek)
+ */
+ public long startTime;
+
/**
* @see javax.servlet.http.HttpSessionBindingListener#valueBound(javax.servlet.http.HttpSessionBindingEvent)
*/