org.jasypt.encryption.pbe.StandardPBEStringEncryptor Java Examples

The following examples show how to use org.jasypt.encryption.pbe.StandardPBEStringEncryptor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: cosmic   Author: MissionCriticalCloud   File: DBEncryptionUtil.java    License: Apache License 2.0 12 votes vote down vote up
private static void initialize() {
    final Properties dbProps = DbProperties.getDbProperties();

    if (EncryptionSecretKeyChecker.useEncryption()) {
        final 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");
    }
}
 
Example #2
Source Project: cloudstack   Author: apache   File: DBEncryptionUtil.java    License: Apache License 2.0 7 votes vote down vote up
private static void initialize() {
    final Properties dbProps = DbProperties.getDbProperties();

    if (EncryptionSecretKeyChecker.useEncryption()) {
        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");
    }
}
 
Example #3
Source Project: vividus   Author: vividus-framework   File: StringEncryptor.java    License: Apache License 2.0 6 votes vote down vote up
public static Properties decryptProperties(StandardPBEStringEncryptor standardPBEStringEncryptor,
        Properties properties)
{
    for (Map.Entry<Object, Object> entry : properties.entrySet())
    {
        String value = (String) entry.getValue();
        Matcher matcher = ENCRYPTED_PROPERTY_PATTERN.matcher(value);
        if (matcher.matches())
        {
            entry.setValue(standardPBEStringEncryptor.decrypt(matcher.group(1)));
        }
    }
    return properties;
}
 
Example #4
Source Project: vividus   Author: vividus-framework   File: StringEncryptorTests.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testDecryptProperties()
{
    StandardPBEStringEncryptor standardPBEStringEncryptor = mock(StandardPBEStringEncryptor.class);
    Properties properties = new Properties();
    properties.setProperty(PROPERTY_KEY_FIRST, PROPERTY_VALUE_FIRST);
    properties.setProperty(PROPERTY_KEY_SECOND, PROPERTY_VALUE_SECOND_ENCRYPTED);
    when(standardPBEStringEncryptor.decrypt(PROPERTY_VALUE_SECOND)).thenReturn(PROPERTY_VALUE_SECOND);
    Properties propertiesDecrypted = StringEncryptor.decryptProperties(standardPBEStringEncryptor, properties);
    assertEquals(properties.getProperty(PROPERTY_KEY_FIRST), propertiesDecrypted.getProperty(PROPERTY_KEY_FIRST));
    assertEquals(PROPERTY_VALUE_SECOND, propertiesDecrypted.getProperty(PROPERTY_KEY_SECOND));
}
 
Example #5
Source Project: jasypt   Author: jasypt   File: HibernatePBEStringEncryptor.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Sets the password to be used by the internal encryptor, if a specific
 * encryptor has not been set with <tt>setEncryptor(...)</tt>.
 * 
 * @param password the password to be set for the internal encryptor
 */
public void setPassword(final String password) {
    if (this.encryptorSet) {
        throw new EncryptionInitializationException(
                "An encryptor has been already set: no " +
                "further configuration possible on hibernate wrapper");
    }
    final StandardPBEStringEncryptor standardPBEStringEncryptor =
        (StandardPBEStringEncryptor) this.encryptor;
    standardPBEStringEncryptor.setPassword(password);
}
 
