diff options
author | knowcenter <knowcenter@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c> | 2007-07-26 15:16:35 +0000 |
---|---|---|
committer | knowcenter <knowcenter@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c> | 2007-07-26 15:16:35 +0000 |
commit | 5f15345f30e5afe3f8ce0e55306047eee466400b (patch) | |
tree | 52d83ab967efc3e2ea91819cd551f8ee9ed05bf0 | |
parent | e068943d97cd50be536babe3a54268fe47f8d8e4 (diff) | |
download | pdf-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
10 files changed, 113 insertions, 56 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"))
diff --git a/webapp/jsp/error.jsp b/webapp/jsp/error.jsp index 0d77ead..e0e0954 100644 --- a/webapp/jsp/error.jsp +++ b/webapp/jsp/error.jsp @@ -1,8 +1,10 @@ +<%@ page import="at.knowcenter.wag.egov.egiz.web.LocalRequestHelper" %>
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>PDF-AS Amtssignaturen Resultat</title>
-<link rel="stylesheet" type="text/css" href="/pdf-as/css/styles.css" />
+<link rel="stylesheet" type="text/css" href="<%=LocalRequestHelper.getLocalServerAddress(request,response)%>pdf-as/css/styles.css" />
</head>
<body>
<%
@@ -20,7 +22,7 @@ <strong><%= cause %></strong>
</div>
</div>
-<a class="big" href="/pdf-as/">Weiter...</a>
+<a class="big" href="<%=LocalRequestHelper.getLocalServerAddress(request,response)%>pdf-as/">Weiter...</a>
</div>
</body>
</html>
\ No newline at end of file diff --git a/webapp/jsp/null_request_page.jsp b/webapp/jsp/null_request_page.jsp index 7bb3541..3299b18 100644 --- a/webapp/jsp/null_request_page.jsp +++ b/webapp/jsp/null_request_page.jsp @@ -10,44 +10,6 @@ <title>PDF-AS Amtssignaturen Lokale Verbindung</title>
<link rel="stylesheet" type="text/css" href="/pdf-as/css/styles.css" />
-<script type="text/javascript">
-
-var req;
-
-function init() {
-
- if (window.XMLHttpRequest) { req = new XMLHttpRequest(); }
- else if (window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHTTP"); }
-
- var url = "<%= local_request_url %>";
- var formdata = "XMLRequest=<?xml version='1.0' encoding='UTF-8'?><NullOperationRequest xmlns='http://www.buergerkarte.at/namespaces/securitylayer/1.2#'/>";
- formdata += "&DataURL=<%= data_url %>";
-
- req.open("post", url, true);
- req.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
- req.onreadystatechange = processXMLResponse;
- req.send(formdata);
-}
-
-function processXMLResponse() {
- try
- {
- //readyState of 4 or 'complete' represents
- //that data has been returned
- if (xmlHttp.readyState == 4 ||
- xmlHttp.readyState == 'complete')
- {
- var response = req.responseText;
- alert(response);
- }
- else
- alert("not ok");
- }
- catch(e){}
-}
-
-</script>
-
</head>
<body onload="document.submitform.submit()">
diff --git a/webapp/jsp/results.jsp b/webapp/jsp/results.jsp index 02e084f..cffe158 100644 --- a/webapp/jsp/results.jsp +++ b/webapp/jsp/results.jsp @@ -89,6 +89,7 @@ <%
}
%>
+
</div>
</body>
</html>
diff --git a/work/cfg/config.properties b/work/cfg/config.properties index b179739..58d055e 100644 --- a/work/cfg/config.properties +++ b/work/cfg/config.properties @@ -20,7 +20,7 @@ strict_mode=false # added by tzefferer
allow_post_sign_modifications=false
-check_old_textual_sigs=true
+check_old_textual_sigs=false
# changes by arian and erno
|