Example usage for java.util Properties setProperty

List of usage examples for java.util Properties setProperty

Introduction

In this page you can find the example usage for java.util Properties setProperty.

Prototype

public synchronized Object setProperty(String key, String value) 

Source Link

Document

Calls the Hashtable method put .

Usage

From source file:com.sap.prd.mobile.ios.mios.CleanMojoTest.java

@BeforeClass
public static void __setup() throws Exception {
    dynamicVersion = "1.0." + String.valueOf(System.currentTimeMillis());
    testName = CleanMojoTest.class.getName() + File.separator
            + Thread.currentThread().getStackTrace()[1].getMethodName();

    remoteRepositoryDirectory = getRemoteRepositoryDirectory(CleanMojoTest.class.getName());

    prepareRemoteRepository(remoteRepositoryDirectory);

    Properties pomReplacements = new Properties();
    pomReplacements.setProperty(PROP_NAME_DEPLOY_REPO_DIR, remoteRepositoryDirectory.getAbsolutePath());
    pomReplacements.setProperty(PROP_NAME_DYNAMIC_VERSION, dynamicVersion);

    Map<String, String> additionalSystemProperties = new HashMap<String, String>();
    testOneArchiveDirectoryForAll = getTestExecutionDirectory(testName, "moduleBuild/target/artifactRedirect");
    additionalSystemProperties.put("archive.dir", testOneArchiveDirectoryForAll.getAbsolutePath());
    additionalSystemProperties.put("mios.ota-service.url",
            "http://apple-ota.wdf.sap.corp:8080/ota-service/HTML");

    test(new XCodeTestParameters(null, testName, new File(getTestRootDirectory(), "moduleBuild"),
            asList("clean", "deploy"), THE_EMPTY_LIST, additionalSystemProperties,
            propertiesToStringMap(pomReplacements), new NullProjectModifier()));
}

From source file:com.esofthead.mycollab.servlet.InstallUtils.java

public static void checkSMTPConfig(String host, int port, String username, String password, boolean auth,
        boolean isStartTls, boolean isSSL) {
    try {/*from  w  ww .j  a  v a2  s.  c  om*/
        Properties props = new Properties();
        if (auth) {
            props.setProperty("mail.smtp.auth", "true");
        } else {
            props.setProperty("mail.smtp.auth", "false");
        }
        if (isStartTls) {
            props.setProperty("mail.smtp.starttls.enable", "true");
            props.setProperty("mail.smtp.startssl.enable", "true");
        } else if (isSSL) {
            props.setProperty("mail.smtp.startssl.enable", "false");
            props.setProperty("mail.smtp.ssl.enable", "true");
            props.setProperty("mail.smtp.ssl.socketFactory.fallback", "false");

        }

        Email email = new SimpleEmail();
        email.setHostName(host);
        email.setSmtpPort(port);
        email.setAuthenticator(new DefaultAuthenticator(username, password));
        if (isStartTls) {
            email.setStartTLSEnabled(true);
        } else {
            email.setStartTLSEnabled(false);
        }

        if (isSSL) {
            email.setSSLOnConnect(true);
        } else {
            email.setSSLOnConnect(false);
        }
        email.setFrom(username);
        email.setSubject("MyCollab Test Email");
        email.setMsg("This is a test mail ... :-)");
        email.addTo(username);
        email.send();
    } catch (Exception e) {
        throw new UserInvalidInputException(e);
    }
}

From source file:io.anserini.index.IndexGov2.java

