diff options
Diffstat (limited to 'BKUOnline')
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 aba12365..26a7a14c 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 db59ad5d..9c531a3c 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 8d5eacd9..1a1c30d0 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 72443b27..53175b3c 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 f193388f..bd59bbd5 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"> |