Example #6
Source Project: jasypt   Author: jasypt   File: TestHibernateTypes.java    License: Apache License 2.0 6 votes vote down vote up
private void registerEncryptors() {
    StandardPBEStringEncryptor stringEncryptor = new StandardPBEStringEncryptor();
       stringEncryptor.setAlgorithm("PBEWithMD5AndDES");
       stringEncryptor.setPassword("jasypt-hibernate5-test");
               
       StandardPBEByteEncryptor byteEncryptor = new StandardPBEByteEncryptor();
       byteEncryptor.setAlgorithm("PBEWithMD5AndDES");
       byteEncryptor.setPassword("jasypt-hibernate5-test");
       
       StandardPBEBigIntegerEncryptor bigIntegerEncryptor = new StandardPBEBigIntegerEncryptor();
       bigIntegerEncryptor.setAlgorithm("PBEWithMD5AndDES");
       bigIntegerEncryptor.setPassword("jasypt-hibernate5-test");
       
       StandardPBEBigDecimalEncryptor bigDecimalEncryptor = new StandardPBEBigDecimalEncryptor();
       bigDecimalEncryptor.setAlgorithm("PBEWithMD5AndDES");
       bigDecimalEncryptor.setPassword("jasypt-hibernate5-test");
       
       HibernatePBEEncryptorRegistry registry =
           HibernatePBEEncryptorRegistry.getInstance();
       registry.registerPBEStringEncryptor("hibernateStringEncryptor", stringEncryptor);
       registry.registerPBEByteEncryptor("hibernateByteEncryptor", byteEncryptor);
       registry.registerPBEBigIntegerEncryptor("hibernateBigIntegerEncryptor", bigIntegerEncryptor);
       registry.registerPBEBigDecimalEncryptor("hibernateBigDecimalEncryptor", bigDecimalEncryptor);
}
 
Example #7
Source Project: JuniperBot   Author: JuniperBot   File: HistoryServiceImpl.java    License: GNU General Public License v3.0 6 votes vote down vote up
private StringEncryptor getEncryptor(TextChannel channel, String iv) {
    StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
    encryptor.setAlgorithm("PBEWithHMACSHA512AndAES_256");
    encryptor.setPassword(String.format("%s:%s", channel.getGuild().getId(), channel.getId()));
    encryptor.setIvGenerator(new StringFixedIvGenerator(iv));
    return encryptor;
}
 
Example #8
Source Project: fb-botmill   Author: BotMill   File: AnnotatedTemplateTest.java    License: MIT License 6 votes vote down vote up
public static void main(String[] args) {
	StandardPBEStringEncryptor enc = new StandardPBEStringEncryptor();
	enc.setPassword("password"); // can be sourced out
	ConfigurationUtils.loadEncryptedConfigurationFile(enc, "botmill.properties");
	
	List<BotDefinition> botDef = new ArrayList<BotDefinition>();
	botDef.add(new AnnotatedTemplatedBehaviourTest());
	ConfigurationUtils.loadBotConfig();
	ConfigurationUtils.setBotDefinitionInstance(botDef);
	
	for(int i=0;i<10;i++) {
		new Thread(new Runnable() {
			String json = "{\"sender\":{\"id\":\"1158621824216736\"},\"recipient\":{\"id\":\"1226565047419159\"},\"timestamp\":1490832021661,\"message\":{\"mid\":\"mid.$cAAUPCFn4ymdhTcignVbHH3rzpKd_\",\"seq\":844819,\"text\":\"Hi!\"}}";
			MessageEnvelope envelope = FbBotMillJsonUtils.fromJson(json, MessageEnvelope.class);
			@Override
			public void run() {
				try {
					IncomingToOutgoingMessageHandler.getInstance().process(envelope);
				}catch(Exception e) {
					e.printStackTrace();
				}
			}
		}).start();
	}
}
 
Example #9
Source Project: jasypt   Author: jasypt   File: HibernatePBEStringEncryptor.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sets the password to be used by the internal encryptor (as a char[]), if a specific
 * encryptor has not been set with <tt>setEncryptor(...)</tt>.
 * 
 * @since 1.8
 * @param password the password to be set for the internal encryptor
 */
public void setPasswordCharArray(final char[] password) {
    if (this.encryptorSet) {
        throw new EncryptionInitializationException(
                "An encryptor has been already set: no " +
                "further configuration possible on hibernate wrapper");
    }
    final StandardPBEStringEncryptor standardPBEStringEncryptor =
        (StandardPBEStringEncryptor) this.encryptor;
    standardPBEStringEncryptor.setPasswordCharArray(password);
}
 
Example #10
Source Project: jasypt   Author: jasypt   File: HibernatePBEStringEncryptor.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sets the algorithm to be used by the internal encryptor, if a specific
 * encryptor has not been set with <tt>setEncryptor(...)</tt>.
 * 
 * @param algorithm the algorithm to be set for the internal encryptor
 */
