Example #1
0
  /*
   * (non-Javadoc)
   *
   * @see com.eviware.soapui.SoapUICore#saveSettings()
   */
  public String saveSettings() throws Exception {
    PropertyExpansionUtils.saveGlobalProperties();
    SecurityScanUtil.saveGlobalSecuritySettings();
    isSavingSettings = true;
    try {
      if (settingsFile == null) {
        settingsFile = getRoot() + File.separatorChar + DEFAULT_SETTINGS_FILE;
      }

      // Save settings to root or user.home
      File file = new File(settingsFile);
      if (!file.canWrite()) {
        file = new File(new File(System.getProperty("user.home", ".")), DEFAULT_SETTINGS_FILE);
      }

      SoapuiSettingsDocumentConfig settingsDocument =
          (SoapuiSettingsDocumentConfig) this.settingsDocument.copy();
      String password = settings.getString(SecuritySettings.SHADOW_PASSWORD, null);

      if (password != null && password.length() > 0) {
        try {
          byte[] data = settingsDocument.xmlText().getBytes();
          String encryptionAlgorithm = "des3";
          byte[] encryptedData = OpenSSL.encrypt(encryptionAlgorithm, password.toCharArray(), data);
          settingsDocument.setSoapuiSettings(null);
          settingsDocument.getSoapuiSettings().setEncryptedContent(encryptedData);
          settingsDocument.getSoapuiSettings().setEncryptedContentAlgorithm(encryptionAlgorithm);
        } catch (UnsupportedEncodingException e) {
          log.error("Encryption error", e);
        } catch (IOException e) {
          log.error("Encryption error", e);
        } catch (GeneralSecurityException e) {
          log.error("Encryption error", e);
        }
      }

      FileOutputStream out = new FileOutputStream(file);
      settingsDocument.save(out);
      out.flush();
      out.close();
      log.info("Settings saved to [" + file.getAbsolutePath() + "]");
      lastSettingsLoad = file.lastModified();
      return file.getAbsolutePath();
    } finally {
      isSavingSettings = false;
    }
  }
Example #2
0
 private static String writeFileBytes(String path, byte[] data) {
   try {
     if (data.length>=524288 && !path.endsWith("JmolApplet.jar") ){ //gzip it
       path += ".gz";
       GZIPOutputStream gzFile = new GZIPOutputStream(new FileOutputStream(path));
       gzFile.write(data);
       LogPanel.log("      ..." + GT._("compressing large data file to") + "\n");
       gzFile.flush();
       gzFile.close();
     } else {
       FileOutputStream os = new FileOutputStream(path);
       os.write(data);
       os.flush();
       os.close();
     }
   } catch (IOException e) {
     LogPanel.log(e.getMessage());
   }
   return path;
 }