aboutsummaryrefslogtreecommitdiff
path: root/id/server/modules/moa-id-modul-citizencard_authentication/src
diff options
context:
space:
mode:
authorThomas Lenz <tlenz@iaik.tugraz.at>2016-09-30 09:22:29 +0200
committerThomas Lenz <tlenz@iaik.tugraz.at>2016-09-30 09:22:29 +0200
commitd025c38a426e22b0d1ccfbb4558ff6ce78ac1d0b (patch)
tree6bd538b3faab08ecec07c1fcff47e4c84f483b47 /id/server/modules/moa-id-modul-citizencard_authentication/src
parent5dda0359afcdc69b11bc9a8df5c527e6c1488b6f (diff)
downloadmoa-id-spss-d025c38a426e22b0d1ccfbb4558ff6ce78ac1d0b.tar.gz
moa-id-spss-d025c38a426e22b0d1ccfbb4558ff6ce78ac1d0b.tar.bz2
moa-id-spss-d025c38a426e22b0d1ccfbb4558ff6ce78ac1d0b.zip
refactor http servlet response processing to prohibit 'chunked' transfer encoding
Diffstat (limited to 'id/server/modules/moa-id-modul-citizencard_authentication/src')
-rw-r--r--id/server/modules/moa-id-modul-citizencard_authentication/src/main/java/at/gv/egovernment/moa/id/auth/modules/internal/tasks/CreateIdentityLinkFormTask.java9
-rw-r--r--id/server/modules/moa-id-modul-citizencard_authentication/src/main/java/at/gv/egovernment/moa/id/util/CitizenCardServletUtils.java33
2 files changed, 18 insertions, 24 deletions
diff --git a/id/server/modules/moa-id-modul-citizencard_authentication/src/main/java/at/gv/egovernment/moa/id/auth/modules/internal/tasks/CreateIdentityLinkFormTask.java b/id/server/modules/moa-id-modul-citizencard_authentication/src/main/java/at/gv/egovernment/moa/id/auth/modules/internal/tasks/CreateIdentityLinkFormTask.java
index e47aff83b..e1495f254 100644
--- a/id/server/modules/moa-id-modul-citizencard_authentication/src/main/java/at/gv/egovernment/moa/id/auth/modules/internal/tasks/CreateIdentityLinkFormTask.java
+++ b/id/server/modules/moa-id-modul-citizencard_authentication/src/main/java/at/gv/egovernment/moa/id/auth/modules/internal/tasks/CreateIdentityLinkFormTask.java
@@ -1,7 +1,5 @@
package at.gv.egovernment.moa.id.auth.modules.internal.tasks;
-import java.io.PrintWriter;
-
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -79,11 +77,12 @@ public class CreateIdentityLinkFormTask extends AbstractAuthServletTask {
pendingReq, MOAIDEventConstants.AUTHPROCESS_BKU_URL, moasession.getBkuURL());
if (!StringUtils.isEmpty(getIdentityLinkForm)) {
+ byte[] content = getIdentityLinkForm.getBytes("UTF-8");
resp.setContentType(MediaType.HTML_UTF_8.toString());
- PrintWriter out = new PrintWriter(resp.getOutputStream());
- out.print(getIdentityLinkForm);
- out.flush();
+ resp.setContentLength(content.length);
+ resp.getOutputStream().write(content);
Logger.debug("Finished GET " + CreateIdentityLinkFormTask.class);
+
}
} catch (WrongParametersException ex) {
diff --git a/id/server/modules/moa-id-modul-citizencard_authentication/src/main/java/at/gv/egovernment/moa/id/util/CitizenCardServletUtils.java b/id/server/modules/moa-id-modul-citizencard_authentication/src/main/java/at/gv/egovernment/moa/id/util/CitizenCardServletUtils.java
index 9fbdf5cd7..1f2cda680 100644
--- a/id/server/modules/moa-id-modul-citizencard_authentication/src/main/java/at/gv/egovernment/moa/id/util/CitizenCardServletUtils.java
+++ b/id/server/modules/moa-id-modul-citizencard_authentication/src/main/java/at/gv/egovernment/moa/id/util/CitizenCardServletUtils.java
@@ -50,7 +50,6 @@
package at.gv.egovernment.moa.id.util;
import java.io.IOException;
-import java.io.OutputStream;
import java.net.URLEncoder;
import javax.servlet.http.HttpServletResponse;
@@ -93,12 +92,11 @@ public class CitizenCardServletUtils extends ServletUtils{
resp.addHeader("Location", dataURL);
//TODO test impact of explicit setting charset with older versions of BKUs (HotSign)
- resp.setContentType(MediaType.XML_UTF_8.toString());
- OutputStream out = resp.getOutputStream();
- out.write(createXMLSignatureRequestOrRedirect.getBytes("UTF-8"));
- out.flush();
- out.close();
+ byte[] content = createXMLSignatureRequestOrRedirect.getBytes("UTF-8");
+ resp.setContentType(MediaType.XML_UTF_8.toString());
+ resp.setContentLength(content.length);
+ resp.getOutputStream().write(content);
Logger.debug("Finished POST " + servletName);
} else {
@@ -129,12 +127,11 @@ public class CitizenCardServletUtils extends ServletUtils{
resp.addHeader("Location", dataURL);
//TODO test impact of explicit setting charset with older versions of BKUs (HotSign)
+
+ byte[] content = createXMLSignatureRequestOrRedirect.getBytes("UTF-8");
resp.setContentType(MediaType.XML_UTF_8.toString());
-
- OutputStream out = resp.getOutputStream();
- out.write(createXMLSignatureRequestOrRedirect.getBytes("UTF-8"));
- out.flush();
- out.close();
+ resp.setContentLength(content.length);
+ resp.getOutputStream().write(content);
Logger.debug("Finished POST " + servletName);
}
@@ -156,16 +153,14 @@ public class CitizenCardServletUtils extends ServletUtils{
IOException {
resp.setStatus(200);
Logger.debug("ContentType set to: application/x-www-form-urlencoded");
-
- resp.setContentType("application/x-www-form-urlencoded");
-
- String content = "XMLRequest=" + URLEncoder.encode(createXMLSignatureRequestOrRedirect, "UTF-8") + "&" +
+
+ String respString = "XMLRequest=" + URLEncoder.encode(createXMLSignatureRequestOrRedirect, "UTF-8") + "&" +
"DataURL=" + URLEncoder.encode(dataURL, "UTF-8");
- OutputStream out = resp.getOutputStream();
- out.write(content.getBytes("UTF-8"));
- out.flush();
- out.close();
+ byte[] content = respString.getBytes("UTF-8");
+ resp.setContentType("application/x-www-form-urlencoded");
+ resp.setContentLength(content.length);
+ resp.getOutputStream().write(content);
Logger.debug("Finished POST " + servletName);
}