public void setAlgorithm(final String algorithm) {
    if (this.encryptorSet) {
        throw new EncryptionInitializationException(
                "An encryptor has been already set: no " +
                "further configuration possible on hibernate wrapper");
    }
    final StandardPBEStringEncryptor standardPBEStringEncryptor =
        (StandardPBEStringEncryptor) this.encryptor;
    standardPBEStringEncryptor.setAlgorithm(algorithm);
}
 
Example #11
Source Project: jasypt   Author: jasypt   File: HibernatePBEStringEncryptor.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sets the key obtention iterations to be used by the internal encryptor, 
 * if a specific encryptor has not been set with <tt>setEncryptor(...)</tt>.
 * 
 * @param keyObtentionIterations to be set for the internal encryptor
 */
public void setKeyObtentionIterations(final int keyObtentionIterations) {
    if (this.encryptorSet) {
        throw new EncryptionInitializationException(
                "An encryptor has been already set: no " +
                "further configuration possible on hibernate wrapper");
    }
    final StandardPBEStringEncryptor standardPBEStringEncryptor =
        (StandardPBEStringEncryptor) this.encryptor;
    standardPBEStringEncryptor.setKeyObtentionIterations(
            keyObtentionIterations);
}
 
Example #12
Source Project: jasypt   Author: jasypt   File: HibernatePBEStringEncryptor.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sets the salt generator to be used by the internal encryptor, 
 * if a specific encryptor has not been set with <tt>setEncryptor(...)</tt>.
 * 
 * @param saltGenerator the salt generator to be set for the internal
 *                      encryptor.
 */
public void setSaltGenerator(final SaltGenerator saltGenerator) {
    if (this.encryptorSet) {
        throw new EncryptionInitializationException(
                "An encryptor has been already set: no " +
                "further configuration possible on hibernate wrapper");
    }
    final StandardPBEStringEncryptor standardPBEStringEncryptor =
        (StandardPBEStringEncryptor) this.encryptor;
    standardPBEStringEncryptor.setSaltGenerator(saltGenerator);
}
 
Example #13
Source Project: jasypt   Author: jasypt   File: HibernatePBEStringEncryptor.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sets the IV generator to be used by the internal encryptor,
 * if a specific encryptor has not been set with <tt>setEncryptor(...)</tt>.
 *
 * @param ivGenerator the IV generator to be set for the internal
 *                      encryptor.
 */
public void setIvGenerator(final IvGenerator ivGenerator) {
    if (this.encryptorSet) {
        throw new EncryptionInitializationException(
            "An encryptor has been already set: no " +
                "further configuration possible on hibernate wrapper");
    }
    final StandardPBEStringEncryptor standardPBEStringEncryptor =
        (StandardPBEStringEncryptor) this.encryptor;
    standardPBEStringEncryptor.setIvGenerator(ivGenerator);
}
 
Example #14
Source Project: jasypt   Author: jasypt   File: HibernatePBEStringEncryptor.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sets the name of the JCE provider to be used by the internal encryptor, 
 * if a specific encryptor has not been set with <tt>setEncryptor(...)</tt>.
 * 
 * @since 1.3
 * 
 * @param providerName the name of the JCE provider (already registered)
 */
public void setProviderName(final String providerName) {
    if (this.encryptorSet) {
        throw new EncryptionInitializationException(
                "An encryptor has been already set: no " +
                "further configuration possible on hibernate wrapper");
    }
    final StandardPBEStringEncryptor standardPBEStringEncryptor =
        (StandardPBEStringEncryptor) this.encryptor;
    standardPBEStringEncryptor.setProviderName(providerName);
}
 
Example #15
Source Project: jasypt   Author: jasypt   File: HibernatePBEStringEncryptor.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sets the JCE provider to be used by the internal encryptor, 
 * if a specific encryptor has not been set with <tt>setEncryptor(...)</tt>.
 * 
 * @since 1.3
 * 
 * @param provider the JCE provider to be used
 */
