コード例 #1
1
ファイル: DefaultSoapUICore.java プロジェクト: mer163/soapui
  protected void initExtensions(ClassLoader extensionClassLoader) {
    /* We break the general rule that you shouldn't catch Throwable, because we don't want extensions to crash SoapUI. */
    try {
      String extDir = System.getProperty("soapui.ext.listeners");
      addExternalListeners(
          FilenameUtils.normalize(
              extDir != null
                  ? extDir
                  : root == null ? "listeners" : root + File.separatorChar + "listeners"),
          extensionClassLoader);
    } catch (Throwable e) {
      SoapUI.logError(e, "Couldn't load external listeners");
    }

    try {
      String factoriesDir = System.getProperty("soapui.ext.factories");
      addExternalFactories(
          FilenameUtils.normalize(
              factoriesDir != null
                  ? factoriesDir
                  : root == null ? "factories" : root + File.separatorChar + "factories"),
          extensionClassLoader);
    } catch (Throwable e) {
      SoapUI.logError(e, "Couldn't load external factories");
    }
  }
コード例 #2
0
ファイル: DefaultSoapUICore.java プロジェクト: mer163/soapui
  protected void addExternalFactories(String folder, ClassLoader classLoader) {
    File[] factoryFiles = new File(folder).listFiles();
    if (factoryFiles != null) {
      for (File factoryFile : factoryFiles) {
        if (factoryFile.isDirectory()) {
          addExternalListeners(factoryFile.getAbsolutePath(), classLoader);
          continue;
        }

        if (!factoryFile.getName().toLowerCase().endsWith("-factories.xml")) {
          continue;
        }

        try {
          log.info("Adding factories from [" + factoryFile.getAbsolutePath() + "]");

          getFactoryRegistry().addConfig(new FileInputStream(factoryFile), classLoader);
          // We break the general rule that you shouldn't catch Throwable, because we don't want
          // extensions to crash SoapUI
        } catch (Throwable e) {
          SoapUI.logError(e, "Couldn't load factories in " + factoryFile.getAbsolutePath());
        }
      }
    }
  }
コード例 #3
0
ファイル: DefaultSoapUICore.java プロジェクト: mer163/soapui
 public synchronized void loadExternalLibraries() {
   if (extClassLoader == null) {
     try {
       extClassLoader =
           SoapUIExtensionClassLoader.create(getRoot(), getExtensionClassLoaderParent());
     } catch (MalformedURLException e) {
       SoapUI.logError(e);
     }
   }
 }
コード例 #4
0
ファイル: DefaultSoapUICore.java プロジェクト: mer163/soapui
 @Override
 public void run() {
   if (settingsFile != null && !isSavingSettings) {
     File file = new File(settingsFile);
     if (file.exists() && file.lastModified() > lastSettingsLoad) {
       log.info("Reloading updated settings file");
       initSettings(settingsFile);
       SoapUI.updateProxyFromSettings();
     }
   }
 }
コード例 #5
0
ファイル: DefaultSoapUICore.java プロジェクト: mer163/soapui
  public void init(String settingsFile) {
    initLog();

    SoapUI.setSoapUICore(this);

    loadExternalLibraries();
    initSettings(settingsFile == null ? DEFAULT_SETTINGS_FILE : settingsFile);

    initExtensions(getExtensionClassLoader());
    initCoreComponents();
    loadPlugins();

    // this is to provoke initialization
    SoapVersion.Soap11.equals(SoapVersion.Soap12);
  }
