aboutsummaryrefslogtreecommitdiff
path: root/id/server/modules/moa-id-modul-citizencard_authentication/src/main/java/at/gv/egovernment/moa/id/util/CitizenCardServletUtils.java
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-10-07 07:44:58 +0200
commit961f785060f749ed97b0516745cb9ad2fd2704cc (patch)
tree23c10876368166f1e65a6719d31ae81784d54b8f /id/server/modules/moa-id-modul-citizencard_authentication/src/main/java/at/gv/egovernment/moa/id/util/CitizenCardServletUtils.java
parent58c843aa630c1e6fd2680cf019f7e270abbe9a69 (diff)
downloadmoa-id-spss-961f785060f749ed97b0516745cb9ad2fd2704cc.tar.gz
moa-id-spss-961f785060f749ed97b0516745cb9ad2fd2704cc.tar.bz2
moa-id-spss-961f785060f749ed97b0516745cb9ad2fd2704cc.zip
refactor http servlet response processing to prohibit 'chunked' transfer encoding
Diffstat (limited to 'id/server/modules/moa-id-modul-citizencard_authentication/src/main/java/at/gv/egovernment/moa/id/util/CitizenCardServletUtils.java')
-rw-r--r--id/server/modules/moa-id-modul-citizencard_authentication/src/main/java/at/gv/egovernment/moa/id/util/CitizenCardServletUtils.java33
1 files changed, 14 insertions, 19 deletions
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);
}