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:com.qut.middleware.saml2.SAML2Test.java

public SAML2Test() throws Exception {
    this.path = "tests" + File.separator + "testdata" + File.separator;

    System.setProperty("file.encoding", "UTF-16");

    System.getProperties().list(System.out);

    this.keyResolver = new SAML2TestKeyResolver();
}

From source file:Interface.FoodDistributionWorkArea.FoodDistributionWorkArea.java

public void sendEmail(String emailID, Food food) {

    final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";
    // Get a Properties object
    Properties props = System.getProperties();
    props.setProperty("mail.smtp.host", "smtp.gmail.com");
    props.setProperty("mail.smtp.socketFactory.class", SSL_FACTORY);
    props.setProperty("mail.smtp.socketFactory.fallback", "false");
    props.setProperty("mail.smtp.port", "465");
    props.setProperty("mail.smtp.socketFactory.port", "465");
    props.put("mail.smtp.auth", "true");
    props.put("mail.debug", "true");
    props.put("mail.store.protocol", "pop3");
    props.put("mail.transport.protocol", "smtp");
    final String username = "kunal.deora@gmail.com";//
    final String password = "adrika46";
    String text = "Hi Sir/Mam, " + '\n'
            + "You have received rewards points for the food you have donated. Details are listed below: "
            + '\n' + "Food Name:  " + food.getFoodName() + '\n' + "Food ID :" + food.getFoodBarCode() + '\n'
            + "Food Reward Points " + food.getRewardPoints() + '\n'
            + "If you have any queries you can contact us on +133333333333" + '\n'
            + "Thank you for helping for the betterment of society. Every little bite counts :) " + '\n';
    try {/*from   ww w. j  a  v  a2s  .  c  o  m*/
        Session session = Session.getDefaultInstance(props, new javax.mail.Authenticator() {
            protected javax.mail.PasswordAuthentication getPasswordAuthentication() {
                return new javax.mail.PasswordAuthentication(username, password);
            }
        });

        // -- Create a new message --
        javax.mail.Message msg = new MimeMessage(session);

        // -- Set the FROM and TO fields --
        msg.setFrom(new InternetAddress("kunal.deora@gmail.com"));
        msg.setRecipients(javax.mail.Message.RecipientType.TO, InternetAddress.parse(emailID, false));
        msg.setSubject("Congratulations! You have received reward points !!!");
        msg.setText(text);
        msg.setSentDate(new Date());
        javax.mail.Transport.send(msg);
        System.out.println("Message sent.");
    } catch (javax.mail.MessagingException e) {
        System.out.println("Erreur d'envoi, cause: " + e);
    }

}

From source file:de.qucosa.servlet.MetsDisseminatorServlet.java

@Override
public void init() throws ServletException {
    super.init();

    startupProperties = new PropertyCollector().source(getServletContext()).source(System.getProperties())
            .collect();/*from ww w . j  av  a  2  s  .  c  o m*/

    final FedoraClientFactory fedoraClientFactory = attemptToCreateFedoraClientFactoryFrom(startupProperties);

    if (fedoraClientFactory == null) {
        // we need a client factory for startup connections
        log.warn("Fedora connection credentials not configured. No connection pooling possible.");
    } else {
        final GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();
        poolConfig.setMaxTotal(
                Integer.parseInt(startupProperties.getProperty(PROP_FEDORA_CONNECTIONPOOL_MAXSIZE, "20")));
        poolConfig.setMinIdle(5);
        poolConfig.setMinEvictableIdleTimeMillis(TimeUnit.MINUTES.toMillis(1));

        fedoraClientPool = new GenericObjectPool<>(fedoraClientFactory, poolConfig);

        log.info("Initialized Fedora connection pool.");
    }

    cacheManager = CacheManager.newInstance();
    cache = cacheManager.getCache("dscache");
}

From source file:ch.cyberduck.core.irods.IRODSWriteFeatureTest.java

