Example usage for java.lang System getProperties

List of usage examples for java.lang System getProperties

Introduction

In this page you can find the example usage for java.lang System getProperties.

Prototype

public static Properties getProperties() 

Source Link

Document

Determines the current system properties.

Usage

From source file:org.ambraproject.service.XMLServiceImpl.java

/**
 * Initialization method called by Spring.
 *
 * @throws org.ambraproject.ApplicationException On Template creation Exceptions.
 *//*from  ww w  . j  a va2 s  . c om*/
public void init() throws ApplicationException {
    // set JAXP properties
    System.getProperties().putAll(xmlFactoryProperty);

    // Create a document builder factory and set the defaults
    factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);
    factory.setValidating(false);

    // set the Templates
    final TransformerFactory tFactory = TransformerFactory.newInstance();

    try {
        translet = tFactory.newTemplates(new StreamSource(xslDefaultTemplate));
    } catch (TransformerConfigurationException tce) {
        throw new ApplicationException(tce);
    }
}

From source file:com.norconex.jef4.mail.SimpleMailer.java

/**
 * Constructor.//  w w w  .ja v a  2s  . c  om
 * @param host mail server host
 * @param sender email address of sender ("From" field)
 * @param recipients email address of recipients ("To" field)
 * @param contentType content type of the email message
 */
public SimpleMailer(final String host, final String sender, final String[] recipients,
        final String contentType) {
    super();
    this.sender = sender;
    this.emailRecipients = ArrayUtils.clone(recipients);

    Properties sysProps = System.getProperties();
    if (sysProps == null) {
        sysProps = new Properties();
    }
    this.props = sysProps;
    this.props.put("mail.smtp.host", host);
    this.contentType = contentType;
}

From source file:org.duracloud.mill.workman.spring.AppDriver.java

@Override
protected void executeImpl(CommandLine cmd) {

    String taskQueueNames = cmd.getOptionValue(TASK_QUEUES_OPTION);
    if (taskQueueNames != null) {
        setSystemProperty(ConfigConstants.QUEUE_TASK_ORDERED, taskQueueNames);
    }/* w  ww  .  j ava2s.  com*/

    List<PropertyDefinition> defintions = new PropertyDefinitionListBuilder().addAws().addMillDb().addMcDb()
            .addDeadLetterQueue().addAuditQueue().addBitIntegrityQueue().addBitIntegrityErrorQueue()
            .addNotificationRecipients().addWorkDir().addTaskQueueOrder().addDuplicationPolicyBucketSuffix()
            .addDuplicationPolicyRefreshFrequency().addDuplicationHighPriorityQueue().addLocalDuplicationDir()
            .addMaxWorkers().build();
    PropertyVerifier verifier = new PropertyVerifier(defintions);
    verifier.verify(System.getProperties());

    WorkmanConfigurationManager config = new WorkmanConfigurationManager();

    String workDirPath = config.getWorkDirectoryPath();

    if (workDirPath == null || workDirPath.trim() == "") {
        // this should never happen since workDirPath is required,
        // but I'll leave this in here as a sanity check.
        workDirPath = System.getProperty("java.io.tmpdir") + File.separator + "workman-work";
    }

    initializeWorkDir(workDirPath);

    String localDuplicationPolicyDirPath = config.getDuplicationPolicyDir();

    if (localDuplicationPolicyDirPath != null && !new File(localDuplicationPolicyDirPath).exists()) {
        System.err.print("The local duplication policy directory " + "path you specified, "
                + localDuplicationPolicyDirPath + " does not exist: ");
        die();
    }

    ApplicationContext context = new AnnotationConfigApplicationContext("org.duracloud.mill");
}

From source file:ch.cyberduck.core.cryptomator.SFTPWriteFeatureTest.java