コード例 #6
0
ファイル: DefaultSoapUICore.java プロジェクト: mer163/soapui
  protected Settings initSettings(String fileName) {
    // TODO Why try to load settings from current directory before using root?
    // This caused a bug in Eclipse:
    // https://sourceforge.net/tracker/?func=detail&atid=737763&aid=2620284&group_id=136013
    File settingsFile = new File(fileName).exists() ? new File(fileName) : null;

    try {
      if (settingsFile == null) {
        settingsFile = new File(new File(getRoot()), DEFAULT_SETTINGS_FILE);
        if (!settingsFile.exists()) {
          settingsFile =
              new File(new File(System.getProperty("user.home", ".")), DEFAULT_SETTINGS_FILE);
          lastSettingsLoad = 0;
        }
      } else {
        settingsFile = new File(fileName);
        if (!settingsFile.getAbsolutePath().equals(this.settingsFile)) {
          lastSettingsLoad = 0;
        }
      }

      if (!settingsFile.exists()) {
        if (settingsDocument == null) {
          log.info("Creating new settings at [" + settingsFile.getAbsolutePath() + "]");
          settingsDocument = SoapuiSettingsDocumentConfig.Factory.newInstance();
          setInitialImport(true);
        }

        lastSettingsLoad = System.currentTimeMillis();
      } else if (settingsFile.lastModified() > lastSettingsLoad) {
        settingsDocument = SoapuiSettingsDocumentConfig.Factory.parse(settingsFile);

        byte[] encryptedContent = settingsDocument.getSoapuiSettings().getEncryptedContent();
        if (encryptedContent != null) {
          char[] password = null;
          if (this.password == null) {
            // swing element -!! uh!
            JPasswordField passwordField = new JPasswordField();
            JLabel qLabel = new JLabel("Password");
            JOptionPane.showConfirmDialog(
                null,
                new Object[] {qLabel, passwordField},
                "Global Settings",
                JOptionPane.OK_CANCEL_OPTION);
            password = passwordField.getPassword();
          } else {
            password = this.password.toCharArray();
          }

          String encryptionAlgorithm =
              settingsDocument.getSoapuiSettings().getEncryptedContentAlgorithm();
          byte[] data =
              OpenSSL.decrypt(
                  StringUtils.isNullOrEmpty(encryptionAlgorithm) ? "des3" : encryptionAlgorithm,
                  password,
                  encryptedContent);
          try {
            settingsDocument =
                SoapuiSettingsDocumentConfig.Factory.parse(new String(data, "UTF-8"));
          } catch (Exception e) {
            log.warn("Wrong password.");
            JOptionPane.showMessageDialog(
                null,
                "Wrong password, creating backup settings file [ "
                    + settingsFile.getAbsolutePath()
                    + ".bak.xml. ]\nSwitch to default settings.",
                "Error - Wrong Password",
                JOptionPane.ERROR_MESSAGE);
            settingsDocument.save(new File(settingsFile.getAbsolutePath() + ".bak.xml"));
            throw e;
          }
        }

        log.info("initialized soapui-settings from [" + settingsFile.getAbsolutePath() + "]");
        lastSettingsLoad = settingsFile.lastModified();

        if (settingsWatcher == null) {
          settingsWatcher = new SettingsWatcher();
          SoapUI.getSoapUITimer().scheduleAtFixedRate(settingsWatcher, 10000, 10000);
        }
      }
    } catch (Exception e) {
      log.warn("Failed to load settings from [" + e.getMessage() + "], creating new");
      settingsDocument = SoapuiSettingsDocumentConfig.Factory.newInstance();
      lastSettingsLoad = 0;
    }

    if (settingsDocument.getSoapuiSettings() == null) {
      settingsDocument.addNewSoapuiSettings();
      settings = new XmlBeansSettingsImpl(null, null, settingsDocument.getSoapuiSettings());

      initDefaultSettings(settings);
    } else {
      settings = new XmlBeansSettingsImpl(null, null, settingsDocument.getSoapuiSettings());
    }

    this.settingsFile = settingsFile.getAbsolutePath();

    if (!settings.isSet(WsdlSettings.EXCLUDED_TYPES)) {
      StringList list = new StringList();
      list.add("schema@http://www.w3.org/2001/XMLSchema");
      settings.setString(WsdlSettings.EXCLUDED_TYPES, list.toXml());
    }

    if (settings
        .getString(HttpSettings.HTTP_VERSION, HttpSettings.HTTP_VERSION_1_1)
        .equals(HttpSettings.HTTP_VERSION_0_9)) {
      settings.setString(HttpSettings.HTTP_VERSION, HttpSettings.HTTP_VERSION_1_1);
    }

    setIfNotSet(WsdlSettings.NAME_WITH_BINDING, true);
    setIfNotSet(WsdlSettings.NAME_WITH_BINDING, 500);
    setIfNotSet(HttpSettings.HTTP_VERSION, HttpSettings.HTTP_VERSION_1_1);
    setIfNotSet(HttpSettings.MAX_TOTAL_CONNECTIONS, 2000);
    setIfNotSet(HttpSettings.RESPONSE_COMPRESSION, true);
    setIfNotSet(HttpSettings.LEAVE_MOCKENGINE, true);
    setIfNotSet(UISettings.AUTO_SAVE_PROJECTS_ON_EXIT, true);
    setIfNotSet(UISettings.SHOW_DESCRIPTIONS, true);
    setIfNotSet(WsdlSettings.XML_GENERATION_ALWAYS_INCLUDE_OPTIONAL_ELEMENTS, true);
    setIfNotSet(WsaSettings.USE_DEFAULT_RELATES_TO, true);
    setIfNotSet(WsaSettings.USE_DEFAULT_RELATIONSHIP_TYPE, true);
    setIfNotSet(UISettings.SHOW_STARTUP_PAGE, true);
    setIfNotSet(UISettings.GC_INTERVAL, "60");
    setIfNotSet(WsdlSettings.CACHE_WSDLS, true);
    setIfNotSet(WsdlSettings.PRETTY_PRINT_RESPONSE_MESSAGES, true);
    setIfNotSet(HttpSettings.RESPONSE_COMPRESSION, true);
    setIfNotSet(HttpSettings.INCLUDE_REQUEST_IN_TIME_TAKEN, true);
    setIfNotSet(HttpSettings.INCLUDE_RESPONSE_IN_TIME_TAKEN, true);
    setIfNotSet(HttpSettings.LEAVE_MOCKENGINE, true);
    setIfNotSet(HttpSettings.START_MOCK_SERVICE, true);
    setIfNotSet(UISettings.AUTO_SAVE_INTERVAL, "0");
    setIfNotSet(UISettings.GC_INTERVAL, "60");
    setIfNotSet(UISettings.SHOW_STARTUP_PAGE, true);
    setIfNotSet(WsaSettings.SOAP_ACTION_OVERRIDES_WSA_ACTION, false);
    setIfNotSet(WsaSettings.USE_DEFAULT_RELATIONSHIP_TYPE, true);
    setIfNotSet(WsaSettings.USE_DEFAULT_RELATES_TO, true);
    setIfNotSet(WsaSettings.OVERRIDE_EXISTING_HEADERS, false);
    setIfNotSet(WsaSettings.ENABLE_FOR_OPTIONAL, false);
    setIfNotSet(VersionUpdateSettings.AUTO_CHECK_VERSION_UPDATE, true);
    if (!settings.isSet(ProxySettings.AUTO_PROXY) && !settings.isSet(ProxySettings.ENABLE_PROXY)) {
      settings.setBoolean(ProxySettings.AUTO_PROXY, true);
      settings.setBoolean(ProxySettings.ENABLE_PROXY, true);
    }

    boolean setWsiDir = false;
    String wsiLocationString = settings.getString(WSISettings.WSI_LOCATION, null);
    if (StringUtils.isNullOrEmpty(wsiLocationString)) {
      setWsiDir = true;
    } else {
      File wsiFile = new File(wsiLocationString);
      if (!wsiFile.exists()) {
        setWsiDir = true;
      }
    }
    if (setWsiDir) {
      String wsiDir = System.getProperty("wsi.dir", new File(".").getAbsolutePath());
      settings.setString(WSISettings.WSI_LOCATION, wsiDir);
    }
    HttpClientSupport.addSSLListener(settings);

    return settings;
  }