summaryrefslogtreecommitdiff
path: root/BKUOnline
diff options
context:
space:
mode:
authortkellner <tkellner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2013-04-10 15:12:48 (GMT)
committertkellner <tkellner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2013-04-10 15:12:48 (GMT)
commit4f8ceef828caa55526fe0dec3bae1c35ff8f5e3f (patch)
tree0c7e553f5b0e7f3775d168737ac5503489a9f385 /BKUOnline
parenteea713ab48c7b5db7de575a7eb75b9ba8a033056 (diff)
downloadmocca-4f8ceef828caa55526fe0dec3bae1c35ff8f5e3f.zip
mocca-4f8ceef828caa55526fe0dec3bae1c35ff8f5e3f.tar.gz
mocca-4f8ceef828caa55526fe0dec3bae1c35ff8f5e3f.tar.bz2
Make p3p policy header configurable
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@1168 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'BKUOnline')
-rw-r--r--BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/MoccaParameterBean.java14
-rw-r--r--BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java11
-rw-r--r--BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/UIServlet.java31
-rw-r--r--BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/WebRequestHandler.java12
-rw-r--r--BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml1
5 files changed, 53 insertions, 16 deletions
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/MoccaParameterBean.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/MoccaParameterBean.java
index aba1236..26a7a14 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/MoccaParameterBean.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/MoccaParameterBean.java
@@ -36,6 +36,9 @@ import java.util.Arrays;
import java.util.Locale;
import java.util.regex.Pattern;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.configuration.Configuration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -69,7 +72,8 @@ public class MoccaParameterBean {
public static final String PARAM_LOCALE = "locale";
public static final Pattern PATTERN_LOCALE = Pattern.compile("[a-zA-Z][a-zA-Z](_[a-zA-Z][a-zA-Z]){0,2}");
- public static final String P3P_POLICY = "policyref=\"w3c/p3p.xml\", CP=\"NON DSP COR CUR ADM DEV TAI PSA PSD OUR DEL IND UNI COM NAV INT CNT STA\"";
+ private static final String P3P_POLICY = "policyref=\"w3c/p3p.xml\", CP=\"NON DSP COR CUR ADM DEV TAI PSA PSD OUR DEL IND UNI COM NAV INT CNT STA\"";
+ private static final String ENABLE_P3P_HEADER = "EnableP3PHeader";
private Charset charset = Charset.forName("ISO-8859-1");
@@ -223,5 +227,11 @@ public class MoccaParameterBean {
}
return null;
}
-
+
+ public static void setP3PHeader(Configuration config, HttpServletResponse response) {
+ if (config.getBoolean(ENABLE_P3P_HEADER, false)) {
+ // Set P3P Policy Header
+ response.addHeader("P3P", P3P_POLICY);
+ }
+ }
}
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java
index db59ad5..9c531a3 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java
@@ -36,11 +36,13 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.commons.configuration.Configuration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import at.gv.egiz.bku.binding.BindingProcessor;
import at.gv.egiz.bku.binding.BindingProcessorManager;
+import at.gv.egiz.bku.binding.BindingProcessorManagerImpl;
import at.gv.egiz.bku.binding.HTTPBindingProcessor;
import at.gv.egiz.bku.binding.Id;
import at.gv.egiz.bku.utils.NullOutputStream;
@@ -87,9 +89,6 @@ public class ResultServlet extends HttpServlet {
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, java.io.IOException {
- // Set P3P Policy Header
- resp.addHeader("P3P", MoccaParameterBean.P3P_POLICY);
-
BindingProcessorManager bindingProcessorManager = (BindingProcessorManager) getServletContext()
.getAttribute("bindingProcessorManager");
if (bindingProcessorManager == null) {
@@ -99,6 +98,12 @@ public class ResultServlet extends HttpServlet {
return;
}
+ Configuration conf = ((BindingProcessorManagerImpl) bindingProcessorManager).getConfiguration();
+ if (conf == null)
+ log.error("No configuration");
+ else
+ MoccaParameterBean.setP3PHeader(conf, resp);
+
Id id = (Id) req.getAttribute("id");
BindingProcessor bindingProcessor = null;
if (id == null
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/UIServlet.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/UIServlet.java
index 8d5eacd..1a1c30d 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/UIServlet.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/UIServlet.java
@@ -26,8 +26,6 @@
package at.gv.egiz.bku.online.webapp;
import java.io.IOException;
-//import java.net.MalformedURLException;
-//import java.net.URL;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
@@ -35,13 +33,17 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.commons.configuration.Configuration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import at.gv.egiz.bku.binding.BindingProcessor;
import at.gv.egiz.bku.binding.BindingProcessorManager;
+import at.gv.egiz.bku.binding.BindingProcessorManagerImpl;
import at.gv.egiz.bku.binding.HTTPBindingProcessor;
import at.gv.egiz.bku.binding.Id;
+//import java.net.MalformedURLException;
+//import java.net.URL;
public class UIServlet extends HttpServlet {
@@ -70,9 +72,6 @@ public class UIServlet extends HttpServlet {
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
- // Set P3P Policy Header
- resp.addHeader("P3P", MoccaParameterBean.P3P_POLICY);
-
BindingProcessorManager bindingProcessorManager = (BindingProcessorManager) getServletContext()
.getAttribute("bindingProcessorManager");
if (bindingProcessorManager == null) {
@@ -82,6 +81,12 @@ public class UIServlet extends HttpServlet {
return;
}
+ Configuration conf = ((BindingProcessorManagerImpl) bindingProcessorManager).getConfiguration();
+ if (conf == null)
+ log.error("No configuration");
+ else
+ MoccaParameterBean.setP3PHeader(conf, resp);
+
Id id = (Id) req.getAttribute("id");
BindingProcessor bindingProcessor = null;
if (id == null
@@ -114,8 +119,20 @@ public class UIServlet extends HttpServlet {
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
- // Set P3P Policy Header
- resp.addHeader("P3P", MoccaParameterBean.P3P_POLICY);
+ BindingProcessorManager bindingProcessorManager = (BindingProcessorManager) getServletContext()
+ .getAttribute("bindingProcessorManager");
+ if (bindingProcessorManager == null) {
+ String msg = "Configuration error: BindingProcessorManager missing!";
+ log.error(msg);
+ resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg);
+ return;
+ }
+
+ Configuration conf = ((BindingProcessorManagerImpl) bindingProcessorManager).getConfiguration();
+ if (conf == null)
+ log.error("No configuration");
+ else
+ MoccaParameterBean.setP3PHeader(conf, resp);
super.doPost(req, resp);
}
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/WebRequestHandler.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/WebRequestHandler.java
index 72443b2..53175b3 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/WebRequestHandler.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/WebRequestHandler.java
@@ -36,10 +36,12 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.commons.configuration.Configuration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import at.gv.egiz.bku.binding.BindingProcessorManager;
+import at.gv.egiz.bku.binding.BindingProcessorManagerImpl;
import at.gv.egiz.bku.binding.HTTPBindingProcessor;
import at.gv.egiz.bku.binding.HttpUtil;
import at.gv.egiz.bku.binding.Id;
@@ -56,10 +58,6 @@ public class WebRequestHandler extends HttpServlet {
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
java.io.IOException {
-
- // Set P3P Policy Header
- resp.addHeader("P3P", MoccaParameterBean.P3P_POLICY);
-
BindingProcessorManager bindingProcessorManager = (BindingProcessorManager) getServletContext()
.getAttribute("bindingProcessorManager");
if (bindingProcessorManager == null) {
@@ -69,6 +67,12 @@ public class WebRequestHandler extends HttpServlet {
return;
}
+ Configuration conf = ((BindingProcessorManagerImpl) bindingProcessorManager).getConfiguration();
+ if (conf == null)
+ log.error("No configuration");
+ else
+ MoccaParameterBean.setP3PHeader(conf, resp);
+
Id id = (Id) req.getAttribute("id");
if (id == null) {
String msg = "No request id! Configuration error: ServletFilter missing?";
diff --git a/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml b/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml
index f193388..bd59bbd 100644
--- a/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml
+++ b/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml
@@ -213,6 +213,7 @@
<!-- binding processor manager -->
<bean id="bindingProcessorManager" class="at.gv.egiz.bku.binding.BindingProcessorManagerImpl"
scope="singleton">
+ <property name="configuration" ref="configuration" />
<property name="stalFactory" ref="stalFactory" />
<property name="slCommandInvoker" ref="slCommandInvoker" />
<property name="factories">