@Test
public void testWrite() throws Exception {
    final Host host = new Host(new SFTPProtocol(), "test.cyberduck.ch",
            new Credentials(System.getProperties().getProperty("sftp.user"),
                    System.getProperties().getProperty("sftp.password")));
    final SFTPSession session = new SFTPSession(host);
    session.open(new DisabledHostKeyCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final TransferStatus status = new TransferStatus();
    final int length = 1048576;
    final byte[] content = RandomUtils.nextBytes(length);
    status.setLength(content.length);//from   w w  w  . j a v a 2 s . c o  m
    final Path home = new SFTPHomeDirectoryService(session).find();
    final Path vault = new Path(home, new AlphanumericRandomStringService().random(),
            EnumSet.of(Path.Type.directory));
    final Path test = new Path(vault, new AlphanumericRandomStringService().random(),
            EnumSet.of(Path.Type.file));
    final CryptoVault cryptomator = new CryptoVault(vault, new DisabledPasswordStore());
    cryptomator.create(session, null, new VaultCredentials("test"));
    session.withRegistry(
            new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator));
    final CryptoWriteFeature<Void> writer = new CryptoWriteFeature<>(session, new SFTPWriteFeature(session),
            cryptomator);
    final Cryptor cryptor = cryptomator.getCryptor();
    final FileHeader header = cryptor.fileHeaderCryptor().create();
    status.setHeader(cryptor.fileHeaderCryptor().encryptHeader(header));
    status.setNonces(new RandomNonceGenerator());
    status.setChecksum(writer.checksum(test).compute(new ByteArrayInputStream(content), status));
    final OutputStream out = writer.write(test, status, new DisabledConnectionCallback());
    assertNotNull(out);
    new StreamCopier(status, status).transfer(new ByteArrayInputStream(content), out);
    out.close();
    assertTrue(new CryptoFindFeature(session, new SFTPFindFeature(session), cryptomator).find(test));
    Assert.assertEquals(content.length, new CryptoListService(session, session, cryptomator)
            .list(test.getParent(), new DisabledListProgressListener()).get(test).attributes().getSize());
    Assert.assertEquals(content.length, writer.append(test, status.getLength(), PathCache.empty()).size, 0L);
    final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length);
    final InputStream in = new CryptoReadFeature(session, new SFTPReadFeature(session), cryptomator).read(test,
            new TransferStatus().length(content.length), new DisabledConnectionCallback());
    new StreamCopier(status, status).transfer(in, buffer);
    assertArrayEquals(content, buffer.toByteArray());
    new CryptoDeleteFeature(session, new SFTPDeleteFeature(session), cryptomator)
            .delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
    session.close();
}

From source file:ch.cyberduck.core.s3.S3SingleUploadServiceTest.java

@Test
public void testUpload() throws Exception {
    final S3Session session = new S3Session(new Host(new S3Protocol(), new S3Protocol().getDefaultHostname(),
            new Credentials(System.getProperties().getProperty("s3.key"),
                    System.getProperties().getProperty("s3.secret"))));
    session.open(new DisabledHostKeyCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final S3SingleUploadService service = new S3SingleUploadService(session,
            new S3WriteFeature(session, new S3DisabledMultipartService()));
    final Path container = new Path("test-us-east-1-cyberduck",
            EnumSet.of(Path.Type.directory, Path.Type.volume));
    final String name = UUID.randomUUID().toString() + ".txt";
    final Path test = new Path(container, name, EnumSet.of(Path.Type.file));
    final Local local = new Local(System.getProperty("java.io.tmpdir"), name);
    final String random = new RandomStringGenerator.Builder().build().generate(1000);
    final OutputStream out = local.getOutputStream(false);
    IOUtils.write(random, out, Charset.defaultCharset());
    out.close();/*w w  w .j  a va  2s . co m*/
    final TransferStatus status = new TransferStatus();
    status.setLength(random.getBytes().length);
    status.setMime("text/plain");
    service.upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED),
            new DisabledStreamListener(), status, new DisabledLoginCallback());
    assertTrue(new S3FindFeature(session).find(test));
    final PathAttributes attributes = new S3AttributesFinderFeature(session).find(test);
    assertEquals(random.getBytes().length, attributes.getSize());
    final Map<String, String> metadata = new S3MetadataFeature(session, new S3AccessControlListFeature(session))
            .getMetadata(test);
    assertFalse(metadata.isEmpty());
    assertEquals("text/plain", metadata.get("Content-Type"));
    new S3DefaultDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(),
            new Delete.DisabledCallback());
    local.delete();
    session.close();
}

From source file:ch.cyberduck.core.cryptomator.SFTPReadFeatureTest.java