@Test
public void testWriteConcurrent() throws Exception {
    final ProtocolFactory factory = new ProtocolFactory(
            new HashSet<>(Collections.singleton(new IRODSProtocol())));
    final Profile profile = new ProfilePlistReader(factory)
            .read(new Local("../profiles/iRODS (iPlant Collaborative).cyberduckprofile"));
    final Host host = new Host(profile, profile.getDefaultHostname(),
            new Credentials(System.getProperties().getProperty("irods.key"),
                    System.getProperties().getProperty("irods.secret")));

    final IRODSSession session1 = new IRODSSession(host);
    session1.open(new DisabledHostKeyCallback());
    session1.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());

    final IRODSSession session2 = new IRODSSession(host);
    session2.open(new DisabledHostKeyCallback());
    session2.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());

    final Path test1 = new Path(new IRODSHomeFinderService(session1).find(), UUID.randomUUID().toString(),
            EnumSet.of(Path.Type.file));
    final Path test2 = new Path(new IRODSHomeFinderService(session2).find(), UUID.randomUUID().toString(),
            EnumSet.of(Path.Type.file));

    final byte[] content = RandomUtils.nextBytes(68400);

    final OutputStream out1 = new IRODSWriteFeature(session1).write(test1,
            new TransferStatus().append(false).length(content.length), new DisabledConnectionCallback());
    final OutputStream out2 = new IRODSWriteFeature(session2).write(test2,
            new TransferStatus().append(false).length(content.length), new DisabledConnectionCallback());
    new StreamCopier(new TransferStatus(), new TransferStatus()).transfer(new ByteArrayInputStream(content),
            out2);/*from  w  w w.j a v a  2 s  .  c  o  m*/
    // Error code received from iRODS:-23000
    new StreamCopier(new TransferStatus(), new TransferStatus()).transfer(new ByteArrayInputStream(content),
            out1);

    {
        final InputStream in1 = session1.getFeature(Read.class).read(test1, new TransferStatus(),
                new DisabledConnectionCallback());
        final byte[] buffer1 = new byte[content.length];
        IOUtils.readFully(in1, buffer1);
        in1.close();
        assertArrayEquals(content, buffer1);
    }
    {
        final InputStream in2 = session2.getFeature(Read.class).read(test2, new TransferStatus(),
                new DisabledConnectionCallback());
        final byte[] buffer2 = new byte[content.length];
        IOUtils.readFully(in2, buffer2);
        in2.close();
        assertArrayEquals(content, buffer2);
    }
    session1.close();
    session2.close();
}

From source file:com.ms.commons.test.classloader.util.SimpleAntxLoader.java

public SimpleAntxLoader(File antxFile) {
    this.antxFile = antxFile;

    this.properties = new Properties();
    setProperties(this.properties, System.getProperties());
    this.otherProperties = new Properties();
    this.antxProperties = this.loadFromAntxFile();

    List<SvnFile> files = this.readHttpPropertiesFiles();

    if (files != null) {
        for (SvnFile file : files) {
            setProperties(this.otherProperties, this.readHttpProperties(file.svnUrl, file.file));
        }//from w w w .ja  v  a2  s . c  om
    }
    setProperties(this.properties, this.otherProperties);
    setProperties(this.properties, this.antxProperties);
}

From source file:at.beris.virtualfile.util.UrlUtils.java

/**
 * Set property so that URL class will find custom handlers
 *///w  w  w  .  java  2  s  . com
public static void registerProtocolURLStreamHandlers() {
    String propertyKey = "java.protocol.handler.pkgs";
    String propertyValue = System.getProperties().getProperty(propertyKey);
    if (StringUtils.isEmpty(propertyValue))
        propertyValue = "";
    else
        propertyValue += "|";
    propertyValue += at.beris.virtualfile.protocol.Protocol.class.getPackage().getName();
    System.getProperties().setProperty(propertyKey, propertyValue);
}

From source file:com.vmware.bdd.utils.CommonUtil.java