private static TrecContentSource createGov2Source(String dataDir) {
    TrecContentSource tcs = new TrecContentSource();
    Properties props = new Properties();
    props.setProperty("print.props", "false");
    props.setProperty("content.source.verbose", "false");
    props.setProperty("content.source.excludeIteration", "true");
    props.setProperty("docs.dir", dataDir);
    props.setProperty("trec.doc.parser", "org.apache.lucene.benchmark.byTask.feeds.TrecGov2Parser");
    props.setProperty("content.source.forever", "false");
    tcs.setConfig(new Config(props));
    try {/*from  ww  w  .  java  2  s  .c  o m*/
        tcs.resetInputs();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return tcs;
}

From source file:com.floreantpos.license.FiveStarPOSLicenseGenerator.java

public static String generateLicense(Properties templateProperties, InputStream privateKeyInputStream,
        File licenseFile) throws FileNotFoundException, NoSuchAlgorithmException, InvalidKeySpecException,
        IOException, InvalidKeyException, SignatureException {

    PrivateKey privateKey = readPrivateKey(privateKeyInputStream);
    String encoded = templateProperties.toString();
    String signature = FiveStarPOSLicenseGenerator.sign(encoded.getBytes(), privateKey);

    OutputStream output = new FileOutputStream(licenseFile);
    Properties licenseProperties = new OrderedProperties();
    licenseProperties.putAll(templateProperties);
    licenseProperties.setProperty(License.SIGNATURE, signature);
    licenseProperties.store(output, "License file");
    output.close();//from w ww  . j a v  a2  s  .c o m

    return signature;
}

From source file:org.hyperic.hq.hqapi1.tools.AbstractCommand.java

private static void configureLogging(String level) {
    Properties props = new Properties();
    props.setProperty("log4j.rootLogger", level.toUpperCase() + ", R");
    props.setProperty("log4j.logger.httpclient.wire", level.toUpperCase());
    props.setProperty("log4j.logger.org.apache.commons.httpclient", level.toUpperCase());

    for (String[] PROPS : LOG_PROPS) {
        props.setProperty(PROPS[0], PROPS[1]);
    }//from   www .j  a v a  2s .  c o  m

    props.putAll(System.getProperties());
    PropertyConfigurator.configure(props);
}

From source file:com.sap.prd.mobile.ios.mios.AlternatePublicHeaderFolderPathTest.java

@BeforeClass
public static void __setup() throws Exception {

    dynamicVersion = "1.0." + String.valueOf(System.currentTimeMillis());
    testName = AlternatePublicHeaderFolderPathTest.class.getName() + File.separator
            + Thread.currentThread().getStackTrace()[1].getMethodName();

    remoteRepositoryDirectory = getRemoteRepositoryDirectory(
            AlternatePublicHeaderFolderPathTest.class.getName());

    prepareRemoteRepository(remoteRepositoryDirectory);

    Properties pomReplacements = new Properties();
    pomReplacements.setProperty(PROP_NAME_DEPLOY_REPO_DIR, remoteRepositoryDirectory.getAbsolutePath());
    pomReplacements.setProperty(PROP_NAME_DYNAMIC_VERSION, dynamicVersion);

    Map<String, String> additionalSystemProperties = new HashMap<String, String>();
    additionalSystemProperties.put("mios.ota-service.url",
            "http://apple-ota.wdf.sap.corp:8080/ota-service/HTML");
    additionalSystemProperties.put("xcode.app.defaultConfigurations", "Release");
    additionalSystemProperties.put("xcode.app.defaultSdks", "iphoneos");
    additionalSystemProperties.put("archive.dir", "archive");
    additionalSystemProperties.put("xcode.useSymbolicLinks", Boolean.TRUE.toString());

    test(testName, new File(getTestRootDirectory(), "straight-forward/MyLibrary"), "deploy", THE_EMPTY_LIST,
            THE_EMPTY_MAP, pomReplacements, new AbstractProjectModifier() {

                @Override/*w ww  . java  2  s  . co  m*/
                public void execute() throws Exception {
                    final File pom = new File(testExecutionDirectory, "pom.xml");

                    final Model model = getModel(pom);
                    Plugin plugin = model.getBuild().getPlugins().get(0);
                    Xpp3Dom configuration = (Xpp3Dom) plugin.getConfiguration();
                    Xpp3Dom alternatePublicHeaderFolderPath = new Xpp3Dom("alternatePublicHeaderFolderPath");
                    alternatePublicHeaderFolderPath.setValue("MyLibrary");
                    configuration.addChild(alternatePublicHeaderFolderPath);

                    persistModel(pom, model);
                }
            });
}

From source file:com.amazonaws.services.cognito.streams.connector.AmazonCognitoStreamsEnvironmentOptions.java

static void createRedshiftTable(Properties properties) {
    // Ensure our data table exists
    Properties loginProperties = new Properties();
    loginProperties.setProperty("user", getRedshiftUserName());
    loginProperties.setProperty("password", getRedshiftPassword());

    StringBuilder builder = new StringBuilder();
    builder.append("CREATE TABLE IF NOT EXISTS ")
            .append(properties.getProperty(KinesisConnectorConfiguration.PROP_REDSHIFT_DATA_TABLE)).append(" (")
            .append("identityPoolId varchar(128),").append("identityId varchar(128),")
            .append("datasetName varchar(128),").append("operation varchar(64),").append("key varchar(1024),")
            .append("value varchar(4096),").append("op varchar(64),").append("syncCount int,")
            .append("deviceLastModifiedDate timestamp,").append("lastModifiedDate timestamp").append(")");

    Connection conn = null;//from   www  . ja  va2 s  .  c o m
    try {
        conn = DriverManager.getConnection(getJDBCConnection(), loginProperties);

        Statement stmt = conn.createStatement();
        stmt.execute(builder.toString());
        stmt.close();
    } catch (SQLException e) {
        LOG.error("Failed to create table.", e);
    } finally {
        try {
            conn.close();
        } catch (SQLException e) {
            LOG.error("Failed close connection.", e);
        }
    }
}

From source file:fedora.server.utilities.ServerUtility.java

/**
 * Initializes logging to use Log4J and to send WARN messages to STDOUT for
 * command-line use.//from  w  w  w  .  j a  v a  2 s.  c  o m
 */
private static void initLogging() {
    // send all log4j output to STDOUT and configure levels
    Properties props = new Properties();
    props.setProperty("log4j.appender.STDOUT", "org.apache.log4j.ConsoleAppender");
    props.setProperty("log4j.appender.STDOUT.layout", "org.apache.log4j.PatternLayout");
    props.setProperty("log4j.appender.STDOUT.layout.ConversionPattern", "%p: %m%n");
    props.setProperty("log4j.rootLogger", "WARN, STDOUT");
    PropertyConfigurator.configure(props);

    // tell commons-logging to use Log4J
    final String pfx = "org.apache.commons.logging.";
    System.setProperty(pfx + "LogFactory", pfx + "impl.Log4jFactory");
    System.setProperty(pfx + "Log", pfx + "impl.Log4JLogger");
}

From source file:eu.eidas.node.ApplicationContextProvider.java

private static void resetParamsForProduction(Properties props) {
    //do not allow self signed certificates
    props.setProperty(SAMLEngineModuleI.SELF_SIGNED_PROPERTY, "true");
    //do check certificates validiy period
    props.setProperty(SAMLEngineModuleI.CHECK_VALIDITY_PERIOD_PROPERTY, "true");
    //activate metadata
    props.setProperty(EIDASValues.METADATA_ACTIVE.toString(), "true");

    props.setProperty(EIDASValues.METADATA_CHECK_SIGNATURE.toString(), "true");
    //enforce https for remote metadata
    NODEMetadataProcessor eidasMetadataProcessor = applicationContext.getBean(NODEMetadataProcessor.class);
    eidasMetadataProcessor.setRestrictHttp(true);

    //validate binding
    props.setProperty(EIDASParameters.VALIDATE_BINDING.toString(), "true");

    //enable content security settings
    ConfigurationSecurityBean securityBean = applicationContext.getBean(ConfigurationSecurityBean.class);
    securityBean.setIncludeHSTS(true);/* w  w  w. j ava2  s  .c  o  m*/
    securityBean.setIncludeMozillaDirectives(true);
    securityBean.setIncludeXContentTypeOptions(true);
    securityBean.setIncludeXFrameOptions(true);
    securityBean.setIsContentSecurityPolicyActive(true);

    //enforce citizen country the same as ServiceProxy country
    AUCONNECTORSAML auConnectorSaml = applicationContext.getBean(AUCONNECTORSAML.class);
    auConnectorSaml.setCheckCitizenCertificateServiceCertificate(true);

    //enforce reponse encryption
    props.setProperty(EIDASValues.RESPONSE_ENCRYPTION_MANDATORY.toString(), "true");
}

From source file:org.apache.solr.client.solrj.SolrSchemalessExampleTest.java

@BeforeClass
public static void beforeClass() throws Exception {
    File tempSolrHome = createTempDir().toFile();
    // Schemaless renames schema.xml -> schema.xml.bak, and creates + modifies conf/managed-schema,
    // which violates the test security manager's rules, which disallow writes outside the build dir,
    // so we copy the example/example-schemaless/solr/ directory to a new temp dir where writes are allowed.
    FileUtils.copyFileToDirectory(new File(ExternalPaths.SERVER_HOME, "solr.xml"), tempSolrHome);
    File collection1Dir = new File(tempSolrHome, "collection1");
    FileUtils.forceMkdir(collection1Dir);
    FileUtils.copyDirectoryToDirectory(new File(ExternalPaths.SCHEMALESS_CONFIGSET), collection1Dir);
    Properties props = new Properties();
    props.setProperty("name", "collection1");
    OutputStreamWriter writer = null;
    try {// w  w w .j a  va  2  s.  c o  m
        writer = new OutputStreamWriter(FileUtils.openOutputStream(new File(collection1Dir, "core.properties")),
                "UTF-8");
        props.store(writer, null);
    } finally {
        if (writer != null) {
            try {
                writer.close();
            } catch (Exception ignore) {
            }
        }
    }
    createJetty(tempSolrHome.getAbsolutePath());
}