public void setProvider(final Provider provider) {
    if (this.encryptorSet) {
        throw new EncryptionInitializationException(
                "An encryptor has been already set: no " +
                "further configuration possible on hibernate wrapper");
    }
    final StandardPBEStringEncryptor standardPBEStringEncryptor =
        (StandardPBEStringEncryptor) this.encryptor;
    standardPBEStringEncryptor.setProvider(provider);
}
 
Example #16
Source Project: cloudstack   Author: apache   File: EncryptionSecretKeyChanger.java    License: Apache License 2.0 5 votes vote down vote up
private boolean migrateProperties(File dbPropsFile, Properties dbProps, String newMSKey, String newDBKey) {
    System.out.println("Migrating db.properties..");
    StandardPBEStringEncryptor msEncryptor = new StandardPBEStringEncryptor();
    ;
    initEncryptor(msEncryptor, newMSKey);

    try {
        PropertiesConfiguration newDBProps = new PropertiesConfiguration(dbPropsFile);
        if (newDBKey != null && !newDBKey.isEmpty()) {
            newDBProps.setProperty("db.cloud.encrypt.secret", "ENC(" + msEncryptor.encrypt(newDBKey) + ")");
        }
        String prop = dbProps.getProperty("db.cloud.password");
        if (prop != null && !prop.isEmpty()) {
            newDBProps.setProperty("db.cloud.password", "ENC(" + msEncryptor.encrypt(prop) + ")");
        }
        prop = dbProps.getProperty("db.usage.password");
        if (prop != null && !prop.isEmpty()) {
            newDBProps.setProperty("db.usage.password", "ENC(" + msEncryptor.encrypt(prop) + ")");
        }
        newDBProps.save(dbPropsFile.getAbsolutePath());
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
    System.out.println("Migrating db.properties Done.");
    return true;
}
 
Example #17
Source Project: jasypt   Author: jasypt   File: HibernatePBEStringEncryptor.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sets the PBEConfig to be used by the internal encryptor, 
 * if a specific encryptor has not been set with <tt>setEncryptor(...)</tt>.
 * 
 * @param config the PBEConfig to be set for the internal encryptor
 */
public void setConfig(final PBEConfig config) {
    if (this.encryptorSet) {
        throw new EncryptionInitializationException(
                "An encryptor has been already set: no " +
                "further configuration possible on hibernate wrapper");
    }
    final StandardPBEStringEncryptor standardPBEStringEncryptor =
        (StandardPBEStringEncryptor) this.encryptor;
    standardPBEStringEncryptor.setConfig(config);
}
 
Example #18
Source Project: jasypt   Author: jasypt   File: HibernatePBEStringEncryptor.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sets the password to be used by the internal encryptor, if a specific
 * encryptor has not been set with <tt>setEncryptor(...)</tt>.
 * 
 * @param password the password to be set for the internal encryptor
 */
public void setPassword(final String password) {
    if (this.encryptorSet) {
        throw new EncryptionInitializationException(
                "An encryptor has been already set: no " +
                "further configuration possible on hibernate wrapper");
    }
    final StandardPBEStringEncryptor standardPBEStringEncryptor =
        (StandardPBEStringEncryptor) this.encryptor;
    standardPBEStringEncryptor.setPassword(password);
}
 
Example #19
Source Project: jasypt   Author: jasypt   File: HibernatePBEStringEncryptor.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sets the password to be used by the internal encryptor (as a char[]), if a specific
 * encryptor has not been set with <tt>setEncryptor(...)</tt>.
 * 
 * @since 1.8
 * @param password the password to be set for the internal encryptor
 */
public void setPasswordCharArray(final char[] password) {
    if (this.encryptorSet) {
        throw new EncryptionInitializationException(
                "An encryptor has been already set: no " +
                "further configuration possible on hibernate wrapper");
    }
    final StandardPBEStringEncryptor standardPBEStringEncryptor =
        (StandardPBEStringEncryptor) this.encryptor;
    standardPBEStringEncryptor.setPasswordCharArray(password);
}
 
Example #20
Source Project: jasypt   Author: jasypt   File: HibernatePBEStringEncryptor.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sets the algorithm to be used by the internal encryptor, if a specific
 * encryptor has not been set with <tt>setEncryptor(...)</tt>.
 * 
 * @param algorithm the algorithm to be set for the internal encryptor
 */
public void setAlgorithm(final String algorithm) {
    if (this.encryptorSet) {
        throw new EncryptionInitializationException(
                "An encryptor has been already set: no " +
                "further configuration possible on hibernate wrapper");
    }
    final StandardPBEStringEncryptor standardPBEStringEncryptor =
        (StandardPBEStringEncryptor) this.encryptor;
    standardPBEStringEncryptor.setAlgorithm(algorithm);
}
 
Example #21
Source Project: jasypt   Author: jasypt   File: HibernatePBEStringEncryptor.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sets the key obtention iterations to be used by the internal encryptor, 
 * if a specific encryptor has not been set with <tt>setEncryptor(...)</tt>.
 * 
 * @param keyObtentionIterations to be set for the internal encryptor
 */
public void setKeyObtentionIterations(final int keyObtentionIterations) {
    if (this.encryptorSet) {
        throw new EncryptionInitializationException(
                "An encryptor has been already set: no " +
                "further configuration possible on hibernate wrapper");
    }
    final StandardPBEStringEncryptor standardPBEStringEncryptor =
        (StandardPBEStringEncryptor) this.encryptor;
    standardPBEStringEncryptor.setKeyObtentionIterations(
            keyObtentionIterations);
}
 
Example #22
Source Project: jasypt   Author: jasypt   File: HibernatePBEStringEncryptor.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sets the salt generator to be used by the internal encryptor, 
 * if a specific encryptor has not been set with <tt>setEncryptor(...)</tt>.
 * 
 * @param saltGenerator the salt generator to be set for the internal
 *                      encryptor.
 */
public void setSaltGenerator(final SaltGenerator saltGenerator) {
    if (this.encryptorSet) {
        throw new EncryptionInitializationException(
                "An encryptor has been already set: no " +
                "further configuration possible on hibernate wrapper");
    }
    final StandardPBEStringEncryptor standardPBEStringEncryptor =
        (StandardPBEStringEncryptor) this.encryptor;
    standardPBEStringEncryptor.setSaltGenerator(saltGenerator);
}
 
Example #23
Source Project: jasypt   Author: jasypt   File: HibernatePBEStringEncryptor.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sets the IV generator to be used by the internal encryptor,
 * if a specific encryptor has not been set with <tt>setEncryptor(...)</tt>.
 *
 * @param ivGenerator the IV generator to be set for the internal
 *                      encryptor.
 */
public void setIvGenerator(final IvGenerator ivGenerator) {
    if (this.encryptorSet) {
        throw new EncryptionInitializationException(
            "An encryptor has been already set: no " +
                "further configuration possible on hibernate wrapper");
    }
    final StandardPBEStringEncryptor standardPBEStringEncryptor =
        (StandardPBEStringEncryptor) this.encryptor;
    standardPBEStringEncryptor.setIvGenerator(ivGenerator);
}
 
Example #24
Source Project: jasypt   Author: jasypt   File: HibernatePBEStringEncryptor.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sets the name of the JCE provider to be used by the internal encryptor, 
 * if a specific encryptor has not been set with <tt>setEncryptor(...)</tt>.
 * 
 * @since 1.3
 * 
 * @param providerName the name of the JCE provider (already registered)
 */
public void setProviderName(final String providerName) {
    if (this.encryptorSet) {
        throw new EncryptionInitializationException(
                "An encryptor has been already set: no " +
                "further configuration possible on hibernate wrapper");
    }
    final StandardPBEStringEncryptor standardPBEStringEncryptor =
        (StandardPBEStringEncryptor) this.encryptor;
    standardPBEStringEncryptor.setProviderName(providerName);
}
 
Example #25
Source Project: jasypt   Author: jasypt   File: HibernatePBEStringEncryptor.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sets the type of String output ("base64" (default), "hexadecimal") to 
 * be used by the internal encryptor, 
 * if a specific encryptor has not been set with <tt>setEncryptor(...)</tt>.
 * 
 * @since 1.3
 * 
 * @param stringOutputType the type of String output
 */
public void setStringOutputType(final String stringOutputType) {
    if (this.encryptorSet) {
        throw new EncryptionInitializationException(
                "An encryptor has been already set: no " +
                "further configuration possible on hibernate wrapper");
    }
    final StandardPBEStringEncryptor standardPBEStringEncryptor =
        (StandardPBEStringEncryptor) this.encryptor;
    standardPBEStringEncryptor.setStringOutputType(stringOutputType);
}
 
Example #26
Source Project: jasypt   Author: jasypt   File: HibernatePBEStringEncryptor.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sets the PBEConfig to be used by the internal encryptor, 
 * if a specific encryptor has not been set with <tt>setEncryptor(...)</tt>.
 * 
 * @param config the PBEConfig to be set for the internal encryptor
 */
public void setConfig(final PBEConfig config) {
    if (this.encryptorSet) {
        throw new EncryptionInitializationException(
                "An encryptor has been already set: no " +
                "further configuration possible on hibernate wrapper");
    }
    final StandardPBEStringEncryptor standardPBEStringEncryptor =
        (StandardPBEStringEncryptor) this.encryptor;
    standardPBEStringEncryptor.setConfig(config);
}
 
Example #27
Source Project: jasypt   Author: jasypt   File: TestHibernateTypes.java    License: Apache License 2.0 5 votes vote down vote up
private void registerEncryptors() {
    StandardPBEStringEncryptor stringEncryptor = new StandardPBEStringEncryptor();
       stringEncryptor.setAlgorithm("PBEWithMD5AndDES");
       stringEncryptor.setPassword("jasypt-hibernate3-test");
               
       StandardPBEByteEncryptor byteEncryptor = new StandardPBEByteEncryptor();
       byteEncryptor.setAlgorithm("PBEWithMD5AndDES");
       byteEncryptor.setPassword("jasypt-hibernate3-test");
       
       HibernatePBEEncryptorRegistry registry =
           HibernatePBEEncryptorRegistry.getInstance();
       registry.registerPBEStringEncryptor("hibernateStringEncryptor", stringEncryptor);
       registry.registerPBEByteEncryptor("hibernateByteEncryptor", byteEncryptor);
}
 
Example #28
Source Project: jasypt   Author: jasypt   File: AES256TextEncryptor.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new instance of <tt>StrongTextEncryptor</tt>.
 */
public AES256TextEncryptor() {
    super();
    this.encryptor = new StandardPBEStringEncryptor();
    this.encryptor.setAlgorithm("PBEWithHMACSHA512AndAES_256");
    this.encryptor.setIvGenerator(new RandomIvGenerator());
}
 
Example #29
Source Project: jasypt   Author: jasypt   File: HibernatePBEStringEncryptor.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sets the password to be used by the internal encryptor, if a specific
 * encryptor has not been set with <tt>setEncryptor(...)</tt>.
 * 
 * @param password the password to be set for the internal encryptor
 */
public void setPassword(final String password) {
    if (this.encryptorSet) {
        throw new EncryptionInitializationException(
                "An encryptor has been already set: no " +
                "further configuration possible on hibernate wrapper");
    }
    final StandardPBEStringEncryptor standardPBEStringEncryptor =
        (StandardPBEStringEncryptor) this.encryptor;
    standardPBEStringEncryptor.setPassword(password);
}
 
Example #30
Source Project: jasypt   Author: jasypt   File: HibernatePBEStringEncryptor.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sets the password to be used by the internal encryptor (as a char[]), if a specific
 * encryptor has not been set with <tt>setEncryptor(...)</tt>.
 * 
 * @since 1.8
 * @param password the password to be set for the internal encryptor
 */
public void setPasswordCharArray(final char[] password) {
    if (this.encryptorSet) {
        throw new EncryptionInitializationException(
                "An encryptor has been already set: no " +
                "further configuration possible on hibernate wrapper");
    }
    final StandardPBEStringEncryptor standardPBEStringEncryptor =
        (StandardPBEStringEncryptor) this.encryptor;
    standardPBEStringEncryptor.setPasswordCharArray(password);
}