aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/knowcenter/wag/egov/egiz/web
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/knowcenter/wag/egov/egiz/web')
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/web/LocalRequestHelper.java78
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/web/SessionInformation.java6
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyPreviewServlet.java13
3 files changed, 88 insertions, 9 deletions
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/web/LocalRequestHelper.java b/src/main/java/at/knowcenter/wag/egov/egiz/web/LocalRequestHelper.java
index b664bc6..fd47cca 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/web/LocalRequestHelper.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/web/LocalRequestHelper.java
@@ -20,6 +20,7 @@ package at.knowcenter.wag.egov.egiz.web;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
@@ -166,7 +167,7 @@ public abstract class LocalRequestHelper
List holders_to_verify, HttpServletRequest request,
HttpServletResponse response) throws SignatureException, NormalizeException, IOException, ConnectorFactoryException
{
- si.requests = new LocalRequest[holders_to_verify.size()];
+ si.requests = new LocalRequest[holders_to_verify.size()];
si.response_properties = new Properties[si.requests.length];
si.current_operation = 0;
si.finished = false;
@@ -204,19 +205,15 @@ public abstract class LocalRequestHelper
si.requests[i] = local_request;
si.response_properties[i] = null;
}
-
+
// TODO read from config
String local_request_url = "http://127.0.0.1:3495/http-security-layer-request";
URL data_URL = new URL(request.getScheme(), host, request.getServerPort(), request.getContextPath() + "/DataURL");
String data_url = response.encodeURL(data_URL.toString());
- //URL local_server_url = new URL(request.getScheme(), host, request.getServerPort(), "/");
- //String loc_server_url = response.encodeURL(local_server_url.toString());
-
request.setAttribute("local_request_url", local_request_url);
request.setAttribute("data_url", data_url);
- //request.setAttribute("loc_server_url", loc_server_url);
return NULL_REQUEST_PAGE_JSP;
@@ -262,6 +259,75 @@ public abstract class LocalRequestHelper
//
// prepareDispatchToLocalConnectionPage(si.requests[0], request, response);
}
+
+ /**
+ * Sets up the local verify procedure.
+ *
+ * @param response
+ * The HttpServletResponse the local request page is written to.
+ * @return Returns the JSP location where the calling servlet should dispatch
+ * to.
+ * @throws SignatureException
+ * Forwarded exception.
+ * @throws NormalizeException
+ * Forwarded exception.
+ * @throws IOException
+ * Forwarded exception.
+ * @throws ConnectorFactoryException
+ * Forwarded exception.
+ */
+ public static String processLocalVerifyForSingleSignature(SessionInformation si,
+ List holders_to_verify, HttpServletRequest request,
+ HttpServletResponse response) throws SignatureException, NormalizeException, IOException, ConnectorFactoryException
+ {
+ si.requests = new LocalRequest[1];
+ si.response_properties = new Properties[1];
+ si.current_operation = 0;
+ si.finished = false;
+
+ String host = request.getServerName();
+ URL loc_ref_URL = new URL(request.getScheme(), host, request.getServerPort(), request.getContextPath() + "/RetrieveSignatureData");
+ String loc_ref_url = response.encodeURL(loc_ref_URL.toString());
+
+ SignatureHolder holder = (SignatureHolder) holders_to_verify.get(0);
+
+ SignatureObject s = holder.getSignatureObject();
+
+ // TODO This whole processing is unnecessary here because only the mime
+ // type is used.
+ String text_to_be_verified = holder.getSignedText();
+ SignatureData sd = null;
+
+ if (holder.getSignatureObject().isBinary())
+ {
+ byte[] data = CodingHelper.decodeBase64(text_to_be_verified);
+ sd = new SignatureDataImpl(data, "application/pdf");
+ }
+ else
+ {
+ sd = new SignatureDataImpl(text_to_be_verified.getBytes("UTF-8"), "text/plain", "UTF-8");
+ }
+
+ SignSignatureObject so = SignatureObjectHelper.convertSignatureObjectToSignSignatureObject(s);
+
+ LocalConnector local_conn = ConnectorChooser.chooseLocalConnectorForVerify(si.connector, s.getKZ(), so.id, si.type, loc_ref_url);
+ String request_string = local_conn.prepareVerifyRequest(sd, so);
+
+ LocalRequest local_request = new LocalRequest("not-needed", request_string);
+ si.requests[0] = local_request;
+ si.response_properties[0] = null;
+
+ // TODO read from config
+ String local_request_url = "http://127.0.0.1:3495/http-security-layer-request";
+
+ URL data_URL = new URL(request.getScheme(), host, request.getServerPort(), request.getContextPath() + "/DataURL");
+ String data_url = response.encodeURL(data_URL.toString());
+
+ request.setAttribute("local_request_url", local_request_url);
+ request.setAttribute("data_url", data_url);
+
+ return NULL_REQUEST_PAGE_JSP;
+ }
/**
* Formats the OK response from the web application back to the local BKU.
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/web/SessionInformation.java b/src/main/java/at/knowcenter/wag/egov/egiz/web/SessionInformation.java
index 52a51a3..a85ca52 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/web/SessionInformation.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/web/SessionInformation.java
@@ -109,6 +109,12 @@ public class SessionInformation implements Serializable
* The signature holders.
*/
public List signature_holders;
+
+ /**
+ * 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.
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyPreviewServlet.java b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyPreviewServlet.java
index 1ab89ed..9d9cc1f 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyPreviewServlet.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyPreviewServlet.java
@@ -506,7 +506,7 @@ public class VerifyPreviewServlet extends HttpServlet
}
logger_.debug("verify_which = " + verify_which);
}
-
+
{
String preview_string = request.getParameter(FormFields.FIELD_PREVIEW);
if (preview_string.equals("true"))
@@ -525,6 +525,7 @@ public class VerifyPreviewServlet extends HttpServlet
}
SignatureHolder holder = (SignatureHolder) si.signature_holders.get(verify_which);
+ si.current_operation = verify_which;
holders_to_verify = new ArrayList();
holders_to_verify.add(holder);
@@ -552,8 +553,14 @@ public class VerifyPreviewServlet extends HttpServlet
if (ConnectorFactory.isConnectorLocal(si.connector))
{
- String dispatch_to = LocalRequestHelper.processLocalVerify(si, holders_to_verify, request, response);
+ List temp_holder = new ArrayList(si.signature_holders);
+
+ si.copy_of_signature_holders = temp_holder;
+ si.signature_holders = holders_to_verify;
+
+ String dispatch_to = LocalRequestHelper.processLocalVerify(si, holders_to_verify, request, response);
dispatch(request, response, dispatch_to);
+
return;
}
@@ -646,7 +653,7 @@ public class VerifyPreviewServlet extends HttpServlet
verify_which = Integer.parseInt(which_str);
continue;
}
-
+
if (item.getFieldName().equals("verify"))
{
if (item.getString("UTF-8").equals("true"))