コード例 #1
0
ファイル: Utilities.java プロジェクト: skelegon/Vidor
  // Saves the settings to config file.
  public static void saveSettings(Settings settings) {
    config.setProperty("vlclocation", settings.getVlcLocation());
    config.setProperty("thumbnailcount", settings.getThumbnailCount());
    config.setProperty("thumbnailwidth", settings.getThumbnailWidth());
    config.setProperty("thumbnailhighlightcolor", settings.getThumbnailHighlightColor());
    config.setProperty("folders", String.join("|", settings.getFolders()));

    try {
      config.save("vidor.config");
    } catch (ConfigurationException ex) {
      ex.printStackTrace();
    }
  }
コード例 #2
0
 private static Project newProject(String key, String language) {
   PropertiesConfiguration configuration = new PropertiesConfiguration();
   configuration.setProperty("sonar.language", language);
   return new Project(key)
       .setConfiguration(configuration)
       .setAnalysisType(Project.AnalysisType.DYNAMIC);
 }
コード例 #3
0
  @Test
  public void shouldGetPropertyValue() {
    PropertiesConfiguration conf = new PropertiesConfiguration();
    conf.setProperty("sonar.timemachine.period1", "5");

    assertThat(PastSnapshotFinder.getPropertyValue(conf, 1), is("5"));
    assertThat(PastSnapshotFinder.getPropertyValue(conf, 999), nullValue());
  }
コード例 #4
0
ファイル: ControlCommand.java プロジェクト: Jiri-Kremser/rhq
  /**
   * Sets a property to rhqctl.properties. Note that calling this will eventually cause
   * rhqctl.properties file to be created later.
   *
   * @param key
   * @param value
   */
  private void putProperty(String key, String value) {
    if (rhqctlConfig == null) {
      rhqctlConfig = new PropertiesConfiguration();
      rhqctlConfig.setPath(getRhqCtlPropertiesPath());
    }

    rhqctlConfig.setProperty(key, value);
  }
コード例 #5
0
 /**
  * Set the property String value to the apache commons config.
  *
  * @param name contains the name of the property.
  * @param value contains the String value of the property.
  */
 public void setProperty(String name, String value) {
   if (config != null) {
     config.setProperty(name, value);
   } else {
     String warn =
         "setProperty invalid config, can't set prop name [" + name + "], value [" + value + "]";
     LOG.warn(warn);
   }
 }
コード例 #6
0
  @Test
  public void shouldGetDefaultPropertyValue() {
    PropertiesConfiguration conf = new PropertiesConfiguration();
    conf.setProperty("sonar.timemachine.period1", "5");

    assertThat(
        PastSnapshotFinder.getPropertyValue(conf, 2),
        is(CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_2));
  }
コード例 #7
0
  @Test
  public void hasJavaSourceFiles() {
    final DefaultProjectFileSystem fs = newDefaultProjectFileSystem(project);
    assertThat(fs.hasJavaSourceFiles(), is(true));

    PropertiesConfiguration conf = new PropertiesConfiguration();
    conf.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, "**/*.java");
    project.setConfiguration(conf);
    assertThat(fs.hasJavaSourceFiles(), is(false));
  }
コード例 #8
0
  @Test
  public void applyExclusionPatternsToSourceFiles() {
    PropertiesConfiguration conf = new PropertiesConfiguration();
    conf.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, "**/B*.java");
    project.setConfiguration(conf);

    final DefaultProjectFileSystem fs = newDefaultProjectFileSystem(project);

    assertThat(fs.getJavaSourceFiles().size(), is(1));
    assertThat(fs.getJavaSourceFiles(), hasItem(named("Whizz.java")));
  }
コード例 #9
0
  @Test
  public void doNotApplyExclusionPatternsToTestFiles() {
    PropertiesConfiguration conf = new PropertiesConfiguration();
    conf.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, "**/B*.java");
    project.setConfiguration(conf);

    final DefaultProjectFileSystem fs = newDefaultProjectFileSystem(project);

    assertThat(fs.getTestFiles(Java.INSTANCE).size(), is(1));
    assertThat(fs.getTestFiles(Java.INSTANCE), hasItem(named("BarTest.java")));
  }
