diff options
Diffstat (limited to 'pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper')
3 files changed, 29 insertions, 110 deletions
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);
|