// Called to create a Wicket session
 // Also sets the timeout at the servlet level to the requested value
 @Override
 public Session newSession(Request request, Response response) {
   if (request instanceof ServletWebRequest) {
     ((ServletWebRequest) request)
         .getContainerRequest()
         .getSession()
         .setMaxInactiveInterval(sessionTimeout);
   }
   return new CwmSession(request);
 }
Exemplo n.º 2
0
  @Override
  protected void onConfigure() {
    super.onConfigure();

    ServletWebRequest req = (ServletWebRequest) RequestCycle.get().getRequest();
    HttpServletRequest httpReq = req.getContainerRequest();
    HttpSession httpSession = httpReq.getSession();

    Exception ex = (Exception) httpSession.getAttribute(WebAttributes.AUTHENTICATION_EXCEPTION);
    if (ex == null) {
      return;
    }

    String key = ex.getMessage() != null ? ex.getMessage() : "web.security.provider.unavailable";
    error(getString(key));

    httpSession.removeAttribute(WebAttributes.AUTHENTICATION_EXCEPTION);

    clearBreadcrumbs();
  }
Exemplo n.º 3
0
  @Override
  public void onRequest() {
    final ServletWebRequest webRequest = (ServletWebRequest) RequestCycle.get().getRequest();
    final WebResponse webResponse = (WebResponse) RequestCycle.get().getResponse();

    try {
      /* Get and process files */
      MultipartServletWebRequest multiPartRequest =
          webRequest.newMultipartWebRequest(Bytes.bytes(maxUploadSize), "ignored");

      Map<String, List<FileItem>> files = multiPartRequest.getFiles();
      List<FileItem> fileItems = files.get(paramName);

      uploadCallback.filesUploaded(fileItems);

      /* Send response */
      sendResponse(webRequest, webResponse, fileItems);
    } catch (Exception f*x) {
      throw new AbortWithHttpErrorCodeException(
          HttpServletResponse.SC_INTERNAL_SERVER_ERROR, f*x.getMessage());
    }
  }
Exemplo n.º 4
0
  /** Prepares response to the file upload */
  protected void sendResponse(
      ServletWebRequest webRequest, WebResponse webResponse, List<FileItem> fileItems)
      throws FileUploadException, IOException {

    String accept = webRequest.getHeader("Accept");
    if (wantsHtml(accept)) {
      // Internet Explorer
      RequestCycle.get()
          .scheduleRequestHandlerAfterCurrent(
              new TextRequestHandler(
                  "text/html",
                  "utf-8",
                  escapeHtml(generateJsonResponse(webRequest, webResponse, fileItems))));
    } else {
      // A real browser
      RequestCycle.get()
          .scheduleRequestHandlerAfterCurrent(
              new TextRequestHandler(
                  "application/json",
                  "utf-8",
                  generateJsonResponse(webRequest, webResponse, fileItems)));
    }
  }
Exemplo n.º 5
0
 protected String getServerName() {
   ServletWebRequest servletWebRequest = (ServletWebRequest) getRequest();
   HttpServletRequest req = servletWebRequest.getHttpServletRequest();
   return req.getServerName();
 }