예제 #1
0
  private void doGenerateSupportZip(final PwmRequest pwmRequest)
      throws IOException, ServletException {
    final PwmResponse resp = pwmRequest.getPwmResponse();
    resp.setHeader(
        PwmConstants.HttpHeader.ContentDisposition,
        "attachment;filename=" + PwmConstants.PWM_APP_NAME + "-Support.zip");
    resp.setContentType(PwmConstants.ContentTypeValue.zip);

    final String pathPrefix = PwmConstants.PWM_APP_NAME + "-Support" + "/";

    ZipOutputStream zipOutput = null;
    try {
      zipOutput = new ZipOutputStream(resp.getOutputStream(), PwmConstants.DEFAULT_CHARSET);
      DebugItemGenerator.outputZipDebugFile(pwmRequest, zipOutput, pathPrefix);
    } catch (Exception e) {
      LOGGER.error(pwmRequest, "error during zip debug building: " + e.getMessage());
    } finally {
      if (zipOutput != null) {
        try {
          zipOutput.close();
        } catch (Exception e) {
          LOGGER.error(pwmRequest, "error during zip debug closing: " + e.getMessage());
        }
      }
    }
  }
예제 #2
0
  private void doDownloadConfig(final PwmRequest pwmRequest)
      throws IOException, ServletException, PwmUnrecoverableException {
    final PwmSession pwmSession = pwmRequest.getPwmSession();
    final PwmResponse resp = pwmRequest.getPwmResponse();

    try {
      final StoredConfigurationImpl storedConfiguration = readCurrentConfiguration(pwmRequest);
      final OutputStream responseWriter = resp.getOutputStream();
      resp.setHeader(
          PwmConstants.HttpHeader.ContentDisposition,
          "attachment;filename=" + PwmConstants.DEFAULT_CONFIG_FILE_FILENAME);
      resp.setContentType(PwmConstants.ContentTypeValue.xml);
      storedConfiguration.toXml(responseWriter);
      responseWriter.close();
    } catch (Exception e) {
      LOGGER.error(pwmSession, "unable to download configuration: " + e.getMessage());
    }
  }