コード例 #10
0
  /** Get the Splout configuration using double configuration: defaults + custom */
  public static SploutConfiguration get(String rootDir) {
    SploutConfiguration properties = new SploutConfiguration();

    PropertiesConfiguration config = load(rootDir, SPLOUT_PROPERTIES, false);
    if (config != null) {
      properties.addConfiguration(config);
    }
    config = load(rootDir, SPLOUT_PROPERTIES + ".default", true);
    properties.addConfiguration(config);

    // The following lines replaces the default "localhost" by the local IP for convenience:
    String myIp = "localhost";

    try {
      Collection<InetAddress> iNetAddresses = GetIPAddresses.getAllLocalIPs();
      // but only if there is Internet connectivity!
      if (iNetAddresses != null) {
        Iterator<InetAddress> it = iNetAddresses.iterator();
        if (it.hasNext()) {
          InetAddress address = it.next();
          if (address.getHostAddress() != null) {
            myIp = address.getHostAddress();
          }
        }
      }
    } catch (IOException e) {
      throw new RuntimeException(e);
    }

    if (config.getString(QNodeProperties.HOST) != null
        && config.getString(QNodeProperties.HOST).equals("localhost")) {
      config.setProperty(QNodeProperties.HOST, myIp);
    }

    if (config.getString(DNodeProperties.HOST) != null
        && config.getString(DNodeProperties.HOST).equals("localhost")) {
      config.setProperty(DNodeProperties.HOST, myIp);
    }

    return properties;
  }
コード例 #11
0
  /** See http://jira.codehaus.org/browse/SONAR-1449 */
  @Test
  public void exclusionPatternOnAjFiles() {
    PropertiesConfiguration conf = new PropertiesConfiguration();
    conf.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, "**/*.aj");
    project.setConfiguration(conf);

    final DefaultProjectFileSystem fs = newDefaultProjectFileSystem(project);

    assertThat(fs.getSourceFiles(Java.INSTANCE).size(), is(2));
    assertThat(fs.getSourceFiles(Java.INSTANCE), hasItem(named("Whizz.java")));
    assertThat(fs.getSourceFiles(Java.INSTANCE), hasItem(named("Bar.java")));
  }
コード例 #12
0
ファイル: Migrate3_0_0.java プロジェクト: CloudMetal/mirth
  @Override
  public void updateConfiguration(PropertiesConfiguration configuration) {
    if (configuration.getProperty("database").equals("derby")) {
      String url = (String) configuration.getProperty("database.url");

      if (!StringUtils.contains(url, ";upgrade=")) {
        url += ";upgrade=true";
      }

      configuration.setProperty("database.url", url);
    }
  }
コード例 #13
0
 /**
  * Converts a JSON string into the properties object.
  *
  * @param properties The properties object to convert.
  * @return A JSON string representing the object. Null if conversion fails.
  */
 public static PropertiesConfiguration toProperties(String json) {
   try {
     Properties src = JsonPropertiesConverter.toProperties(json);
     if (src != null) {
       PropertiesConfiguration dest = new PropertiesConfiguration();
       for (String key : src.stringPropertyNames()) {
         dest.setProperty(key, src.getProperty(key));
       }
       return dest;
     }
   } catch (Exception e) {
   }
   return null;
 }
  /** @throws CommandExecutionException */
  private void updateDefaultVersion(String key) throws CommandExecutionException {
    final PropertiesConfiguration properties = globalConfig.getProperties();
    properties.setProperty(mapping.get(type).getName(), key);
    try {
      properties.save();
      SignatureFileInfo sigFileInfo = signatureManager.getDefaultSignatures().get(type);
      printWriter.println(
          I18N.getResource(
              I18N.CONFIGURE_SIGNATURE_FILE_VERSION_SUCCESS,
              sigFileInfo.getVersion(),
              sigFileInfo.getFile().getName()));

    } catch (ConfigurationException e) {
      throw new CommandExecutionException(e);
    } catch (SignatureFileException e) {
      throw new CommandExecutionException(e);
    }
  };
コード例 #15
0
ファイル: SecorConfig.java プロジェクト: fxpz/secor
        @Override
        protected SecorConfig initialValue() {
          // Load the default configuration file first
          Properties systemProperties = System.getProperties();
          String configProperty = systemProperties.getProperty("config");

          PropertiesConfiguration properties;
          try {
            properties = new PropertiesConfiguration(configProperty);
          } catch (ConfigurationException e) {
            throw new RuntimeException("Error loading configuration from " + configProperty);
          }

          for (final Map.Entry<Object, Object> entry : systemProperties.entrySet()) {
            properties.setProperty(entry.getKey().toString(), entry.getValue());
          }

          return new SecorConfig(properties);
        }