@Test
public void testReadRange() throws Exception {
    final Host host = new Host(new SFTPProtocol(), "test.cyberduck.ch",
            new Credentials(System.getProperties().getProperty("sftp.user"),
                    System.getProperties().getProperty("sftp.password")));
    final SFTPSession session = new SFTPSession(host);
    session.open(new DisabledHostKeyCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final TransferStatus status = new TransferStatus();
    final int length = 140000;
    final byte[] content = RandomUtils.nextBytes(length);
    status.setLength(content.length);//from w ww  . j ava  2  s .  c o m
    final Path home = new SFTPHomeDirectoryService(session).find();
    final Path vault = new Path(home, new AlphanumericRandomStringService().random(),
            EnumSet.of(Path.Type.directory));
    final Path test = new Path(vault, new AlphanumericRandomStringService().random(),
            EnumSet.of(Path.Type.file));
    final CryptoVault cryptomator = new CryptoVault(vault, new DisabledPasswordStore());
    cryptomator.create(session, null, new VaultCredentials("test"));
    session.withRegistry(
            new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator));
    final CryptoWriteFeature<Void> writer = new CryptoWriteFeature<>(session, new SFTPWriteFeature(session),
            cryptomator);
    final Cryptor cryptor = cryptomator.getCryptor();
    final FileHeader header = cryptor.fileHeaderCryptor().create();
    status.setHeader(cryptor.fileHeaderCryptor().encryptHeader(header));
    status.setNonces(new RandomNonceGenerator());
    status.setChecksum(writer.checksum(test).compute(new ByteArrayInputStream(content), status));
    final OutputStream out = writer.write(test, status, new DisabledConnectionCallback());
    assertNotNull(out);
    new StreamCopier(status, status).transfer(new ByteArrayInputStream(content), out);
    out.close();
    assertTrue(new CryptoFindFeature(session, new SFTPFindFeature(session), cryptomator).find(test));
    Assert.assertEquals(content.length, new CryptoListService(session, session, cryptomator)
            .list(test.getParent(), new DisabledListProgressListener()).get(test).attributes().getSize());
    Assert.assertEquals(content.length, writer.append(test, status.getLength(), PathCache.empty()).size, 0L);
    final ByteArrayOutputStream buffer = new ByteArrayOutputStream(30000);
    final TransferStatus read = new TransferStatus();
    read.setOffset(40000);
    read.setAppend(true);
    read.length(30000); // ensure to read at least two chunks
    final InputStream in = new CryptoReadFeature(session, new SFTPReadFeature(session), cryptomator).read(test,
            read, new DisabledConnectionCallback());
    new StreamCopier(read, read).withLimit(30000L).transfer(in, buffer);
    final byte[] reference = new byte[30000];
    System.arraycopy(content, 40000, reference, 0, reference.length);
    assertArrayEquals(reference, buffer.toByteArray());
    new CryptoDeleteFeature(session, new SFTPDeleteFeature(session), cryptomator)
            .delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
    session.close();
}

From source file:ch.cyberduck.core.cryptomator.SwiftLargeUploadWriteFeatureTest.java

@Test
public void testWrite() throws Exception {
    final Host host = new Host(new SwiftProtocol(), "identity.api.rackspacecloud.com",
            new Credentials(System.getProperties().getProperty("rackspace.key"),
                    System.getProperties().getProperty("rackspace.secret")));
    final SwiftSession session = new SwiftSession(host);
    session.open(new DisabledHostKeyCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path home = new Path("test.cyberduck.ch", EnumSet.of(Path.Type.volume, Path.Type.directory));
    home.attributes().setRegion("DFW");
    final Path vault = new Path(home, new AlphanumericRandomStringService().random(),
            EnumSet.of(Path.Type.directory));
    final Path test = new Path(vault, new AlphanumericRandomStringService().random(),
            EnumSet.of(Path.Type.file));
    final CryptoVault cryptomator = new CryptoVault(vault, new DisabledPasswordStore());
    cryptomator.create(session, null, new VaultCredentials("test"));
    session.withRegistry(//from   w w  w.  j a v a2  s  .c  o  m
            new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator));
    final SwiftRegionService regionService = new SwiftRegionService(session);
    final CryptoWriteFeature feature = new CryptoWriteFeature<List<StorageObject>>(session,
            new SwiftLargeUploadWriteFeature(session, regionService,
                    new SwiftSegmentService(session, ".segments-test/")),
            cryptomator);
    final TransferStatus writeStatus = new TransferStatus();
    final Cryptor cryptor = cryptomator.getCryptor();
    final FileHeader header = cryptor.fileHeaderCryptor().create();
    writeStatus.setHeader(cryptor.fileHeaderCryptor().encryptHeader(header));
    writeStatus.setNonces(new RandomNonceGenerator());
    writeStatus.setLength(-1L);
    final OutputStream out = feature.write(test, writeStatus, new DisabledConnectionCallback());
    final byte[] content = RandomUtils.nextBytes(6 * 1024 * 1024);
    final ByteArrayInputStream in = new ByteArrayInputStream(content);
    final TransferStatus progress = new TransferStatus();
    new StreamCopier(new TransferStatus(), progress).transfer(in, out);
    assertEquals(content.length, progress.getOffset());
    assertTrue(new CryptoFindFeature(session, new SwiftFindFeature(session), cryptomator).find(test));
    final byte[] compare = new byte[content.length];
    final InputStream stream = new CryptoReadFeature(session, new SwiftReadFeature(session, regionService),
            cryptomator).read(test, new TransferStatus().length(content.length),
                    new DisabledConnectionCallback());
    IOUtils.readFully(stream, compare);
    stream.close();
    assertArrayEquals(content, compare);
    new CryptoDeleteFeature(session, new SwiftDeleteFeature(session), cryptomator)
            .delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
    session.close();
}

