view src/nabble/view/web/w3c/P3PXML.jtp @ 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 source

<%
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");
		%>
		<META xmlns="http://www.w3.org/2002/01/P3Pv1">
			<POLICY-REFERENCES>
				<POLICY-REF about="http://<%=request.getHeader("host")%>/w3c/policy.xml#Policy">
					<INCLUDE>/*</INCLUDE>
					<COOKIE-INCLUDE name="*" value="*" domain="<%=request.getHeader("host")%>"/>
				</POLICY-REF>
			</POLICY-REFERENCES>
		</META>
		<%
	}
}
%>