コード例 #16
0
  /** Load the properties contained within ou=Config node in LDAP. */
  private void loadRemoteConfig() {
    try {
      // Retrieve parameters from the config node stored in target LDAP DIT:
      String realmName = config.getString(GlobalIds.CONFIG_REALM, "DEFAULT");
      if (realmName != null && realmName.length() > 0) {
        LOG.info("static init: load config realm [{}]", realmName);
        Properties props = getRemoteConfig(realmName);
        if (props != null) {
          for (Enumeration<?> e = props.propertyNames(); e.hasMoreElements(); ) {
            String key = (String) e.nextElement();
            String val = props.getProperty(key);
            config.setProperty(key, val);
          }
        }

        // init ldap util vals since config is stored on server
        boolean ldapfilterSizeFound = (getProperty(GlobalIds.LDAP_FILTER_SIZE_PROP) != null);
        LdapUtil.getInstance().setLdapfilterSizeFound(ldapfilterSizeFound);
        LdapUtil.getInstance().setLdapMetaChars(loadLdapEscapeChars());
        LdapUtil.getInstance().setLdapReplVals(loadValidLdapVals());
        try {
          String lenProp = getProperty(GlobalIds.LDAP_FILTER_SIZE_PROP);
          if (ldapfilterSizeFound) {
            LdapUtil.getInstance().setLdapFilterSize(Integer.valueOf(lenProp));
          }
        } catch (java.lang.NumberFormatException nfe) {
          String error = "loadRemoteConfig caught NumberFormatException=" + nfe;
          LOG.warn(error);
        }
        remoteConfigLoaded = true;
      } else {
        LOG.info("static init: config realm not setup");
      }
    } catch (SecurityException se) {
      String error = "static init: Error loading from remote config: SecurityException=" + se;
      LOG.error(error);
      throw new CfgRuntimeException(GlobalErrIds.FT_CONFIG_INITIALIZE_FAILED, error, se);
    }
  }
コード例 #17
0
  /**
   * This creates a new database connector for use. It establishes a database connection immediately
   * ready for use.
   */
  public ZabbixDirectDbDataSourceAdaptor() {
    HISTORY_TABLES.add("history");
    HISTORY_TABLES.add("history_str");
    HISTORY_TABLES.add("history_uint");
    HISTORY_TABLES.add("history_text");

    try {
      PropertiesConfiguration config;
      if (new File(CONFIG_FILE).exists()) {
        config = new PropertiesConfiguration(CONFIG_FILE);
      } else {
        config = new PropertiesConfiguration();
        config.setFile(new File(CONFIG_FILE));
      }
      config.setAutoSave(
          true); // This will save the configuration file back to disk. In case the defaults need
                 // setting.
      databaseURL = config.getString("iaas.energy.modeller.zabbix.db.url", databaseURL);
      config.setProperty("iaas.energy.modeller.zabbix.db.url", databaseURL);
      databaseDriver = config.getString("iaas.energy.modeller.zabbix.db.driver", databaseDriver);
      config.setProperty("iaas.energy.modeller.zabbix.db.driver", databaseDriver);
      databasePassword =
          config.getString("iaas.energy.modeller.zabbix.db.password", databasePassword);
      config.setProperty("iaas.energy.modeller.zabbix.db.password", databasePassword);
      databaseUser = config.getString("iaas.energy.modeller.zabbix.db.user", databaseUser);
      config.setProperty("iaas.energy.modeller.zabbix.db.user", databaseUser);
      begins = config.getString("iaas.energy.modeller.filter.begins", begins);
      config.setProperty("iaas.energy.modeller.filter.begins", begins);
      isHost = config.getBoolean("iaas.energy.modeller.filter.isHost", isHost);
      config.setProperty("iaas.energy.modeller.filter.isHost", isHost);

    } catch (ConfigurationException ex) {
      DB_LOGGER.log(Level.SEVERE, "Error loading the configuration of the IaaS energy modeller");
    }
    try {
      connection = getConnection();
    } catch (IOException | SQLException | ClassNotFoundException ex) {
      DB_LOGGER.log(Level.SEVERE, "Failed to establish the connection to the Zabbix DB", ex);
    }
  }
コード例 #18
0
 public static void setTemperatureInputFolder(File temperatureInputFolder) {
   Options.temperatureInputFolder = temperatureInputFolder;
   configuration.setProperty(
       FileConfiguration.TEMPERATURE_FOLDER, temperatureInputFolder.getAbsolutePath());
 }
