Package org.jasypt.encryption.pbe

Examples of org.jasypt.encryption.pbe.StandardPBEStringEncryptor


    public synchronized StandardPBEStringEncryptor getEncryptor() {
        if (encryptor == null) {
            // password is mandatory
            ObjectHelper.notEmpty("password", getPassword());

            encryptor = new StandardPBEStringEncryptor();
            encryptor.setPassword(getPassword());
            if (algorithm != null) {
                encryptor.setAlgorithm(getAlgorithm());
            }
        }
View Full Code Here


{

    @Test
    public void testEncrypt()
    {
        StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
        encryptor.setProvider(new BouncyCastleProvider());
        encryptor.setAlgorithm("PBEWITHSHA256AND256BITAES-CBC-BC");
        encryptor.setPassword("w3bp@$$w0rd$@f3k3y");
        encryptor.setKeyObtentionIterations(1000);

        String clearText = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";
        System.out.println("clearText.length="+clearText.length());
        System.out.println("clearText="+clearText);
        String encryptedText = encryptor.encrypt(clearText);
        System.out.println("encryptedText.length="+encryptedText.length());
        System.out.println("encryptedText="+encryptedText);
        assertEquals(encryptedText.length(), 172);
        String decryptedText = encryptor.decrypt(encryptedText);
        assertEquals(decryptedText, clearText);
    }
View Full Code Here

        return getEncryptor().decrypt(message);
    }

    private StandardPBEStringEncryptor getEncryptor() {
        if (encryptor == null) {
            encryptor = new StandardPBEStringEncryptor();
            encryptor.setProvider(new BouncyCastleProvider());
            encryptor.setAlgorithm("PBEWITHSHA256AND128BITAES-CBC-BC");
            encryptor.setPassword(this.getUuid() + HASH_KEY);
        }
        return encryptor;
View Full Code Here

    @Before
    public void setUp() throws Exception {

        // Configure Jasypt
        enc = new StandardPBEStringEncryptor();
        env = new EnvironmentStringPBEConfig();
        env.setAlgorithm("PBEWithMD5AndDES");
        env.setPassword("password");
        enc.setConfig(env);
View Full Code Here

    public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
        _name = name;
        File dbPropsFile = PropertiesUtil.findConfigFile("db.properties");
        final Properties dbProps;
        if (EncryptionSecretKeyChecker.useEncryption()) {
            StandardPBEStringEncryptor encryptor = EncryptionSecretKeyChecker.getEncryptor();
            dbProps = new EncryptableProperties(encryptor);
        } else {
            dbProps = new Properties();
        }
        try {
View Full Code Here

    public static void initDataSource(String propsFileName) {
        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 {
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) {
View Full Code Here

            String dbSecretKey = dbProps.getProperty("db.cloud.encrypt.secret");
            if (dbSecretKey == null || dbSecretKey.isEmpty()) {
                throw new CloudRuntimeException("Empty DB secret key in db.properties");
            }

            s_encryptor = new StandardPBEStringEncryptor();
            s_encryptor.setAlgorithm("PBEWithMD5AndDES");
            s_encryptor.setPassword(dbSecretKey);
        } else {
            throw new CloudRuntimeException("Trying to encrypt db values when encrytion is not enabled");
        }
View Full Code Here

    private void updateRegionEntries(Connection conn) {
        File dbPropsFile = PropertiesUtil.findConfigFile("db.properties");
        final Properties dbProps;
        if (EncryptionSecretKeyChecker.useEncryption()) {
            StandardPBEStringEncryptor encryptor = EncryptionSecretKeyChecker.getEncryptor();
            dbProps = new EncryptableProperties(encryptor);
        } else {
            dbProps = new Properties();
        }
        try {
View Full Code Here

   
    private void updateRegionEntries(Connection conn) {
        File dbPropsFile = PropertiesUtil.findConfigFile("db.properties");
        final Properties dbProps;
        if (EncryptionSecretKeyChecker.useEncryption()) {
            StandardPBEStringEncryptor encryptor = EncryptionSecretKeyChecker.getEncryptor();
            dbProps = new EncryptableProperties(encryptor);
        } else {
            dbProps = new Properties();
        }
        try {
View Full Code Here

TOP

Related Classes of org.jasypt.encryption.pbe.StandardPBEStringEncryptor

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.