/** * DES algorithm */ private PBEStringEncryptor newEncryptor(final String passphrase) { final StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); encryptor.setPassword(passphrase); return encryptor; } }
/* * First, create (or ask some other component for) the adequate encryptor for * decrypting the values in our .properties file. */ StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); encryptor.setPassword("jasypt"); // could be got from web, env variable... /* * Create our EncryptableProperties object and load it the usual way. */ Properties props = new EncryptableProperties(encryptor); props.load(new FileInputStream("/path/to/my/configuration.properties")); /* * To get a non-encrypted value, we just get it with getProperty... */ String datasourceUsername = props.getProperty("datasource.username"); /* * ...and to get an encrypted value, we do exactly the same. Decryption will * be transparently performed behind the scenes. */ String datasourcePassword = props.getProperty("datasource.password"); // From now on, datasourcePassword equals "reports_passwd"...
/** * AES algorithm */ private PBEStringEncryptor newEncryptor(final String passphrase) { final StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); encryptor.setPassword(passphrase); encryptor.setProvider(PROVIDER); encryptor.setAlgorithm(CRYPTO_ALGO); return encryptor; } }
public static StandardPBEStringEncryptor createEncryptor() { StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); EnvironmentStringPBEConfig config = new EnvironmentStringPBEConfig(); config.setAlgorithm("PBEWithMD5AndDES"); config.setPasswordEnvName("ACTIVEMQ_ENCRYPTION_PASSWORD"); encryptor.setConfig(config); return encryptor; }
@Override protected PasswordEncoder createStringEncoder() { byte[] password = lookupPasswordFromKeyStore(); char[] chars = toChars(password); try { stringEncrypter = new StandardPBEStringEncryptor(); stringEncrypter.setPasswordCharArray(chars); if (getProviderName() != null && !getProviderName().isEmpty()) { stringEncrypter.setProviderName(getProviderName()); } stringEncrypter.setAlgorithm(getAlgorithm()); JasyptPBEPasswordEncoderWrapper encoder = new JasyptPBEPasswordEncoderWrapper(); encoder.setPbeStringEncryptor(stringEncrypter); return encoder; } finally { scramble(password); scramble(chars); } }
private static void initialize(String key) { StandardPBEStringEncryptor standardPBEStringEncryptor = new StandardPBEStringEncryptor(); standardPBEStringEncryptor.setAlgorithm("PBEWITHSHA1ANDDESEDE"); standardPBEStringEncryptor.setPassword(key); encryptor = standardPBEStringEncryptor; }
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; }
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"); } } }
final Properties dbProps; EncryptionSecretKeyChanger keyChanger = new EncryptionSecretKeyChanger(); StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); keyChanger.initEncryptor(encryptor, oldMSKey); dbProps = new EncryptableProperties(encryptor);
/** * Creates a new instance of <tt>PooledStandardPBEStringEncryptor</tt>. */ public PooledPBEStringEncryptor() { super(); this.firstEncryptor = new StandardPBEStringEncryptor(); }
/** * Creates a new instance of <tt>PooledStandardPBEStringEncryptor</tt>. */ public PooledPBEStringEncryptor() { super(); this.firstEncryptor = new StandardPBEStringEncryptor(); }
/** * Creates a new instance of <tt>BasicTextEncryptor</tt>. */ public BasicTextEncryptor() { super(); this.encryptor = new StandardPBEStringEncryptor(); this.encryptor.setAlgorithm("PBEWithMD5AndDES"); }
/** * Creates a new instance of <tt>StrongTextEncryptor</tt>. */ public StrongTextEncryptor() { super(); this.encryptor = new StandardPBEStringEncryptor(); this.encryptor.setAlgorithm("PBEWithMD5AndTripleDES"); }
/** * Creates a new instance of <tt>BasicTextEncryptor</tt>. */ public BasicTextEncryptor() { super(); this.encryptor = new StandardPBEStringEncryptor(); this.encryptor.setAlgorithm("PBEWithMD5AndDES"); }
public static void main(String[] args) { StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); encryptor.setPassword("mySecretPassword"); String encryptedText = encryptor.encrypt("Hello World"); System.out.println("Encrypted text is: " + encryptedText); StandardPBEStringEncryptor decryptor = new StandardPBEStringEncryptor(); decryptor.setPassword("mySecretPassword"); String decryptedText = decryptor.decrypt(encryptedText); System.out.println("Decrypted text is: " + decryptedText); }
String seed = "ipNumber"; String myIpValue = "192.168.0.1"; StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); encryptor.setPassword(seed); String encrypted= encryptor.encrypt(myIpValue);
private static void initialize(final String key) { final StandardPBEStringEncryptor standardPBEStringEncryptor = new StandardPBEStringEncryptor(); standardPBEStringEncryptor.setAlgorithm("PBEWITHSHA1ANDDESEDE"); standardPBEStringEncryptor.setPassword(key); encryptor = standardPBEStringEncryptor; }
private static String encryptPassword(String plainPassword, String encryptionKey) { StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); encryptor.setPassword(encryptionKey); encryptor.setAlgorithm("PBEWithMD5AndDES"); return PropertyValueEncryptionUtils.encrypt(plainPassword, encryptor); }
private static String decryptPassword(String encryptedPassword, String encryptionKey) { StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); encryptor.setPassword(encryptionKey); encryptor.setAlgorithm("PBEWithMD5AndDES"); return PropertyValueEncryptionUtils.decrypt(encryptedPassword, encryptor); }
@Override public Boolean isEncEnabled() { Boolean encEnabled = getResolvedBooleanProperty(PROPERTY_ENC_ENABLED); if (encEnabled) { this.encryptor = new StandardPBEStringEncryptor(); this.encryptor.setPassword(getEncMasterPassword()); this.encryptor.setAlgorithm(getEncAlgorithm()); } return encEnabled; }