コード例 #19
0
  private static PropertiesConfiguration initConfiguration(String[] args) {
    OptionSet options = null;
    OptionParser parser = new OptionParser();
    PropertiesConfiguration conf = null;

    // Setup the option parser
    parser.accepts("help", "print this help statement");
    parser
        .accepts("conf", "configuration file (required)")
        .withRequiredArg()
        .ofType(String.class)
        .required();
    parser
        .accepts("interval", "interval between rate measurements")
        .withRequiredArg()
        .ofType(Integer.class);
    parser.accepts("ops", "total number of operations").withRequiredArg().ofType(Integer.class);
    parser
        .accepts("lbound", "lowerbound for the number of operations")
        .withRequiredArg()
        .ofType(Integer.class);
    parser
        .accepts("time", "time tests will run for (milliseconds)")
        .withRequiredArg()
        .ofType(Integer.class);
    parser.accepts("sync", "sync or async test").withRequiredArg().ofType(Boolean.class);

    // Parse and gather the arguments
    try {
      options = parser.parse(args);
    } catch (OptionException e) {
      System.out.println("\nError parsing arguments.\n");
      try {
        parser.printHelpOn(System.out);
      } catch (IOException e2) {
        LOG.error("Exception while printing help message", e2);
      }
      System.exit(-1);
    }

    Integer interval = (Integer) options.valueOf("interval");
    Integer totOps = (Integer) options.valueOf("ops");
    Integer lowerbound = (Integer) options.valueOf("lbound");
    Integer time = (Integer) options.valueOf("time");
    Boolean sync = (Boolean) options.valueOf("sync");

    // Load and parse the configuration file
    String configFile = (String) options.valueOf("conf");
    LOG.info("Loading benchmark from configuration file: " + configFile);

    try {
      conf = new PropertiesConfiguration(configFile);
    } catch (ConfigurationException e) {
      LOG.error("Failed to read configuration file: " + configFile, e);
      System.exit(-2);
    }

    // If there are options from command line, override the conf
    if (interval != null) conf.setProperty("interval", interval);
    if (totOps != null) conf.setProperty("totalOperations", totOps);
    if (lowerbound != null) conf.setProperty("lowerbound", lowerbound);
    if (time != null) conf.setProperty("totalTime", time);
    if (sync != null) conf.setProperty("sync", sync);

    return conf;
  }
コード例 #20
0
 public void set(String key, String[] values) {
   if (key != null) properties.setProperty(key, values);
 }
コード例 #21
0
  /** Constructs the segment metadata file, and writes in outputDir */
  private void writeMetadata(File outputDir, int totalDocs) throws ConfigurationException {
    final PropertiesConfiguration properties =
        new PropertiesConfiguration(
            new File(outputDir, V1Constants.MetadataKeys.METADATA_FILE_NAME));

    properties.setProperty(SEGMENT_NAME, segmentName);
    properties.setProperty(TABLE_NAME, config.getTableName());
    properties.setProperty(DIMENSIONS, config.getDimensions());
    properties.setProperty(METRICS, config.getMetrics());
    properties.setProperty(TIME_COLUMN_NAME, config.getTimeColumnName());
    properties.setProperty(TIME_INTERVAL, "not_there");
    properties.setProperty(SEGMENT_TOTAL_DOCS, String.valueOf(totalDocs));

    // StarTree
    Joiner csv = Joiner.on(",");
    properties.setProperty(SPLIT_ORDER, csv.join(splitOrder));
    properties.setProperty(SPLIT_EXCLUDES, csv.join(starTreeIndexSpec.getSplitExcludes()));
    properties.setProperty(MAX_LEAF_RECORDS, starTreeIndexSpec.getMaxLeafRecords());
    properties.setProperty(
        EXCLUDED_DIMENSIONS, csv.join(starTreeIndexSpec.getExcludedDimensions()));

    String timeColumn = config.getTimeColumnName();
    if (columnInfo.get(timeColumn) != null) {
      properties.setProperty(SEGMENT_START_TIME, columnInfo.get(timeColumn).getMin());
      properties.setProperty(SEGMENT_END_TIME, columnInfo.get(timeColumn).getMax());
      properties.setProperty(TIME_UNIT, config.getTimeUnitForSegment());
    }

    if (config.containsKey(SEGMENT_START_TIME)) {
      properties.setProperty(SEGMENT_START_TIME, config.getStartTime());
    }
    if (config.containsKey(SEGMENT_END_TIME)) {
      properties.setProperty(SEGMENT_END_TIME, config.getStartTime());
    }
    if (config.containsKey(TIME_UNIT)) {
      properties.setProperty(TIME_UNIT, config.getTimeUnitForSegment());
    }

    for (final String key : config.getAllCustomKeyValuePair().keySet()) {
      properties.setProperty(key, config.getAllCustomKeyValuePair().get(key));
    }

    for (final String column : columnInfo.keySet()) {
      properties.setProperty(
          V1Constants.MetadataKeys.Column.getKeyFor(column, CARDINALITY),
          String.valueOf(columnInfo.get(column).getSortedUniqueElementsArray().length));
      properties.setProperty(
          V1Constants.MetadataKeys.Column.getKeyFor(column, TOTAL_DOCS), String.valueOf(totalDocs));
      properties.setProperty(
          V1Constants.MetadataKeys.Column.getKeyFor(column, DATA_TYPE),
          schema.getFieldSpecFor(column).getDataType().toString());
      properties.setProperty(
          V1Constants.MetadataKeys.Column.getKeyFor(column, BITS_PER_ELEMENT),
          String.valueOf(
              SingleValueUnsortedForwardIndexCreator.getNumOfBits(
                  columnInfo.get(column).getSortedUniqueElementsArray().length)));

      properties.setProperty(
          V1Constants.MetadataKeys.Column.getKeyFor(column, DICTIONARY_ELEMENT_SIZE),
          String.valueOf(dictionaryCreatorMap.get(column).getStringColumnMaxLength()));

      properties.setProperty(
          V1Constants.MetadataKeys.Column.getKeyFor(column, COLUMN_TYPE),
          String.valueOf(schema.getFieldSpecFor(column).getFieldType().toString()));

      properties.setProperty(
          V1Constants.MetadataKeys.Column.getKeyFor(column, IS_SORTED),
          String.valueOf(columnInfo.get(column).isSorted()));

      properties.setProperty(
          V1Constants.MetadataKeys.Column.getKeyFor(column, HAS_NULL_VALUE),
          String.valueOf(columnInfo.get(column).hasNulls()));
      properties.setProperty(
          V1Constants.MetadataKeys.Column.getKeyFor(
              column, V1Constants.MetadataKeys.Column.HAS_DICTIONARY),
          String.valueOf(columnInfo.get(column).isCreateDictionary()));

      properties.setProperty(
          V1Constants.MetadataKeys.Column.getKeyFor(column, HAS_INVERTED_INDEX),
          String.valueOf(true));

      properties.setProperty(
          V1Constants.MetadataKeys.Column.getKeyFor(column, IS_SINGLE_VALUED),
          String.valueOf(schema.getFieldSpecFor(column).isSingleValueField()));

      properties.setProperty(
          V1Constants.MetadataKeys.Column.getKeyFor(column, MAX_MULTI_VALUE_ELEMTS),
          String.valueOf(columnInfo.get(column).getMaxNumberOfMutiValueElements()));

      properties.setProperty(
          V1Constants.MetadataKeys.Column.getKeyFor(column, TOTAL_NUMBER_OF_ENTRIES),
          String.valueOf(columnInfo.get(column).getTotalNumberOfEntries()));
    }

    properties.save();
  }
