List of usage examples for java.util Properties toString
@Override public synchronized String toString()
From source file:hudson.UtilTest.java
@Test public void loadProperties() throws IOException { assertEquals(0, Util.loadProperties("").size()); Properties p = Util.loadProperties("k.e.y=va.l.ue"); assertEquals(p.toString(), "va.l.ue", p.get("k.e.y")); assertEquals(p.toString(), 1, p.size()); }
From source file:com.floreantpos.license.FiveStarPOSLicenseManager.java
private final License loadLicense(File licenseFile) throws LicenseException { Properties properties = loadProperties(licenseFile); if (!properties.containsKey(License.SIGNATURE)) { throw new LicenseException("Invalid license key! Please contact our support."); }/*from w w w . j a va2 s .co m*/ String signature = (String) properties.remove(License.SIGNATURE); String encoded = properties.toString(); PublicKey publicKey = readPublicKey(String.format("/license/%s", PUBLIC_KEY_FILE)); if (!verify(encoded.getBytes(), signature, publicKey)) { throw new LicenseException("Invalid license key! Please contact our support."); } License license = new License(properties); if (license.isExpired()) { throw new LicenseException("License key expired! Please contact our support."); } return license; }
From source file:idgs.jdbc.IdgsJdbcDriver.java
@Override public Connection connect(String url, Properties info) throws SQLException { if (url == null) { LOG.error("The url cannot be null"); return null; }//from w w w. j a v a2s .com url = url.trim(); String hiveUrl = null; if (url.isEmpty()) { hiveUrl = Utils.URL_PREFIX; } else { if (!acceptsURL(url)) { LOG.error("The url " + url + " is must be start with " + URL_PREFIX); return null; } hiveUrl = url.replaceFirst(URL_PREFIX, Utils.URL_PREFIX); } LOG.info("JDBC URL: " + url + ", Properties: " + info.toString()); return new IdgsConnection(hiveUrl, info); }
From source file:eu.asterics.ape.main.APE.java
/** * Determins property file location (APE.properties), reads property values and overrides property values given as system property (-Dkey=value). * @throws IOException //from w w w . j a v a 2s . c o m */ private void initProperties() throws IOException { Properties defaultProperties = new Properties(); //Init with empty properties apeProperties = new APEProperties(); try { //APE.properties is expected to be in the project directory URI apePropFileURI = ResourceRegistry.resolveRelativeFilePath(projectDir, "APE.properties").toURI(); defaultProperties.load(new BufferedReader(new InputStreamReader(apePropFileURI.toURL().openStream()))); Notifier.debug("defaultProperties: " + defaultProperties.toString(), null); apeProperties = new APEProperties(defaultProperties); for (Entry<Object, Object> entry : System.getProperties().entrySet()) { if (entry.getKey().toString().startsWith(APEProperties.APE_PROP_PREFIX) || entry.getKey().toString().startsWith(APEProperties.ARE_PROP_PREFIX)) { //sanity check if (entry.getValue() == null) { continue; } String propValue = entry.getValue().toString(); if (entry.getKey().equals(P_APE_MODELS) || entry.getKey().equals(P_APE_BUILD_DIR) || entry.getKey().equals(P_ARE_BASE_URI)) { //if the user provided model paths via the system property and not via the properties file, we have to resolve relative paths to the current directory //and not relative to the APE.projectDir location to make it more intuitive. propValue = resolveURIsToCWD(entry.getValue().toString()); } Notifier.debug("Overriding ApeProp[" + entry.getKey() + "]=" + propValue, null); apeProperties.setProperty(entry.getKey().toString(), propValue); } } //Also add the projectDir to the properties to be sure that the values are in sync. apeProperties.setProperty(P_APE_PROJECT_DIR, projectDir.getPath()); //Now adding default models search path to APE.models property Notifier.debug("Adding APE.projectDir/" + Packager.CUSTOM_BIN_ARE_FOLDER + " as search path for model files to " + APEProperties.P_APE_MODELS, null); String projectDirSearchPath = ResourceRegistry .resolveRelativeFilePath(projectDir, Packager.CUSTOM_BIN_ARE_MODELS_FOLDER).getPath(); apeProperties.setProperty(APEProperties.P_APE_MODELS, apeProperties.getProperty(APEProperties.P_APE_MODELS, "") + ";" + projectDirSearchPath); Notifier.info("ApeProp[" + APEProperties.P_APE_MODELS + "]=" + apeProperties.getProperty(APEProperties.P_APE_MODELS), null); Notifier.debug("Final apeProperties: " + apeProperties.toString(), null); } catch (IOException e) { Notifier.error("STOPPING: Initialization of APE properties failed", e); throw e; } }
From source file:com.tesora.dve.common.PEUrl.java
/** * Create an instance of PEUrl and initialize with values from Properties * object. If the Properties contains a prefix."url" key, PEUrl will be * initialized with that; otherwise it will look for prefix."host", * prefix."port", prefix."type" and prefix."dbname". If setDefaults is true, * then defaults will be filled in for host (localhost), port (3306) and * type (mysql)./*from w w w . j av a 2 s.com*/ * * This doesn't currently handle passing query options via a properties file * * @param Properties * props * @param String * prefix * @param boolean useDefaults * @throws PEException * if the ".url" is malformed. */ public PEUrl(Properties props, String prefix, boolean useDefaults) throws PEException { initializeFromProps(props, prefix, useDefaults); if (!isInitialized()) { throw new PEException("Error creating URL object from Properties: " + props.toString()); } }
From source file:obdii.starter.automotive.iot.ibm.com.iot4a_obdii.IoTPlatformDevice.java
public synchronized boolean createDeviceClient(final JSONObject deviceDefinition) throws Exception { if (deviceDefinition != null) { if (deviceClient != null) { disconnectDevice();/*from w w w . java2s . c o m*/ } currentDevice = deviceDefinition; } if (deviceClient != null) { return true; } if (currentDevice == null) { throw new NoDeviceDefinitionException(); } if (!hasValidOrganization()) { throw new NoIoTPOrganizationException(); } final Properties options = new Properties(); options.setProperty("org", organizationId); options.setProperty("type", typeId); final String deviceId = currentDevice.getString("deviceId"); options.setProperty("id", deviceId); options.setProperty("auth-method", "token"); final String token = getDeviceToken(deviceId); options.setProperty("auth-token", token); deviceClient = new DeviceClient(options); System.out.println("IOTP DEVICE CLIENT CREATED: " + options.toString()); return true; }
From source file:org.springframework.xd.dirt.plugins.job.JobPlugin.java
@Override public void configureProperties(Module module) { final Properties properties = new Properties(); properties.setProperty("xd.stream.name", module.getDeploymentMetadata().getGroup()); if (!module.getProperties().contains(DATE_FORMAT)) { properties.setProperty(DATE_FORMAT, ""); }/*from w w w . j a v a2 s. c om*/ if (!module.getProperties().contains(NUMBER_FORMAT)) { properties.setProperty(NUMBER_FORMAT, ""); } if (!module.getProperties().contains(MAKE_UNIQUE)) { properties.setProperty(MAKE_UNIQUE, String.valueOf(Boolean.TRUE)); } if (logger.isInfoEnabled()) { logger.info("Configuring module with the following properties: " + properties.toString()); } module.addProperties(properties); }
From source file:org.smartfrog.services.www.bulkio.client.SunJavaBulkIOClient.java
@Override public long doUpload(String method, long ioSize) throws IOException, InterruptedException { validateURL();//w w w .j a v a 2 s . c o m CRC32 checksum = new CRC32(); URL targetUrl = getUrl(); getLog().info("Uploading " + ioSize + " bytes to " + targetUrl); HttpURLConnection connection = openConnection(); connection.setRequestMethod(method); connection.setRequestProperty(HttpHeaders.CONTENT_LENGTH, Long.toString(ioSize)); connection.setDoOutput(true); maybeSetChunking(connection); connection.connect(); OutputStream stream = connection.getOutputStream(); long bytes = 0; try { for (bytes = 0; bytes < ioSize; bytes++) { int octet = (AbstractBulkioServlet.getByteFromCounter(bytes)); stream.write(octet); checksum.update(octet); if (interrupted) { throw new InterruptedException( "Interrupted after sending " + bytes + " bytes" + " to " + targetUrl); } } } finally { closeQuietly(stream); } getLog().info("Upload complete, checking results"); checkStatusCode(targetUrl, connection, HttpURLConnection.HTTP_OK); long expectedChecksum = checksum.getValue(); getLog().info("Uploaded " + bytes + " bytes to " + targetUrl + " checksum=" + expectedChecksum); if (bytes != ioSize) { throw new IOException( "Wrong content length uploaded to " + targetUrl + " : put " + ioSize + " but got " + bytes); } if (parseResults) { InputStream inStream = null; Properties props = new Properties(); try { inStream = connection.getInputStream(); props.load(inStream); } finally { closeQuietly(inStream); } long actualChecksum = getLongPropValue(props, IoAttributes.CHECKSUM); if (actualChecksum != expectedChecksum) { throw new IOException("Expected the checksum from upload of " + ioSize + " bytes " + " to " + targetUrl + "to be " + expectedChecksum + " but got " + actualChecksum + "\n Properties: " + props.toString()); } } return ioSize; }
From source file:org.ejbca.core.model.ca.catoken.BaseCAToken.java
/** @see ICAToken#updateProperties(Properties) *///from w w w .ja v a 2 s . co m public void updateProperties(Properties properties) { if (log.isDebugEnabled()) { // This is only a sections for debug logging. If we have enabled debug logging we don't want to display any password in the log. // These properties may contain autoactivation PIN codes and we will, only when debug logging, replace this with "hidden". if (properties.containsKey(ICAToken.AUTOACTIVATE_PIN_PROPERTY) || properties.containsKey("PIN")) { Properties prop = new Properties(); prop.putAll(properties); if (properties.containsKey(ICAToken.AUTOACTIVATE_PIN_PROPERTY)) { prop.setProperty(ICAToken.AUTOACTIVATE_PIN_PROPERTY, "hidden"); } if (properties.containsKey("PIN")) { prop.setProperty("PIN", "hidden"); } log.debug("Prop: " + (prop != null ? prop.toString() : "null")); } else { // If no autoactivation PIN codes exists we can debug log everything as original. log.debug("Properties: " + (properties != null ? properties.toString() : "null")); } } // if (log.isDebugEnabled()) this.keyStrings = new KeyStrings(properties); this.mAuthCode = BaseCAToken.getAutoActivatePin(properties); }
From source file:org.apache.usergrid.corepersistence.GuiceFactory.java
@Override public Injector getObject() throws Exception { if (this.injector != null) { return injector; }/*from w w w. ja v a 2 s . c o m*/ try { logger.info("Loading Core Persistence properties"); String hostsString = ""; CassandraHost[] hosts = chc.buildCassandraHosts(); if (hosts.length == 0) { throw new RuntimeException("Fatal error: no Cassandra hosts configured"); } for (CassandraHost host : hosts) { if (StringUtils.isEmpty(host.getHost())) { throw new RuntimeException("Fatal error: Cassandra hostname cannot be empty"); } hostsString += host.getHost() + ","; } hostsString = hostsString.substring(0, hostsString.length() - 1); logger.info("hostsString: {}", hostsString); Properties cpProps = new Properties(); // Some Usergrid properties must be mapped to Core Persistence properties cpProps.put("cassandra.hosts", hostsString); cpProps.put("cassandra.port", hosts[0].getPort()); cpProps.put("cassandra.cluster_name", getAndValidateProperty("cassandra.cluster")); cpProps.put("collections.keyspace.strategy.class", getAndValidateProperty("cassandra.keyspace.strategy")); cpProps.put("collections.keyspace.strategy.options", getAndValidateProperty("cassandra.keyspace.replication")); if (logger.isDebugEnabled()) { logger.debug("Set Cassandra properties for Core Persistence: {}", cpProps.toString()); } // Load the properties into the new CP Props Map by calling getProperty as the methods may be overridden for (Object propKey : systemProperties.keySet()) { cpProps.setProperty((String) propKey, systemProperties.getProperty((String) propKey)); } //logger.debug("All properties fed to Core Persistence: " + cpProps.toString() ); ConfigurationManager.loadProperties(cpProps); } catch (Exception e) { throw new RuntimeException("Fatal error loading configuration.", e); } List<Module> moduleList = new ArrayList<>(); if (applicationContext.containsBean("serviceModule")) { Module serviceModule = (Module) applicationContext.getBean("serviceModule"); moduleList.add(serviceModule); } moduleList.add(new CoreModule()); moduleList.add(new PersistenceModule(applicationContext)); //we have to inject a couple of spring beans into our Guice. Wire it with PersistenceModule injector = Guice.createInjector(moduleList); return injector; }