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:ch.cyberduck.core.sds.SDSMissingFileKeysSchedulerFeatureTest.java

@Test
public void testMissingKeys() throws Exception {
    final Host host = new Host(new SDSProtocol(), "duck.ssp-europe.eu", new Credentials(
            System.getProperties().getProperty("sds.user"), System.getProperties().getProperty("sds.key")));
    final SDSSession session = new SDSSession(host, new DisabledX509TrustManager(),
            new DefaultX509KeyManager());
    session.open(new DisabledHostKeyCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path room = new Path("CD-TEST-ENCRYPTED",
            EnumSet.of(Path.Type.directory, Path.Type.volume, Path.Type.vault));
    final byte[] content = RandomUtils.nextBytes(32769);
    final TransferStatus status = new TransferStatus();
    status.setLength(content.length);/*from w  ww  .  j a  v a2 s  .  co m*/
    final Path test = new Path(room, UUID.randomUUID().toString(),
            EnumSet.of(Path.Type.file, Path.Type.decrypted));
    final SDSEncryptionBulkFeature bulk = new SDSEncryptionBulkFeature(session);
    bulk.pre(Transfer.Type.upload, Collections.singletonMap(test, status), new DisabledConnectionCallback());
    final CryptoWriteFeature writer = new CryptoWriteFeature(session, new SDSWriteFeature(session));
    final StatusOutputStream<VersionId> out = writer.write(test, status, new DisabledConnectionCallback());
    assertNotNull(out);
    new StreamCopier(status, status).transfer(new ByteArrayInputStream(content), out);
    final VersionId version = out.getStatus();
    assertNotNull(version);
    assertTrue(new DefaultFindFeature(session).find(test));
    assertEquals(content.length, new SDSAttributesFinderFeature(session).find(test).getSize());
    final SDSMissingFileKeysSchedulerFeature background = new SDSMissingFileKeysSchedulerFeature(session);
    final List<UserFileKeySetRequest> processed = background.operate(new PasswordCallback() {
        @Override
        public Credentials prompt(final Host bookmark, final String title, final String reason,
                final LoginOptions options) throws LoginCanceledException {
            return new VaultCredentials("ahbic3Ae");
        }
    }, test);
    assertFalse(processed.isEmpty());
    boolean found = false;
    for (UserFileKeySetRequest p : processed) {
        if (p.getFileId().equals(Long.parseLong(version.id))) {
            found = true;
            break;
        }
    }
    assertTrue(found);
    new SDSDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(),
            new Delete.DisabledCallback());
    session.close();
}

From source file:ch.cyberduck.core.shared.DefaultDownloadFeatureTest.java

@Test
public void testTransferAppend() 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 Path test = new Path(new SFTPHomeDirectoryService(session).find(), UUID.randomUUID().toString(),
            EnumSet.of(Path.Type.file));
    session.getFeature(Touch.class).touch(test, new TransferStatus());
    final byte[] content = new byte[39864];
    new Random().nextBytes(content);
    {//w  w  w . j  a  va2s . co  m
        final TransferStatus status = new TransferStatus().length(content.length);
        final OutputStream out = new SFTPWriteFeature(session).write(test, status,
                new DisabledConnectionCallback());
        assertNotNull(out);
        new StreamCopier(status, status).withLimit(new Long(content.length))
                .transfer(new ByteArrayInputStream(content), out);
        out.close();
    }
    final Local local = new Local(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString());
    {
        final TransferStatus status = new TransferStatus().length(content.length / 2);
        new DefaultDownloadFeature(new SFTPReadFeature(session)).download(test, local,
                new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener(), status,
                new DisabledConnectionCallback(), new DisabledPasswordCallback());
    }
    {
        final TransferStatus status = new TransferStatus().length(content.length / 2).skip(content.length / 2)
                .append(true);
        new DefaultDownloadFeature(new SFTPReadFeature(session)).download(test, local,
                new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener(), status,
                new DisabledConnectionCallback(), new DisabledPasswordCallback());
    }
    final byte[] buffer = new byte[content.length];
    final InputStream in = local.getInputStream();
    IOUtils.readFully(in, buffer);
    in.close();
    assertArrayEquals(content, buffer);
    final Delete delete = session.getFeature(Delete.class);
    delete.delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
    session.close();
}