コード例 #22
0
 public static void setInputFolder(File inputFolder) {
   Options.inputFolder = inputFolder;
   configuration.setProperty(FileConfiguration.INPUT_FOLDER, inputFolder.getAbsolutePath());
 }
コード例 #23
0
 public static void setOutputFolder(File outputFolder) {
   Options.outputFolder = outputFolder;
   configuration.setProperty(FileConfiguration.OUTPUT_FOLDER, outputFolder.getAbsolutePath());
 }
コード例 #24
0
  /** Load these config parameters from the system.properties. */
  private void getExternalConfig() {
    String PREFIX = "getExternalConfig override name [{}] value [{}]";
    // Check to see if the ldap host has been overridden by a system property:
    String szValue = System.getProperty(EXT_LDAP_HOST);
    if (StringUtils.isNotEmpty(szValue)) {
      config.setProperty(GlobalIds.LDAP_HOST, szValue);
      LOG.info(PREFIX, GlobalIds.LDAP_HOST, szValue);
    }
    // Check to see if the ldap port has been overridden by a system property:
    szValue = System.getProperty(EXT_LDAP_PORT);
    if (StringUtils.isNotEmpty(szValue)) {
      config.setProperty(GlobalIds.LDAP_PORT, szValue);
      LOG.info(PREFIX, GlobalIds.LDAP_PORT, szValue);
    }

    // Check to see if the admin pool uid has been overridden by a system property:
    szValue = System.getProperty(EXT_LDAP_ADMIN_POOL_UID);
    if (StringUtils.isNotEmpty(szValue)) {
      config.setProperty(GlobalIds.LDAP_ADMIN_POOL_UID, szValue);
      // never display ldap admin userid name to log:
      LOG.info("getExternalConfig override name [{}]", GlobalIds.LDAP_ADMIN_POOL_UID);
    }

    // Check to see if the admin pool pw has been overridden by a system property:
    szValue = System.getProperty(EXT_LDAP_ADMIN_POOL_PW);
    if (StringUtils.isNotEmpty(szValue)) {
      config.setProperty(GlobalIds.LDAP_ADMIN_POOL_PW, szValue);
      // never display password of any type to log:
      LOG.info("getExternalConfig override name [{}]", GlobalIds.LDAP_ADMIN_POOL_PW);
    }

    // Check to see if the admin pool min connections has been overridden by a system property:
    szValue = System.getProperty(EXT_LDAP_ADMIN_POOL_MIN);
    if (StringUtils.isNotEmpty(szValue)) {
      config.setProperty(GlobalIds.LDAP_ADMIN_POOL_MIN, szValue);
      LOG.info(PREFIX, GlobalIds.LDAP_ADMIN_POOL_MIN, szValue);
    }

    // Check to see if the admin pool max connections has been overridden by a system property:
    szValue = System.getProperty(EXT_LDAP_ADMIN_POOL_MAX);
    if (StringUtils.isNotEmpty(szValue)) {
      config.setProperty(GlobalIds.LDAP_ADMIN_POOL_MAX, szValue);
      LOG.info(PREFIX, GlobalIds.LDAP_ADMIN_POOL_MAX, szValue);
    }

    // Check to see if ssl enabled parameter has been overridden by a system property:
    szValue = System.getProperty(EXT_ENABLE_LDAP_SSL);
    if (StringUtils.isNotEmpty(szValue)) {
      config.setProperty(GlobalIds.ENABLE_LDAP_SSL, szValue);
      LOG.info(PREFIX, GlobalIds.ENABLE_LDAP_SSL, szValue);
    }

    // Check to see if the ssl debug enabled parameter has been overridden by a system property:
    szValue = System.getProperty(EXT_ENABLE_LDAP_SSL_DEBUG);
    if (StringUtils.isNotEmpty(szValue)) {
      config.setProperty(GlobalIds.ENABLE_LDAP_SSL_DEBUG, szValue);
      LOG.info(PREFIX, GlobalIds.ENABLE_LDAP_SSL_DEBUG, szValue);
    }

    // Check to see if the trust store location has been overridden by a system property:
    szValue = System.getProperty(EXT_TRUST_STORE);
    if (StringUtils.isNotEmpty(szValue)) {
      config.setProperty(GlobalIds.TRUST_STORE, szValue);
      LOG.info(PREFIX, GlobalIds.TRUST_STORE, szValue);
    }

    // Check to see if the trust store password has been overridden by a system property:
    szValue = System.getProperty(EXT_TRUST_STORE_PW);
    if (StringUtils.isNotEmpty(szValue)) {
      config.setProperty(GlobalIds.TRUST_STORE_PW, szValue);
      // never display password value to log:
      LOG.info("getExternalConfig override name [{}]", GlobalIds.TRUST_STORE_PW);
    }

    // Check to see if the trust store set parameter has been overridden by a system property:
    szValue = System.getProperty(EXT_SET_TRUST_STORE_PROP);
    if (StringUtils.isNotEmpty(szValue)) {
      config.setProperty(GlobalIds.SET_TRUST_STORE_PROP, szValue);
      LOG.info(PREFIX, GlobalIds.SET_TRUST_STORE_PROP, szValue);
    }

    // Check to see if the config realm name has been overridden by a system property:
    szValue = System.getProperty(EXT_CONFIG_REALM);
    if (StringUtils.isNotEmpty(szValue)) {
      config.setProperty(GlobalIds.CONFIG_REALM, szValue);
      LOG.info(PREFIX, GlobalIds.CONFIG_REALM, szValue);
    }

    // Check to see if the config realm name has been overridden by a system property:
    szValue = System.getProperty(EXT_CONFIG_ROOT_DN);
    if (StringUtils.isNotEmpty(szValue)) {
      config.setProperty(GlobalIds.CONFIG_ROOT_PARAM, szValue);
      LOG.info(PREFIX, GlobalIds.CONFIG_ROOT_PARAM, szValue);
    }

    // Check to see if the ldap server type has been overridden by a system property:
    szValue = System.getProperty(EXT_SERVER_TYPE);
    if (StringUtils.isNotEmpty(szValue)) {
      config.setProperty(GlobalIds.SERVER_TYPE, szValue);
      LOG.info(PREFIX, GlobalIds.SERVER_TYPE, szValue);
    }
  }
