0
|
1
|
|
2 package nabble.view.web.w3c;
|
|
3
|
|
4 import fschmidt.util.servlet.JtpContext;
|
|
5 import nabble.view.lib.UrlMappable;
|
|
6 import nabble.view.lib.Cache;
|
|
7
|
|
8 import javax.servlet.ServletException;
|
|
9 import javax.servlet.http.HttpServlet;
|
|
10 import javax.servlet.http.HttpServletRequest;
|
|
11 import javax.servlet.http.HttpServletResponse;
|
|
12 import java.io.IOException;
|
|
13 import java.io.PrintWriter;
|
|
14 import java.util.HashMap;
|
|
15 import java.util.Map;
|
|
16 import java.util.regex.Matcher;
|
|
17 import java.util.regex.Pattern;
|
|
18
|
|
19 public final class P3PXML extends HttpServlet implements UrlMappable {
|
|
20
|
|
21 private static final Pattern URL_PATTERN = Pattern.compile("/w3c/p3p.xml$");
|
|
22
|
|
23 private static String path() {
|
|
24 return "/w3c/p3p.xml";
|
|
25 }
|
|
26
|
|
27 public Map<String, String[]> getParameterMapFromUrl(HttpServletRequest request,String mappedUrl) {
|
|
28 Matcher m = URL_PATTERN.matcher(mappedUrl);
|
|
29 if (!m.find())
|
|
30 throw new RuntimeException();
|
|
31 Map<String,String[]> params = new HashMap<String,String[]>();
|
|
32 return params;
|
|
33 }
|
|
34
|
|
35 public Pattern getUrlPattern() {
|
|
36 return URL_PATTERN;
|
|
37 }
|
|
38
|
|
39 protected void service(HttpServletRequest request, HttpServletResponse response)
|
|
40 throws ServletException, IOException {
|
|
41
|
|
42 JtpContext jtpContext = (JtpContext)getServletContext().getAttribute(JtpContext.attrName);
|
|
43 jtpContext.setEtag(request,response);
|
|
44 PrintWriter out = response.getWriter();
|
|
45 response.setContentType("text/xml");
|
|
46
|
|
47 out.print( "\r\n<META xmlns=\"http://www.w3.org/2002/01/P3Pv1\">\r\n <POLICY-REFERENCES>\r\n <POLICY-REF about=\"http://" );
|
|
48 out.print( (request.getHeader("host")) );
|
|
49 out.print( "/w3c/policy.xml#Policy\">\r\n <INCLUDE>/*</INCLUDE>\r\n <COOKIE-INCLUDE name=\"*\" value=\"*\" domain=\"" );
|
|
50 out.print( (request.getHeader("host")) );
|
|
51 out.print( "\"/>\r\n </POLICY-REF>\r\n </POLICY-REFERENCES>\r\n</META>\r\n" );
|
|
52
|
|
53 }
|
|
54 }
|
|
55
|