static public void decrypt(Properties props) { StandardPBEStringEncryptor encryptor = createEncryptor(); for (Object k : new ArrayList(props.keySet())) { String key = (String) k; String value = props.getProperty(key); if (PropertyValueEncryptionUtils.isEncryptedValue(value)) { value = PropertyValueEncryptionUtils.decrypt(value, encryptor); props.setProperty(key, value); } } } public static StandardPBEStringEncryptor createEncryptor() {
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) { String encryptionPassword = (String)options.get(ENCRYPTION_PASSWORD); String passwordEnvName = options.get(PASSWORD_ENV_NAME) != null ? (String)options.get(PASSWORD_ENV_NAME) : DEFAULT_PASSWORD_ENV_NAME; String passwordAlgorithm = options.get(PASSWORD_ALGORITHM) != null ? (String)options.get(PASSWORD_ALGORITHM) : DEFAULT_PASSWORD_ALGORITHM; EnvironmentStringPBEConfig envConfig = new EnvironmentStringPBEConfig(); envConfig.setAlgorithm(passwordAlgorithm); //If the password was set, use it //else look up the password from the environment if (encryptionPassword == null) { envConfig.setPasswordEnvName(passwordEnvName); } else { envConfig.setPassword(encryptionPassword); } configurationEncryptor.setConfig(envConfig); EncryptableProperties encryptableOptions = new EncryptableProperties(configurationEncryptor); encryptableOptions.putAll(options); super.initialize(subject, callbackHandler, sharedState, encryptableOptions); }
/** * * @param encryptor initialized encryptor * @param data * @return */ public static String encrypt(StringEncryptor encryptor, String data) { return PropertyValueEncryptionUtils.encrypt(data,encryptor); }
StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); keyChanger.initEncryptor(encryptor, oldMSKey); dbProps = new EncryptableProperties(encryptor); PropertiesConfiguration backupDBProps = null;
@Override protected String convertPropertyValue(final String originalValue) { if (!PropertyValueEncryptionUtils.isEncryptedValue(originalValue)) { return originalValue; } if (this.stringEncryptor != null) { return PropertyValueEncryptionUtils.decrypt(originalValue, this.stringEncryptor); } return PropertyValueEncryptionUtils.decrypt(originalValue, this.textEncryptor); }
protected static Properties wrapEncryption(Properties dbProps) throws IOException { EncryptionSecretKeyChecker checker = new EncryptionSecretKeyChecker(); checker.check(dbProps); if (EncryptionSecretKeyChecker.useEncryption()) { return dbProps; } else { EncryptableProperties encrProps = new EncryptableProperties(EncryptionSecretKeyChecker.getEncryptor()); encrProps.putAll(dbProps); return encrProps; } }
@Override protected String convertPropertyValue(final String originalValue) { if (!PropertyValueEncryptionUtils.isEncryptedValue(originalValue)) { return originalValue; } if (this.stringEncryptor != null) { return PropertyValueEncryptionUtils.decrypt(originalValue, this.stringEncryptor); } return PropertyValueEncryptionUtils.decrypt(originalValue, this.textEncryptor); }
EncryptableProperties encrDbProps = new EncryptableProperties(encryptor); encrDbProps.putAll(dbProps); dbProps = encrDbProps;
@Override protected String convertPropertyValue(final String originalValue) { if (!PropertyValueEncryptionUtils.isEncryptedValue(originalValue)) { return originalValue; } if (this.stringEncryptor != null) { return PropertyValueEncryptionUtils.decrypt(originalValue, this.stringEncryptor); } return PropertyValueEncryptionUtils.decrypt(originalValue, this.textEncryptor); } }
@Override protected String convertPropertyValue(final String originalValue) { if (!PropertyValueEncryptionUtils.isEncryptedValue(originalValue)) { return originalValue; } if (this.stringEncryptor != null) { return PropertyValueEncryptionUtils.decrypt(originalValue, this.stringEncryptor); } return PropertyValueEncryptionUtils.decrypt(originalValue, this.textEncryptor); }
@Override protected String convertPropertyValue(final String originalValue) { if (!PropertyValueEncryptionUtils.isEncryptedValue(originalValue)) { return originalValue; } if (this.stringEncryptor != null) { return PropertyValueEncryptionUtils.decrypt(originalValue, this.stringEncryptor); } return PropertyValueEncryptionUtils.decrypt(originalValue, this.textEncryptor); }
@Override protected String convertPropertyValue(final String originalValue) { if (!PropertyValueEncryptionUtils.isEncryptedValue(originalValue)) { return originalValue; } if (this.stringEncryptor != null) { return PropertyValueEncryptionUtils.decrypt(originalValue, this.stringEncryptor); } return PropertyValueEncryptionUtils.decrypt(originalValue, this.textEncryptor); }
@Override protected String convertPropertyValue(final String originalValue) { if (!PropertyValueEncryptionUtils.isEncryptedValue(originalValue)) { return originalValue; } if (this.stringEncryptor != null) { return PropertyValueEncryptionUtils.decrypt(originalValue, this.stringEncryptor); } return PropertyValueEncryptionUtils.decrypt(originalValue, this.textEncryptor); }
protected String convertPropertyValue(final String originalValue) { if (!PropertyValueEncryptionUtils.isEncryptedValue(originalValue)) { return originalValue; } if (this.stringEncryptor != null) { return PropertyValueEncryptionUtils.decrypt(originalValue, this.stringEncryptor); } return PropertyValueEncryptionUtils.decrypt(originalValue, this.textEncryptor); }
@Override protected String convertPropertyValue(final String originalValue) { if (!PropertyValueEncryptionUtils.isEncryptedValue(originalValue)) { return originalValue; } if (this.stringEncryptor != null) { return PropertyValueEncryptionUtils.decrypt(originalValue, this.stringEncryptor); } return PropertyValueEncryptionUtils.decrypt(originalValue, this.textEncryptor); } }
protected String convertPropertyValue(final String originalValue) { if (!PropertyValueEncryptionUtils.isEncryptedValue(originalValue)) { return originalValue; } if (this.stringEncryptor != null) { return PropertyValueEncryptionUtils.decrypt(originalValue, this.stringEncryptor); } return PropertyValueEncryptionUtils.decrypt(originalValue, this.textEncryptor); }
@Override protected String convertPropertyValue(final String originalValue) { if (!PropertyValueEncryptionUtils.isEncryptedValue(originalValue)) { return originalValue; } return PropertyValueEncryptionUtils.decrypt(originalValue, GlobalPropertyUtils.stringEncryptor); }
@Override protected String convertPropertyValue(final String originalValue) { if (!PropertyValueEncryptionUtils.isEncryptedValue(originalValue)) { return originalValue; } if (this.stringEncryptor != null) { return PropertyValueEncryptionUtils.decrypt(originalValue, this.stringEncryptor); } return PropertyValueEncryptionUtils.decrypt(originalValue, this.textEncryptor); }
@Override protected String convertPropertyValue(final String originalValue) { if (!PropertyValueEncryptionUtils.isEncryptedValue(originalValue)) { return originalValue; } if (this.stringEncryptor != null) { return PropertyValueEncryptionUtils.decrypt(originalValue, this.stringEncryptor); } return PropertyValueEncryptionUtils.decrypt(originalValue, this.textEncryptor); }
@Override protected String convertPropertyValue(final String originalValue) { if (!PropertyValueEncryptionUtils.isEncryptedValue(originalValue)) { return originalValue; } if (this.stringEncryptor != null) { return PropertyValueEncryptionUtils.decrypt(originalValue, this.stringEncryptor); } return PropertyValueEncryptionUtils.decrypt(originalValue, this.textEncryptor); }