diff src/nabble/view/web/w3c/P3PXML.java @ 0:7ecd1a4ef557

add content
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 21 Mar 2019 19:15:52 -0600
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/nabble/view/web/w3c/P3PXML.java	Thu Mar 21 19:15:52 2019 -0600
@@ -0,0 +1,55 @@
+
+package nabble.view.web.w3c;
+
+import fschmidt.util.servlet.JtpContext;
+import nabble.view.lib.UrlMappable;
+import nabble.view.lib.Cache;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public final class P3PXML extends HttpServlet implements UrlMappable {
+
+	private static final Pattern URL_PATTERN = Pattern.compile("/w3c/p3p.xml$");
+
+	private static String path() {
+		return "/w3c/p3p.xml";
+	}
+
+	public Map<String, String[]> getParameterMapFromUrl(HttpServletRequest request,String mappedUrl) {
+		Matcher m = URL_PATTERN.matcher(mappedUrl);
+		if (!m.find())
+			throw new RuntimeException();
+		Map<String,String[]> params = new HashMap<String,String[]>();
+		return params;
+	}
+
+	public Pattern getUrlPattern() {
+		return URL_PATTERN;
+	}
+
+	protected void service(HttpServletRequest request, HttpServletResponse response)
+			throws ServletException, IOException {
+
+		JtpContext jtpContext = (JtpContext)getServletContext().getAttribute(JtpContext.attrName);
+		jtpContext.setEtag(request,response);
+		PrintWriter out = response.getWriter();
+		response.setContentType("text/xml");
+		
+		out.print( "\r\n<META xmlns=\"http://www.w3.org/2002/01/P3Pv1\">\r\n	<POLICY-REFERENCES>\r\n		<POLICY-REF about=\"http://" );
+		out.print( (request.getHeader("host")) );
+		out.print( "/w3c/policy.xml#Policy\">\r\n			<INCLUDE>/*</INCLUDE>\r\n			<COOKIE-INCLUDE name=\"*\" value=\"*\" domain=\"" );
+		out.print( (request.getHeader("host")) );
+		out.print( "\"/>\r\n		</POLICY-REF>\r\n	</POLICY-REFERENCES>\r\n</META>\r\n" );
+
+	}
+}
+