From source file:com.redhat.rhn.common.messaging.SmtpMail.java

/**
 * Create a mailer.// w ww .  jav a2s  .co  m
 */
public SmtpMail() {
    log.debug("Constructed new SmtpMail.");

    disallowedDomains = Config.get().getStringArray("web.disallowed_mail_domains");
    restrictedDomains = Config.get().getStringArray("web.restrict_mail_domains");

    Config c = Config.get();
    smtpHost = c.getString(ConfigDefaults.WEB_SMTP_SERVER, "localhost");
    String from = c.getString(ConfigDefaults.WEB_DEFAULT_MAIL_FROM);

    // Get system properties
    Properties props = System.getProperties();

    // Setup mail server
    props.put("mail.smtp.host", smtpHost);

    // Get session
    Session session = Session.getDefaultInstance(props, null);
    try {
        message = new MimeMessage(session);
        message.setFrom(new InternetAddress(from));
    } catch (AddressException me) {
        String msg = "Malformed address in traceback configuration: " + from;
        log.warn(msg);
        throw new JavaMailException(msg, me);
    } catch (MessagingException me) {
        String msg = "MessagingException while trying to send email: " + me.toString();
        log.warn(msg);
        throw new JavaMailException(msg, me);
    }
}

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

@Test
public void testTouchLongFilenameEncrypted() throws Exception {
    final Host host = new Host(new AzureProtocol(), "kahy9boj3eib.blob.core.windows.net",
            new Credentials(System.getProperties().getProperty("azure.account"),
                    System.getProperties().getProperty("azure.key")));
    final AzureSession session = new AzureSession(host);
    session.open(new DisabledHostKeyCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path home = new Path("cyberduck", EnumSet.of(Path.Type.volume, Path.Type.directory));
    final CryptoVault cryptomator = new CryptoVault(
            new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)),
            new DisabledPasswordStore());
    final Path vault = cryptomator.create(session, null, new VaultCredentials("test"));
    session.withRegistry(/*from  w w w  .  jav a 2s  .  c om*/
            new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator));
    final Path test = new Path(vault, new RandomStringGenerator.Builder().build().generate(130),
            EnumSet.of(Path.Type.file));
    new CryptoTouchFeature<Void>(session, new AzureTouchFeature(session, null),
            new AzureWriteFeature(session, null), cryptomator).touch(test, new TransferStatus());
    assertTrue(new CryptoFindFeature(session, new AzureFindFeature(session, null), cryptomator).find(test));
    new CryptoDeleteFeature(session, new AzureDeleteFeature(session, null), cryptomator)
            .delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
    session.close();
}

From source file:io.apiman.test.integration.runner.PolicyLoader.java

private void storeBean(String definitionId, String config, List<NewPolicyBean> policies) {
    config = StrSubstitutor.replace(config, System.getProperties());
    config = StrSubstitutor.replace(config, SuiteProperties.getProperties());
    config = StrSubstitutor.replace(config, params);

    NewPolicyBean bean = new NewPolicyBean();
    bean.setDefinitionId(definitionId);//from  w  w  w.  java  2  s  .co m
    bean.setConfiguration(config);

    policies.add(bean);
}

From source file:com.egt.ejb.toolkit.ToolKitUtils.java

public static String mkLibSrcDir(String root, String project, String subproject) {
    String sep = System.getProperties().getProperty("file.separator");
    String com = PREFIJO_PAQUETE.replace(".", sep);
    String lib = getLibPackageName(project).replace(".", sep);
    String sub = StringUtils.isBlank(subproject) ? "" : sep + subproject.replace("-", sep).replace(".", sep);
    String dir = StringUtils.chomp(root, sep) + sep + project + sep + "src" + sep + com + sep + lib + sub;
    mkdirs(dir);/* www .j a  v a2 s  . c  om*/
    return dir + sep;
}

From source file:com.amazonaws.services.logs.connectors.samples.AbstractConnectorExecutor.java

/**
 * Creates a new CloudWatchLogsSubscriptionsExecutor.
 *
 * @param configFile The name of the configuration file to look for on the classpath.
 *///from  w  w  w.  j  a  v a 2s  . com
