コード例 #1
0
 public boolean restoreRequest() {
   HttpSession session = myRequest.getSession(false);
   if (session == null) return false;
   synchronized (session) {
     String j_uri = (String) session.getAttribute(FormAuthenticator.__J_URI);
     if (j_uri != null) {
       // check if the request is for the same url as the original and restore
       // params if it was a post
       StringBuffer buf = myRequest.getRequestURL();
       if (myRequest.getQueryString() != null) buf.append("?").append(myRequest.getQueryString());
       if (j_uri.equals(buf.toString())) {
         String method = (String) session.getAttribute(JettyHttpFacade.__J_METHOD);
         myRequest.setMethod(HttpMethod.valueOf(method.toUpperCase()), method);
         MultivaluedHashMap<String, String> j_post =
             (MultivaluedHashMap<String, String>) session.getAttribute(CACHED_FORM_PARAMETERS);
         if (j_post != null) {
           myRequest.setContentType("application/x-www-form-urlencoded");
           MultiMap<String> map = new MultiMap<String>();
           for (String key : j_post.keySet()) {
             for (String val : j_post.getList(key)) {
               map.add(key, val);
             }
           }
           restoreFormParameters(map, myRequest);
         }
         session.removeAttribute(FormAuthenticator.__J_URI);
         session.removeAttribute(JettyHttpFacade.__J_METHOD);
         session.removeAttribute(FormAuthenticator.__J_POST);
       }
       return true;
     }
   }
   return false;
 }
コード例 #2
0
 @Override
 public void handle(
     String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
     throws IOException, ServletException {
   final String suffix = RequestPath.suffix(target);
   final String path = path(suffix);
   if (!paths.contains(path)) {
     if (!whitelist.contains(suffix)) return;
     if (!"GET".equals(baseRequest.getMethod()))
       baseRequest.setMethod(HttpMethod.GET, HttpMethod.GET.toString());
     super.handle(target, baseRequest, request, allowCrossOrigin(response));
   } else {
     baseRequest
         .getContext()
         .getContext(path)
         .getRequestDispatcher(target)
         .forward(request, allowCrossOrigin(response));
   }
 }