Java Properties Load from File loadCryptoProperties()

Here you can find the source of loadCryptoProperties()

Description

load Crypto Properties

License

Creative Commons License

Declaration

private static void loadCryptoProperties() throws IOException 

Method Source Code


//package com.java2s;
//License from project: Creative Commons License 

import java.io.*;

import java.util.*;

public class Main {
    private static final String CRYPTO_PROPERTIES = "crypto.properties";
    private static final String CRYPTO_KEY_ALGORITHM = "crypto.key_algorithm";
    private static final String CRYPTO_RNG_ALGORITHM = "crypto.rng_algorithm";
    private static final String CRYPTO_ITERATIONS = "crypto.iterations";
    private static final String CRYPTO_SALT_LENGTH = "crypto.salt_length";
    private static final String CRYPTO_KEY_LENGTH = "crypto.key_length";
    private static String keyAlgorithm = "PBKDF2WithHmacSHA1";
    private static String rngAlgorithm = "SHA1PRNG";
    private static int iterations = 10 * 1024;
    private static int saltLength = 32;
    private static int keyLength = 256;

    private static void loadCryptoProperties() throws IOException {
        ClassLoader cl = Thread.currentThread().getContextClassLoader();
        Properties properties = new Properties();
        InputStream is = cl.getResourceAsStream(CRYPTO_PROPERTIES);
        properties.load(is);/*from w  w w  . j a v a2  s.  co m*/

        keyAlgorithm = properties.getProperty(CRYPTO_KEY_ALGORITHM);
        rngAlgorithm = properties.getProperty(CRYPTO_RNG_ALGORITHM);

        String v = properties.getProperty(CRYPTO_ITERATIONS);
        iterations = Integer.parseInt(v);

        v = properties.getProperty(CRYPTO_SALT_LENGTH);
        saltLength = Integer.parseInt(v);

        v = properties.getProperty(CRYPTO_KEY_LENGTH);
        keyLength = Integer.parseInt(v);
    }
}

Related

  1. loadConfigProperties()
  2. loadConfiguration()
  3. loadConfiguration(String file)
  4. loadConfiguration(String filePath)
  5. loadCredentials(File credentials, String credentialsAppend)
  6. loadDBProperties(String dbConn)
  7. loadDefault(String _file_path)
  8. loadDefaultConfiguration()
  9. loadDefaultProps(Properties deployProps)