List of usage examples for java.util Properties containsKey
@Override public boolean containsKey(Object key)
From source file:eu.eidas.config.impl.FileEidasNodeConfiguration.java
private void loadEncryptionConf() { CertificateManagerConfigurationImpl samlConfig = null; Properties encryptionProps = new Properties(); if (eidasProperties.containsKey(SAML_ENGINE_REPOSITORY_URL)) { //in this case a SamlEngineConfiguration instance will hold the SamlEngine configuration samlConfig = EidasConfigManagerUtil.getInstance().getCertificateManagerConfiguration(); }/* ww w .ja va2 s . co m*/ if (samlConfig != null) { encryptionProps = ((FileConfigurationRepository) repository) .loadPropertiesFromXML("encryptionConf.xml"); } for (EIDASNodeCountry country : countries) { String encryptionKey = "EncryptTo." + country.getCode(); if (encryptionProps.containsKey(encryptionKey)) { country.setEncryptionTo(Boolean.parseBoolean(encryptionProps.getProperty(encryptionKey))); } encryptionKey = "EncryptFrom." + country.getCode(); if (encryptionProps.containsKey(encryptionKey)) { country.setEncryptionFrom(Boolean.parseBoolean(encryptionProps.getProperty(encryptionKey))); } } }
From source file:fr.ens.biologie.genomique.eoulsan.it.ITFactory.java
/** * Load configuration file in properties object. * @param configurationFile configuration file * @return properties// ww w. jav a 2 s. c o m * @throws IOException if an error occurs when reading file. * @throws EoulsanException if an error occurs evaluate value property. */ private static Properties loadProperties(final File configurationFile) throws IOException, EoulsanException { // TODO Replace properties by treeMap to use constant in set environment // variables final Properties rawProps = new Properties(); final Properties props; checkExistingStandardFile(configurationFile, "test configuration file"); // Load configuration file rawProps.load(newReader(configurationFile, Charsets.toCharset(Globals.DEFAULT_FILE_ENCODING))); props = evaluateProperties(rawProps); // Check include final String includeOption = props.getProperty(INCLUDE_CONF_KEY); if (includeOption != null) { // Check configuration file final File otherConfigurationFile = new File(includeOption); checkExistingStandardFile(otherConfigurationFile, "configuration file doesn't exist"); // Load configuration in global configuration final Properties rawPropsIncludedConfigurationFile = new Properties(); rawPropsIncludedConfigurationFile .load(newReader(otherConfigurationFile, Charsets.toCharset(Globals.DEFAULT_FILE_ENCODING))); final Properties newProps = evaluateProperties(rawPropsIncludedConfigurationFile); for (final String propertyName : newProps.stringPropertyNames()) { // No overwrite property from includes file configuration if (props.containsKey(propertyName)) { continue; } props.put(propertyName, newProps.getProperty(propertyName)); } } // Add default value addDefaultProperties(props); return props; }
From source file:coral.reef.service.ReefService.java
public boolean startCoralService(String name) { CoralBean coralBean = coralBeanRepository.findOne(name); Properties properties = fillDefaultProperties(); InputStream is = new ByteArrayInputStream(coralBean.getProperties().getBytes()); try {/*w w w . j a v a 2 s . com*/ properties.load(is); is.close(); } catch (IOException e) { // never happens e.printStackTrace(); } CoralUtils.hoststr = properties.getProperty("coral.head.coralhost", "exp://host/"); String path = properties.getProperty("coral.web.path", coralBean.getName()); String host = properties.getProperty("coral.web.hostname", "localhost"); int port = Integer.parseInt(properties.getProperty("coral.web.port", "8080")); if (!properties.containsKey("coral.web.exphost")) { properties.setProperty("coral.web.exphost", "http://" + host + ":" + port + "/" + path + "/"); } ReefHandler handler = new ReefHandler(name, properties); this.handlers.put(coralBean.getName(), handler); // this.services.put( expname, serv); this.serviceProperties.put(coralBean.getName(), properties); coralBean.setStart(true); coralBeanRepository.save(coralBean); CoralRun run = new CoralRun(); run.setProperties(coralBean.getProperties()); run.setTimestamp(new Date()); run.setCoralBean(coralBean); runRepository.save(run); return true; }
From source file:org.apache.nutch.searcher.custom.CustomFieldQueryFilter.java
public void setConf(Configuration conf) { try {/*from w w w . j a va2s .co m*/ this.conf = conf; FileSystem fs = FileSystem.get(conf); String configFile = conf.get("custom.fields.config", "custom-fields.xml"); LOG.info("Reading configuration field configuration from " + configFile); Properties customFieldProps = new Properties(); InputStream fis = CustomFields.class.getClassLoader().getResourceAsStream(configFile); if (fis == null) { throw new IOException("Was unable to open " + configFile); } customFieldProps.loadFromXML(fis); Enumeration keys = customFieldProps.keys(); while (keys.hasMoreElements()) { String prop = (String) keys.nextElement(); if (prop.endsWith(".name")) { String propName = prop.substring(0, prop.length() - 5); String name = customFieldProps.getProperty(prop); fieldNames.add(name); String boostKey = propName + ".boost"; if (customFieldProps.containsKey(boostKey)) { float boost = Float.parseFloat(customFieldProps.getProperty(boostKey)); boosts.put(name, boost); } } } } catch (Exception e) { LOG.error("Error loading custom field properties:\n" + StringUtils.stringifyException(e)); } }
From source file:org.onebusaway.nyc.vehicle_tracking.impl.VehicleLocationSimulationServiceImpl.java
private double getLocationSigma(Properties properties) { double locationSigma = 0.0; if (properties.containsKey(ARG_LOCATION_SIGMA)) locationSigma = Double.parseDouble(properties.getProperty(ARG_LOCATION_SIGMA)); return locationSigma; }
From source file:com.octo.captcha.j2ee.ImageCaptchaService.java
/** * Initialize the service from a Properties : create * the internal store and instanciate an image captcha * engine./*from w w w . j a va2 s . c o m*/ * @param theInitializationValues the Properties that * contains the initialization parameters */ private void initializeService(Properties theInitializationValues) { // Verfify that all required initialization values are present if (theInitializationValues == null) { throw new RuntimeException("No initialization values provided" + " (Properties object is null)"); } else { if (!theInitializationValues.containsKey(MAX_NUMBER_OF_SIMULTANEOUS_CAPTCHAS_PROP)) { throw new RuntimeException( MAX_NUMBER_OF_SIMULTANEOUS_CAPTCHAS_PROP + " initialization parameter missing"); } if (!theInitializationValues.containsKey(MIN_GUARANTED_STORAGE_DELAY_IN_SECONDS_PROP)) { throw new RuntimeException( MIN_GUARANTED_STORAGE_DELAY_IN_SECONDS_PROP + " initialization parameter missing"); } if (!theInitializationValues.containsKey(ENGINE_CLASS_INIT_PARAMETER_PROP)) { throw new RuntimeException(ENGINE_CLASS_INIT_PARAMETER_PROP + " initialization parameter missing"); } } // get the maximum number of simultaneous captchas from the // properties String maxNumberOfSimultaneousCaptchasAsString = theInitializationValues .getProperty(MAX_NUMBER_OF_SIMULTANEOUS_CAPTCHAS_PROP); Integer maxNumberOfSimultaneousCaptchas; try { maxNumberOfSimultaneousCaptchas = new Integer(maxNumberOfSimultaneousCaptchasAsString); } catch (NumberFormatException e) { throw new RuntimeException("Initialization error : initialization parameter " + MAX_NUMBER_OF_SIMULTANEOUS_CAPTCHAS_PROP + " must be an integer !"); } this.maxNumberOfSimultaneousCaptchas = maxNumberOfSimultaneousCaptchas.intValue(); // get the maximum waiting delay between guaranted to the user // between generation and verification of a captcha from the // properties String minGuarantedStorageDelayInSecondsAsString = theInitializationValues .getProperty(MIN_GUARANTED_STORAGE_DELAY_IN_SECONDS_PROP); Integer minGuarantedStorageDelayInSeconds; try { minGuarantedStorageDelayInSeconds = new Integer(minGuarantedStorageDelayInSecondsAsString); } catch (NumberFormatException e) { throw new RuntimeException("Initialization error : initialization parameter " + MIN_GUARANTED_STORAGE_DELAY_IN_SECONDS_PROP + " must be an integer !"); } this.minGuarantedStorageDelayInSeconds = minGuarantedStorageDelayInSeconds.intValue(); // create the internal store this.internalStore = new ConstantCapacityHashtable(this.maxNumberOfSimultaneousCaptchas, (this.minGuarantedStorageDelayInSeconds * 1000)); // get the ImageCaptchaEngine class name from the properties String engineClassName = theInitializationValues.getProperty(ENGINE_CLASS_INIT_PARAMETER_PROP); // create an instance of the engine try { this.engine = (ImageCaptchaEngine) Class.forName(engineClassName).newInstance(); } catch (ClassNotFoundException e) { throw new RuntimeException("Initialization error : can't find class " + engineClassName); } catch (InstantiationException e) { throw new RuntimeException("Initialization error : can't instanciate class " + engineClassName); } catch (IllegalAccessException e) { throw new RuntimeException("Initialization error : can't instanciate class " + engineClassName); } }
From source file:com.googlecode.jgenhtml.Config.java
/** * Gets the value of a numeric option.//w ww . j a va 2 s. co m * @param properties The properties in which to search for the option * @param optName the name of the option to fetch * @return The value of the option if it is explicitly set * null if the option is not set */ private Integer getNumericValue(final Properties properties, final String optName) { Integer result = null; if (properties.containsKey(optName)) { try { int propval = Integer.parseInt(properties.getProperty(optName)); result = propval; } catch (NumberFormatException ex) { LOGGER.log(Level.WARNING, "{0} {1}", new Object[] { optName, ex.getLocalizedMessage() }); } } return result; }
From source file:org.acmsl.dockerfile.maven.DockerfileMojo.java
/** * Retrieves the version of Dockerfile Maven Plugin currently running. * @param properties the pom.properties information. * @return the version entry.// w w w. ja v a 2s. c o m */ @NotNull protected String retrieveOwnVersion(@Nullable final Properties properties) { @NotNull final String result; if ((properties != null) && (properties.containsKey(Literals.VERSION_L))) { result = properties.getProperty(Literals.VERSION_L); } else { result = Literals.UNKNOWN_L; } return result; }
From source file:com.couchbase.jdbc.core.ProtocolImpl.java
public ProtocolImpl(String url, Properties props) { if (props.containsKey(ConnectionParameters.USER)) { user = props.getProperty(ConnectionParameters.USER); }/*from w ww.ja v a 2 s .c o m*/ if (props.containsKey(ConnectionParameters.PASSWORD)) { password = props.getProperty(ConnectionParameters.PASSWORD); } if (props.containsKey("credentials")) { credentials = props.getProperty("credentials"); } this.url = url; setConnectionTimeout(props.getProperty(ConnectionParameters.CONNECTION_TIMEOUT)); if (props.containsKey(ConnectionParameters.SCAN_CONSISTENCY)) { scanConsistency = props.getProperty(ConnectionParameters.SCAN_CONSISTENCY); } requestConfig = RequestConfig.custom().setConnectionRequestTimeout(0).setConnectTimeout(connectTimeout) .setSocketTimeout(connectTimeout).build(); if (props.containsKey(ConnectionParameters.ENABLE_SSL) && props.getProperty(ConnectionParameters.ENABLE_SSL).equals("true")) { SSLContextBuilder builder = SSLContexts.custom(); try { builder.loadTrustMaterial(null, new TrustStrategy() { @Override public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException { return true; } }); SSLContext sslContext = builder.build(); SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, new X509HostnameVerifier() { @Override public void verify(String host, SSLSocket ssl) throws IOException { } @Override public void verify(String host, X509Certificate cert) throws SSLException { } @Override public void verify(String host, String[] cns, String[] subjectAlts) throws SSLException { } @Override public boolean verify(String s, SSLSession sslSession) { return true; } }); Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder .<ConnectionSocketFactory>create().register("https", sslsf).build(); HttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(socketFactoryRegistry); httpClient = HttpClients.custom().setConnectionManager(cm).setDefaultRequestConfig(requestConfig) .build(); ssl = true; } catch (Exception ex) { logger.error("Error creating ssl client", ex); } } else { httpClient = HttpClientBuilder.create().setDefaultRequestConfig(requestConfig).build(); } }
From source file:io.warp10.standalone.StandaloneStreamUpdateHandler.java
public StandaloneStreamUpdateHandler(KeyStore keystore, Properties properties, StandaloneDirectoryClient directoryClient, StoreClient storeClient) { super(StandaloneStreamUpdateWebSocket.class); this.keyStore = keystore; this.storeClient = storeClient; this.directoryClient = directoryClient; this.properties = properties; if (properties.containsKey(Configuration.DATALOG_DIR)) { File dir = new File(properties.getProperty(Configuration.DATALOG_DIR)); if (!dir.exists()) { throw new RuntimeException("Data logging target '" + dir + "' does not exist."); } else if (!dir.isDirectory()) { throw new RuntimeException("Data logging target '" + dir + "' is not a directory."); } else {//from w ww .java 2 s .com loggingDir = dir; LOG.info("Data logging enabled in directory '" + dir + "'."); } String id = properties.getProperty(Configuration.DATALOG_ID); if (null == id) { throw new RuntimeException("Property '" + Configuration.DATALOG_ID + "' MUST be set to a unique value for this instance."); } else { datalogId = new String(OrderPreservingBase64.encode(id.getBytes(Charsets.UTF_8)), Charsets.US_ASCII); } } else { loggingDir = null; datalogId = null; } if (properties.containsKey(Configuration.DATALOG_PSK)) { this.datalogPSK = this.keyStore.decodeKey(properties.getProperty(Configuration.DATALOG_PSK)); } else { this.datalogPSK = null; } }