Checking postback key.

This commit is contained in:
Winston Li 2014-12-04 23:39:43 +00:00
parent e31b4fead5
commit 0ac263ad45

View file

@ -5,6 +5,7 @@ import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.handler.ResourceHandler;
import org.eclipse.jetty.util.MultiMap;
import uk.ac.ic.wlgitbridge.writelatex.WriteLatexAPI;
import uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception.InvalidPostbackKeyException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@ -26,9 +27,18 @@ public class AttsResourceHandler extends ResourceHandler {
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
HttpURI uri = baseRequest.getUri();
System.out.println(baseRequest.getMethod() + " " + uri);
System.out.println(uri.getPath());
MultiMap<String> multimap = new MultiMap<String>();
uri.decodeQueryTo(multimap);
String[] pathSections = uri.getPath().split("/");
String key = multimap.getString("key");
if (key == null || pathSections.length < 2) {
throw new ServletException();
}
try {
writeLatexDataSource.checkPostbackKey(pathSections[1], key);
} catch (InvalidPostbackKeyException e) {
throw new ServletException();
}
System.out.println(multimap);
if (false) {