From source file:io.vertx.stack.model.Stack.java

/**
 * Apply filtering on the set of dependencies.
 *//*from w  w w.  j  ava  2  s  . co  m*/
public void applyFiltering() {
    // Compute the final set of properties.
    // First the properties, Then the system properties, so you can override a value using -D.
    Map<String, String> properties = new LinkedHashMap<>();
    properties.putAll(variables);
    properties.putAll((Map) System.getProperties());

    dependencies.stream().forEach(dependency -> {
        dependency.setGroupId(Filtering.filter(dependency.getGroupId(), properties));
        dependency.setArtifactId(Filtering.filter(dependency.getArtifactId(), properties));
        dependency.setVersion(Filtering.filter(dependency.getVersion(), properties));
        dependency.setClassifier(Filtering.filter(dependency.getClassifier(), properties));
        dependency.setType(Filtering.filter(dependency.getType(), properties));
    });
}

From source file:adalid.jaas.google.GoogleRecaptcha.java

private static String secretKey() {
    logger.log(Level.INFO, VALIDATOR_KEY + " = {0}", GoogleRecaptcha.class.getName());
    String secretKey = System.getProperties().getProperty(SECRET_KEY_PROPERTY_KEY);
    if (secretKey == null || secretKey.isEmpty()) {
        String path = secretKeyFilePath();
        File file = new File(path);
        if (file.isFile()) {
            logger.log(TRACE, SECRET_KEY_FILE_PROPERTY_KEY + " = {0}", path);
            try {
                secretKey = new Scanner(file).useDelimiter("\\Z").next();
            } catch (FileNotFoundException ex) {
                logger.log(Level.WARNING, SECRET_KEY_FILE_PROPERTY_KEY + " {0} is missing", path);
            }//  w ww  .  j  av a 2  s .  co  m
        } else {
            logger.log(Level.WARNING, SECRET_KEY_FILE_PROPERTY_KEY + " {0} is missing or invalid", path);
        }
    }
    if (secretKey == null || secretKey.isEmpty()) {
        logger.log(Level.WARNING, MISSING_SECRET_KEY);
        return DEFAULT_SECRET_KEY;
    }
    return secretKey;
}

From source file:com.qmetry.qaf.automation.util.PropertyUtil.java

public PropertyUtil() {
    super();/*from   ww  w .j a v  a 2 s  .c o m*/
    setLogger(logger);
    Iterator<Entry<Object, Object>> iterator = System.getProperties().entrySet().iterator();

    while (iterator.hasNext()) {
        Entry<Object, Object> entry = iterator.next();

        String skey = String.valueOf(entry.getKey());
        String sval = String.valueOf(entry.getValue());
        if (!StringMatcher.like("^(sun\\.|java\\.).*").match(skey)) {
            Object[] vals = sval != null && sval.indexOf(getListDelimiter()) >= 0
                    ? sval.split(getListDelimiter() + "")
                    : new Object[] { sval };
            for (Object val : vals) {
                super.addPropertyDirect(skey, val);
            }

        }
    }

}