Package org.jasypt.properties

Examples of org.jasypt.properties.EncryptableProperties


    final File dbPropsFile = PropertiesUtil.findConfigFile("db.properties");
    final Properties dbProps;
    EncryptionSecretKeyChanger keyChanger = new EncryptionSecretKeyChanger();
    StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
    keyChanger.initEncryptor(encryptor, oldMSKey);
    dbProps = new EncryptableProperties(encryptor);
    PropertiesConfiguration backupDBProps = null;

    System.out.println("Parsing db.properties file");
    try {
      dbProps.load(new FileInputStream(dbPropsFile));
View Full Code Here


        final File dbPropsFile = PropertiesUtil.findConfigFile("db.properties");
        final Properties dbProps;
        EncryptionSecretKeyChanger keyChanger = new EncryptionSecretKeyChanger();
        StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
        keyChanger.initEncryptor(encryptor, oldMSKey);
        dbProps = new EncryptableProperties(encryptor);
        PropertiesConfiguration backupDBProps = null;

        System.out.println("Parsing db.properties file");
        try {
            dbProps.load(new FileInputStream(dbPropsFile));
View Full Code Here

    final File dbPropsFile = PropertiesUtil.findConfigFile("db.properties");
    final Properties dbProps;
    EncryptionSecretKeyChanger keyChanger = new EncryptionSecretKeyChanger();
    StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
    keyChanger.initEncryptor(encryptor, oldMSKey);
    dbProps = new EncryptableProperties(encryptor);
    PropertiesConfiguration backupDBProps = null;

    System.out.println("Parsing db.properties file");
    try {
      dbProps.load(new FileInputStream(dbPropsFile));
View Full Code Here

    /**
     * Find all conf files on classpath. Use a EncryptableProperties so that any ENC(...) properties are decrypted
     */
    public Properties getProperties(){

        EncryptableProperties properties = new EncryptableProperties(encryptor);

        URL baseUrl = JasyptExample.class.getClassLoader().getResource(".");
        File rootClassPath = new File(baseUrl.getFile());
        for( String next : rootClassPath.list() ) {
            if(next.endsWith(".conf")) {
                try {
                    properties.load(new FileReader(baseUrl.getFile() + next));
                } catch (IOException e) {
                    log.error("Unable to read properties file {}", baseUrl.getFile() + next);
                }
            }
        }
View Full Code Here

    public void propsTest() throws IOException {

        BasicTextEncryptor encryptor = new BasicTextEncryptor();
        encryptor.setPassword("secret");

        Properties props = new EncryptableProperties(encryptor);
        URL url = JasyptTest.class.getClassLoader().getResource("secret.conf");

        props.load(new FileInputStream(url.getFile()));

        String message = props.getProperty("encrypted");

        assertEquals("super secret message", message);

    }
View Full Code Here

        config.setPasswordEnvName("MY_APP_PASSWORD");

        StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
        encryptor.setConfig(config);

        Properties props = new EncryptableProperties(encryptor);
        URL url = JasyptTest.class.getClassLoader().getResource("secret.conf");

        props.load(new FileInputStream(url.getFile()));
        String message;

        try {
            message = props.getProperty("encrypted");
        } catch (NullPointerException e) {
            throw new AssertionError("Set MY_APP_PASSWORD and try again");
        }

        assertEquals("super secret message", message);
View Full Code Here

     * @param props the properties currently read
     * @return an instance of {@link org.jasypt.properties.EncryptableProperties}
     */
    @Override
    protected Properties parseProperties(Properties props) {
        return new EncryptableProperties(props, encryptor);
    }
View Full Code Here

        try {
            File dbPropsFile = PropertiesUtil.findConfigFile(propsFileName);
            final Properties dbProps;
            if (EncryptionSecretKeyChecker.useEncryption()) {
                StandardPBEStringEncryptor encryptor = EncryptionSecretKeyChecker.getEncryptor();
                dbProps = new EncryptableProperties(encryptor);
            } else {
                dbProps = new Properties();
            }
            try {
                dbProps.load(new FileInputStream(dbPropsFile));
View Full Code Here

        checker.check(dbProps);

        if ( EncryptionSecretKeyChecker.useEncryption() ) {
            return dbProps;
        } else {
            EncryptableProperties encrProps = new EncryptableProperties(EncryptionSecretKeyChecker.getEncryptor());
            encrProps.putAll(dbProps);
            return encrProps;
        }
    }
View Full Code Here

                EncryptionSecretKeyChecker checker = new EncryptionSecretKeyChecker();
                checker.check(dbProps);

                if (EncryptionSecretKeyChecker.useEncryption()) {
                    StandardPBEStringEncryptor encryptor = EncryptionSecretKeyChecker.getEncryptor();
                    EncryptableProperties encrDbProps = new EncryptableProperties(encryptor);
                    encrDbProps.putAll(dbProps);
                    dbProps = encrDbProps;
                }
            } catch ( IOException e ) {
                throw new IllegalStateException("Failed to load db.properties", e);
            } finally {
View Full Code Here

TOP

Related Classes of org.jasypt.properties.EncryptableProperties

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.