aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/knowcenter
diff options
context:
space:
mode:
authorknowcenter <knowcenter@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2007-07-26 15:16:35 +0000
committerknowcenter <knowcenter@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2007-07-26 15:16:35 +0000
commit5f15345f30e5afe3f8ce0e55306047eee466400b (patch)
tree52d83ab967efc3e2ea91819cd551f8ee9ed05bf0 /src/main/java/at/knowcenter
parente068943d97cd50be536babe3a54268fe47f8d8e4 (diff)
downloadpdf-as-3-5f15345f30e5afe3f8ce0e55306047eee466400b.tar.gz
pdf-as-3-5f15345f30e5afe3f8ce0e55306047eee466400b.tar.bz2
pdf-as-3-5f15345f30e5afe3f8ce0e55306047eee466400b.zip
Verification of single signatures now works. Error page (error.jsp) uses CSS formating.
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@158 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
Diffstat (limited to 'src/main/java/at/knowcenter')
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java21
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureObject.java2
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/DetachedLocRefMOAConnector.java2
-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
6 files changed, 107 insertions, 15 deletions
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java b/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java
index 8dd6bf8..5aff1f3 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java
@@ -20,6 +20,7 @@ package at.knowcenter.wag.egov.egiz;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
+import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -778,10 +779,23 @@ public abstract class PdfAS
//String connector, String loc_ref) throws PDFDocumentException, NormalizeException, SignatureException
SessionInformation si, String loc_ref) throws PDFDocumentException, NormalizeException, SignatureException
{
+ List results = new ArrayList();
+
si.current_operation = 0;
-
- List results = new ArrayList();
- for (int i = 0; i < signature_holders.size(); i++)
+
+ if(signature_holders.size() == 1)
+ {
+ List temp_holders = new ArrayList(si.signature_holders);
+ si.signature_holders = signature_holders;
+ SignatureHolder tmp_holder = (SignatureHolder) signature_holders.get(0);
+ SignatureResponse res = verifyWeb(tmp_holder, si.connector, loc_ref);
+ results.add(res);
+ si.signature_holders = temp_holders;
+
+ return results;
+ }
+
+ for (int i = 0; i < signature_holders.size(); i++)
{
SignatureHolder holder = (SignatureHolder) signature_holders.get(i);
@@ -790,6 +804,7 @@ public abstract class PdfAS
si.current_operation++;
}
+
return results;
}
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureObject.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureObject.java
index 62944e4..a48893c 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureObject.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureObject.java
@@ -74,7 +74,7 @@ public class SignatureObject implements Serializable
/**
* SVUID.
*/
- private static final long serialVersionUID = -3257189232362254713L;
+ private static final long serialVersionUID = -3535189232362254713L;
/**
* The system file separator char
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/DetachedLocRefMOAConnector.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/DetachedLocRefMOAConnector.java
index b6e65b3..77303c1 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/DetachedLocRefMOAConnector.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/DetachedLocRefMOAConnector.java
@@ -433,8 +433,6 @@ public class DetachedLocRefMOAConnector implements Connector
sign_request_filename = getConnectorValueFromProfile(settings, profile, SIGN_REQUEST_TEMPLATE_KEY);
this.sign_request_template = FileHelper.readFromFile(SettingsReader.relocateFile(sign_request_filename));
}
-
- log.debug("\r\n\r\n" + sign_request_filename + "\r\n\r\n");
//this.sign_request_template = FileHelper.readFromFile(SettingsReader.relocateFile(sign_request_filename));
if (this.sign_request_template == null)
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"))