public AbstractConnectorExecutor(String configFile) {
    InputStream configFileInputStream = Thread.currentThread().getContextClassLoader()
            .getResourceAsStream(configFile);

    if (configFileInputStream == null) {
        String msg = "Could not find resource " + configFile + " in the classpath";
        LOG.error(msg);
        throw new IllegalStateException(msg);
    }

    Properties propertiesFile = new Properties();
    Properties mergedProperties = new Properties();
    try {
        propertiesFile.load(configFileInputStream);

        mergedProperties.putAll(propertiesFile);
        mergedProperties.putAll(System.getProperties());

        configFileInputStream.close();

        this.config = new KinesisConnectorConfiguration(mergedProperties,
                new DefaultAWSCredentialsProviderChain());
    } catch (IOException e) {
        String msg = "Could not load properties file " + configFile + " from classpath";
        LOG.error(msg, e);
        throw new IllegalStateException(msg, e);
    }

    super.initialize(config, new NullMetricsFactory());
}

From source file:ch.cyberduck.core.sds.SDSDelegatingCopyFeatureTest.java

@Test
public void testCopyFileServerSide() throws Exception {
    final Host host = new Host(new SDSProtocol(), "duck.ssp-europe.eu", new Credentials(
            System.getProperties().getProperty("sds.user"), System.getProperties().getProperty("sds.key")));
    final SDSSession session = new SDSSession(host, new DisabledX509TrustManager(),
            new DefaultX509KeyManager());
    session.open(new DisabledHostKeyCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path room = new SDSDirectoryFeature(session)
            .mkdir(new Path(new AlphanumericRandomStringService().random(),
                    EnumSet.of(Path.Type.directory, Path.Type.volume)), null, new TransferStatus());
    final Path test = new SDSTouchFeature(session).touch(
            new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)),
            new TransferStatus());
    final Path copy = new Path(new SDSDirectoryFeature(session).mkdir(
            new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)),
            null, new TransferStatus()), test.getName(), EnumSet.of(Path.Type.file));
    new SDSTouchFeature(session).touch(copy, new TransferStatus());
    final SDSCopyFeature feature = new SDSCopyFeature(session);
    assertTrue(feature.isSupported(test, copy));
    new SDSDelegatingCopyFeature(session, feature).copy(test, copy, new TransferStatus(),
            new DisabledConnectionCallback());
    assertTrue(new SDSFindFeature(session).find(test));
    assertTrue(new SDSFindFeature(session).find(copy));
    new SDSDeleteFeature(session).delete(Collections.singletonList(room), new DisabledLoginCallback(),
            new Delete.DisabledCallback());
    session.close();/* ww  w.  j  a v  a  2  s .co  m*/
}

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

@Test
public void testTouchEncrypted() throws Exception {
    final Host host = new Host(new S3Protocol(), new S3Protocol().getDefaultHostname(), new Credentials(
            System.getProperties().getProperty("s3.key"), System.getProperties().getProperty("s3.secret")));
    final S3Session session = new S3Session(host);
    session.open(new DisabledHostKeyCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path home = new Path("test-us-east-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
    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  av a  2 s. c  o  m
            new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator));
    new CryptoTouchFeature<StorageObject>(session, new S3TouchFeature(session), new S3WriteFeature(session),
            cryptomator).touch(test, new TransferStatus());
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(test));
    new CryptoDeleteFeature(session, new S3DefaultDeleteFeature(session), cryptomator)
            .delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
    session.close();
}

From source file:io.symcpe.hendrix.api.dao.TestTemplateManager.java

@BeforeClass
public static void beforeClass() throws Exception {
    Properties config = new Properties(System.getProperties());
    File db = new File(TARGET_RULES_DB);
    if (db.exists()) {
        FileUtils.deleteDirectory(db);//  w w  w  . j a v a 2  s.  c om
    }
    config.setProperty("javax.persistence.jdbc.url", CONNECTION_STRING);
    try {
        emf = Persistence.createEntityManagerFactory("hendrix", config);
    } catch (Exception e) {
        e.printStackTrace();
        throw e;
    }

    EntityManager em = emf.createEntityManager();

    Tenant tenant = new Tenant();
    tenant.setTenant_id(TENANT_ID_1);
    tenant.setTenant_name(TEST_TENANT);
    TenantManager.getInstance().createTenant(em, tenant);

    em.close();
}