public static File getConfigurationFile(final String filename, final String typeName) {
    // try to locate file directly
    File specFile = new File(filename);
    if (specFile.exists()) {
        return specFile;
    }/*from   w w w .j  ava  2s  .c  o  m*/

    // search ${serengeti.home.dir}/conf directory
    String homeDir = System.getProperties().getProperty("serengeti.home.dir");
    if (homeDir != null && !homeDir.trim().isEmpty()) {
        StringBuilder builder = new StringBuilder();
        builder.append(getConfDir()).append(File.separator).append(filename);
        specFile = new File(builder.toString());

        if (!specFile.exists()) {
            logger.warn(typeName + " file does not exist: " + builder);
        } else {
            return specFile;
        }
    }

    // search in class paths
    URL filePath = ConfigurationUtils.locate(filename);
    if (filePath != null) {
        specFile = ConfigurationUtils.fileFromURL(filePath);
    }

    if (!specFile.exists()) {
        String errorMsg = "Can not find file " + filename;
        logger.fatal(errorMsg);
        throw new RuntimeException(errorMsg);
    }

    return specFile;
}

From source file:com.p6spy.engine.spy.option.P6TestOptionDefaults.java

@After
public void tearDown() throws SQLException, IOException {
    System.getProperties().remove(SystemProperties.P6SPY_PREFIX + P6SpyOptions.MODULELIST);
}

From source file:ch.cyberduck.core.ftp.FTPReadFeatureTest.java

@Test
public void testRead() throws Exception {
    final Host host = new Host(new FTPTLSProtocol(), "test.cyberduck.ch",
            new Credentials(System.getProperties().getProperty("ftp.user"),
                    System.getProperties().getProperty("ftp.password")));
    final FTPSession session = new FTPSession(host);
    session.open(new DisabledHostKeyCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path home = new FTPWorkdirService(session).find();
    final Path test = new Path(home, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file));
    session.getFeature(Touch.class).touch(test, new TransferStatus());
    final int length = 39865;
    final byte[] content = RandomUtils.nextBytes(length);
    {/*from  w  w w.ja  va  2  s .co  m*/
        final TransferStatus status = new TransferStatus().length(content.length);
        final OutputStream out = new FTPWriteFeature(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 TransferStatus status = new TransferStatus();
        status.setLength(content.length);
        final InputStream in = new FTPReadFeature(session).read(test, status, new DisabledConnectionCallback());
        assertNotNull(in);
        final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length);
        new StreamCopier(status, status).withLimit(new Long(content.length)).transfer(in, buffer);
        in.close();
        assertArrayEquals(content, buffer.toByteArray());
    }
    new FTPDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(),
            new Delete.DisabledCallback());
    session.close();
}

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

@Test
public void testWrite() throws Exception {
    final Host host = new Host(new DAVProtocol(), "test.cyberduck.ch",
            new Credentials(System.getProperties().getProperty("webdav.user"),
                    System.getProperties().getProperty("webdav.password")));
    host.setDefaultPath("/dav/basic");
    final DAVSession session = new DAVSession(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  va2s . c  o m*/
    final Path home = new DefaultHomeFinderService(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<String> writer = new CryptoWriteFeature<String>(session,
            new DAVWriteFeature(session), cryptomator);
    final Cryptor cryptor = cryptomator.getCryptor();
    final FileHeader header = cryptor.fileHeaderCryptor().create();
    status.setHeader(cryptor.fileHeaderCryptor().encryptHeader(header));
    status.setNonces(new RotatingNonceGenerator(cryptomator.numberOfChunks(content.length)));
    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 DAVFindFeature(session), cryptomator).find(test));
    assertEquals(content.length, new CryptoListService(session, session, cryptomator)
            .list(test.getParent(), new DisabledListProgressListener()).get(test).attributes().getSize());
    assertEquals(content.length,
            new CryptoWriteFeature<>(session,
                    new DAVWriteFeature(session, new DefaultFindFeature(session),
                            new DefaultAttributesFinderFeature(session), true),
                    cryptomator).append(test, status.getLength(), PathCache.empty()).size,
            0L);
    assertEquals(content.length,
            new CryptoWriteFeature<>(session,
                    new DAVWriteFeature(session, new DAVFindFeature(session),
                            new DAVAttributesFinderFeature(session), true),
                    cryptomator).append(test, status.getLength(), PathCache.empty()).size,
            0L);
    final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length);
    final InputStream in = new CryptoReadFeature(session, new DAVReadFeature(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 DAVDeleteFeature(session), cryptomator)
            .delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
    session.close();
}