コード例 #25
0
 @Override
 public void setProperty(String s, Object o) {
   runtimeConfiguration.setProperty(s, o);
 }
コード例 #26
0
ファイル: ConfigGenerator.java プロジェクト: cvgaviao/yajsw
  private static void createJavaConfigFile(Process p, File input, File output) {
    System.out.println("creating java configuration file");

    try {
      String workingDir = p.getWorkingDir();
      String cmd = p.getCommand();

      /*
       * MonitoredHost monitoredhost =
       * MonitoredHost.getMonitoredHost("//localhost"); VmIdentifier
       * vmidentifier = new VmIdentifier("" + p.getPid()); MonitoredVm vm
       * = monitoredhost.getMonitoredVm(vmidentifier, 0);
       */

      // System.out.println("cmd " +MonitoredVmUtil.commandLine(vm));
      PropertiesConfiguration conf;
      if (input == null) conf = new PropertiesConfiguration();
      else conf = new PropertiesConfiguration(input);

      JCLParser parsedCmd = JCLParser.parse(cmd);
      /*
       * String mainClass = MonitoredVmUtil.mainClass(vm, true); if
       * (!isNotNullEmpty(mainClass)) {System.out.println(
       * "could not retrieve main class of java application -> abort");
       * return; } mainClass = confString(mainClass); if
       * (mainClass.endsWith(".jar"))
       * conf.setProperty("wrapper.java.app.jar",
       * relativeString(mainClass, workingDir)); else
       * conf.setProperty("wrapper.java.app.mainclass", mainClass);
       */
      if (parsedCmd.getMainClass() != null)
        conf.setProperty("wrapper.java.app.mainclass", parsedCmd.getMainClass());
      else conf.setProperty("wrapper.java.app.jar", relativeString(parsedCmd.getJar(), workingDir));

      /*
       * // this does not seem to work correctly -> get jvm the hard way
       * // System.out.println("vmVersion " + vmVersion); String jvm =
       * null; if (cmd.startsWith("\"")) jvm = cmd.substring(0,
       * cmd.indexOf("\" ") + 1); else jvm = cmd.substring(0,
       * cmd.indexOf(" ")); if (isNotNullEmpty(jvm)) { jvm =
       * confString(jvm); conf.setProperty("wrapper.java.command", jvm); }
       */
      conf.setProperty("wrapper.java.command", parsedCmd.getJava());
      /*
       * String classpath = ((StringMonitor)
       * vm.findByName("java.property.java.class.path")).stringValue(); if
       * (isNotNullEmpty(classpath)) { classpath =
       * relativeString(classpath, workingDir); classpath =
       * confString(classpath); String[] classpaths =
       * classpath.split(System.getProperty("path.separator")); int i = 1;
       * for (String file : classpaths) {
       * conf.setProperty("wrapper.java.classpath." + i, file); i++; } }
       */
      int i = 1;
      List<String> classpathList = parsedCmd.getClasspath();
      // no longer required - wrapper will automatically add the jar to
      // the classpath
      // if (conf.getString("wrapper.java.app.jar", null) != null)
      // classpathList.add(conf.getString("wrapper.java.app.jar"));
      if (classpathList == null || classpathList.isEmpty())
        classpathList = getClasspathFromEnvironment(p);
      if (classpathList.isEmpty() && parsedCmd.getJar() == null) classpathList.add(".");
      for (String classpath : classpathList) {
        classpath = relativeString(classpath, workingDir);
        classpath = confString(classpath);
        // yajsw handles wildcards differently.
        if (classpath.endsWith("*")) classpath = classpath + ".jar";
        conf.setProperty("wrapper.java.classpath." + i++, classpath);
      }

      /*
       * // bug in MonitoredVMUtil 'c:/x.txt "d d"' returns 'c:/x.txt d d'
       * //String mainArgs = MonitoredVmUtil.mainArgs(vm); // TODO really
       * parse the cmd String mainArgs =
       * cmd.substring(cmd.indexOf(" "+mainClass
       * +" ")+mainClass.length()+2); if (isNotNullEmpty(mainArgs)) { List
       * args = splitArgs(mainArgs); int i = 1; for (Iterator
       * it=args.iterator(); it.hasNext(); ) { String arg = (String)
       * it.next(); arg = relativeString(arg, workingDir); arg =
       * confString(arg); conf.setProperty("wrapper.app.parameter."+i++,
       * arg); } }
       */

      i = 1;
      for (String arg : parsedCmd.getArgs()) {
        arg = relativeString(arg, workingDir);
        arg = confString(arg);
        if (arg != null && !"".equals(arg)) conf.setProperty("wrapper.app.parameter." + i++, arg);
      }
      /*
       * // bug in MonitoredVMUtil '"-Xd=a a"' returns '-Xd=a a' //String
       * jvmArgs = MonitoredVmUtil.jvmArgs(vm); // TODO really parse the
       * cmd String jvmArgs = cmd.substring(jvm.length(),
       * cmd.indexOf(" "+mainClass+" ")); if (cmd.startsWith("\""))
       * jvmArgs = jvmArgs.substring(1); jvmArgs =
       * jvmArgs.replace(classpath, ""); jvmArgs =
       * jvmArgs.replace(" -classpath ", ""); jvmArgs =
       * jvmArgs.replace(" -cp ", "");
       *
       * if (isNotNullEmpty(jvmArgs)) { List args = splitArgs(jvmArgs);
       * int i = 1; for (Iterator it=args.iterator(); it.hasNext(); ) {
       * String arg = (String) it.next(); arg = relativeString(arg,
       * workingDir); arg = confString(arg);
       * conf.setProperty("wrapper.java.additional."+i++, arg); } }
       *
       * String jvmFlags = MonitoredVmUtil.jvmFlags(vm);
       */
      i = 1;
      for (String opt : parsedCmd.getVmOptions()) {
        opt = relativeString(opt, workingDir);
        opt = confString(opt);
        conf.setProperty("wrapper.java.additional." + i++, opt);
      }

      if (isNotNullEmpty(workingDir)) {
        workingDir = confString(workingDir);
        conf.setProperty("wrapper.working.dir", workingDir);
      }
      String title = p.getTitle();
      if (cmd.equals(title)) title = parsedCmd.getMainClass();

      if (isNotNullEmpty(title)) {
        title = confString(title);
        conf.setProperty("wrapper.console.title", title);
        conf.setProperty("wrapper.ntservice.name", title);
        conf.setProperty("wrapper.ntservice.displayname", title);
        conf.setProperty("wrapper.ntservice.description", title);
      }
      /*
       * String account = p.getUser(); if (account != null &&
       * !"".equals(account)) conf.setProperty("wrapper.app.account",
       * account);
       */

      /*
       * List l = vm.findByPattern(".*"); for (Iterator it = l.iterator();
       * it.hasNext(); ) { Monitor m = (Monitor) it.next();
       * System.out.println(m.getName()); System.out.println("> "+
       * m.getValue()); }
       */

      conf.save(output);
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
コード例 #27
0
  @BeforeClass
  public void setUp() throws Exception {
    jksPath = new Path(Files.createTempDirectory("tempproviders").toString(), "test.jks");
    providerUrl = JavaKeyStoreProvider.SCHEME_NAME + "://file/" + jksPath.toUri();

    String persistDir = TestUtils.getTempDirectory();

    setupKDCAndPrincipals();
    setupCredentials();

    // client will actually only leverage subset of these properties
    final PropertiesConfiguration configuration = getSSLConfiguration(providerUrl);

    persistSSLClientConfiguration(configuration);

    TestUtils.writeConfiguration(
        configuration, persistDir + File.separator + ApplicationProperties.APPLICATION_PROPERTIES);

    String confLocation = System.getProperty("atlas.conf");
    URL url;
    if (confLocation == null) {
      url =
          NegativeSSLAndKerberosTest.class.getResource(
              "/" + ApplicationProperties.APPLICATION_PROPERTIES);
    } else {
      url = new File(confLocation, ApplicationProperties.APPLICATION_PROPERTIES).toURI().toURL();
    }
    configuration.load(url);

    configuration.setProperty(TLS_ENABLED, true);
    configuration.setProperty("atlas.authentication.method.kerberos", "true");
    configuration.setProperty("atlas.authentication.keytab", userKeytabFile.getAbsolutePath());
    configuration.setProperty("atlas.authentication.principal", "dgi/localhost@" + kdc.getRealm());

    configuration.setProperty("atlas.authentication.method.file", "false");
    configuration.setProperty("atlas.authentication.method.kerberos", "true");
    configuration.setProperty(
        "atlas.authentication.method.kerberos.principal", "HTTP/localhost@" + kdc.getRealm());
    configuration.setProperty(
        "atlas.authentication.method.kerberos.keytab", httpKeytabFile.getAbsolutePath());
    configuration.setProperty(
        "atlas.authentication.method.kerberos.name.rules",
        "RULE:[1:$1@$0](.*@EXAMPLE.COM)s/@.*//\nDEFAULT");

    configuration.setProperty("atlas.authentication.method.file", "true");
    configuration.setProperty(
        "atlas.authentication.method.file.filename", persistDir + "/users-credentials");
    configuration.setProperty("atlas.auth.policy.file", persistDir + "/policy-store.txt");

    TestUtils.writeConfiguration(
        configuration, persistDir + File.separator + ApplicationProperties.APPLICATION_PROPERTIES);

    setupUserCredential(persistDir);
    setUpPolicyStore(persistDir);

    // save original setting
    originalConf = System.getProperty("atlas.conf");
    System.setProperty("atlas.conf", persistDir);

    dgiClient = new AtlasClient(configuration, DGI_URL);

    secureEmbeddedServer =
        new TestSecureEmbeddedServer(21443, getWarPath()) {
          @Override
          public Configuration getConfiguration() {
            return configuration;
          }
        };
    secureEmbeddedServer.getServer().start();
  }
コード例 #28
0
 @Test
 public void shouldSkipTendencies() {
   PropertiesConfiguration conf = new PropertiesConfiguration();
   conf.setProperty(CoreProperties.SKIP_TENDENCIES_PROPERTY, true);
   assertThat(new TimeMachineConfiguration(conf).skipTendencies(), is(true));
 }
コード例 #29
0
 public static void setSolenoidValvesOfInterest(List<Double> solenoidValvesOfInterest) {
   Options.solenoidValvesOfInterest = solenoidValvesOfInterest;
   configuration.setProperty(
       Options.OPTIONS_SOLENOID_VALVES_OF_INTEREST, solenoidValvesOfInterest);
 }