@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); }
EncryptableProperties encrDbProps = new EncryptableProperties(encryptor); encrDbProps.putAll(dbProps); dbProps = encrDbProps;
StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); keyChanger.initEncryptor(encryptor, oldMSKey); dbProps = new EncryptableProperties(encryptor); PropertiesConfiguration backupDBProps = null;
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; } }
/** * Uses jasypt to parse the properties * * @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); } }
private static Properties processProperties(final Properties props, final TextEncryptor encryptor) { if (props == null) { return null; } if (props instanceof EncryptableProperties) { throw new IllegalArgumentException( "Properties object already is an " + EncryptableProperties.class.getName() + " object. No encryptor should be specified."); } final EncryptableProperties encryptableProperties = new EncryptableProperties(encryptor); encryptableProperties.putAll(props); return encryptableProperties; }
private static Properties processProperties(final Properties props, final StringEncryptor encryptor) { if (props == null) { return null; } if (props instanceof EncryptableProperties) { throw new IllegalArgumentException( "Properties object already is an " + EncryptableProperties.class.getName() + " object. No encryptor should be specified."); } final EncryptableProperties encryptableProperties = new EncryptableProperties(encryptor); encryptableProperties.putAll(props); return encryptableProperties; }
private static Properties processProperties(final Properties props, final TextEncryptor encryptor) { if (props == null) { return null; } if (props instanceof EncryptableProperties) { throw new IllegalArgumentException( "Properties object already is an " + EncryptableProperties.class.getName() + " object. No encryptor should be specified."); } final EncryptableProperties encryptableProperties = new EncryptableProperties(encryptor); encryptableProperties.putAll(props); return encryptableProperties; }
private static Properties processProperties(final Properties props, final StringEncryptor encryptor) { if (props == null) { return null; } if (props instanceof EncryptableProperties) { throw new IllegalArgumentException( "Properties object already is an " + EncryptableProperties.class.getName() + " object. No encryptor should be specified."); } final EncryptableProperties encryptableProperties = new EncryptableProperties(encryptor); encryptableProperties.putAll(props); return encryptableProperties; }
/** * Loads the Encrypted configuration BotMill configuration properties file. * In order for this to work, you need a botmill.properties file on the * classpath. If you have a Maven project, just make sure to place it in the * resources folder. * * @param encryptor * the encryptor */ public static void setEncryptedPropertiesEncryptor(PBEStringCleanablePasswordEncryptor encryptor) { try { if (encryptedConfiguration == null) { encryptedConfiguration = new EncryptableProperties(encryptor); } encryptedConfiguration.load(ConfigurationUtils.class.getClassLoader().getResourceAsStream(CONFIG_PATH)); } catch (Exception e) { logger.error("Error while loading BotMill properties file ({})", CONFIG_PATH, e); } }
private EncryptableProperties processEncryptable(final Properties props) { if (this.encryptor == null) { throw new IllegalArgumentException( "\"encryptor\" property in EncryptableProperties definition cannot be null"); } if (this.encryptor instanceof TextEncryptor) { final EncryptableProperties encryptableProperties = new EncryptableProperties((TextEncryptor)this.encryptor); encryptableProperties.putAll(props); return encryptableProperties; } else if (this.encryptor instanceof StringEncryptor) { final EncryptableProperties encryptableProperties = new EncryptableProperties((StringEncryptor)this.encryptor); encryptableProperties.putAll(props); return encryptableProperties; } throw new IllegalArgumentException( "\"encryptor\" property in EncryptableProperties definition must be either " + "an org.jasypt.util.text.TextEncryptor or an org.jasypt.encryption.StringEncryptor " + "object. An object of class " + this.encryptor.getClass().getName() + " has been " + "specified instead."); }
private EncryptableProperties processEncryptable(final Properties props) { if (this.encryptor == null) { throw new IllegalArgumentException( "\"encryptor\" property in EncryptableProperties definition cannot be null"); } if (this.encryptor instanceof TextEncryptor) { final EncryptableProperties encryptableProperties = new EncryptableProperties((TextEncryptor)this.encryptor); encryptableProperties.putAll(props); return encryptableProperties; } else if (this.encryptor instanceof StringEncryptor) { final EncryptableProperties encryptableProperties = new EncryptableProperties((StringEncryptor)this.encryptor); encryptableProperties.putAll(props); return encryptableProperties; } throw new IllegalArgumentException( "\"encryptor\" property in EncryptableProperties definition must be either " + "an org.jasypt.util.text.TextEncryptor or an org.jasypt.encryption.StringEncryptor " + "object. An object of class " + this.encryptor.getClass().getName() + " has been " + "specified instead."); }
private EncryptableProperties processEncryptable(final Properties props) { if (this.encryptor == null) { throw new IllegalArgumentException( "\"encryptor\" property in EncryptableProperties definition cannot be null"); } if (this.encryptor instanceof TextEncryptor) { final EncryptableProperties encryptableProperties = new EncryptableProperties((TextEncryptor)this.encryptor); encryptableProperties.putAll(props); return encryptableProperties; } else if (this.encryptor instanceof StringEncryptor) { final EncryptableProperties encryptableProperties = new EncryptableProperties((StringEncryptor)this.encryptor); encryptableProperties.putAll(props); return encryptableProperties; } throw new IllegalArgumentException( "\"encryptor\" property in EncryptableProperties definition must be either " + "an org.jasypt.util.text.TextEncryptor or an org.jasypt.encryption.StringEncryptor " + "object. An object of class " + this.encryptor.getClass().getName() + " has been " + "specified instead."); }
/** * Loads the Encrypted configuration BotMill configuration properties file. * In order for this to work, you need a botmill.properties file on the * classpath. If you have a Maven project, just make sure to place it in the * resources folder. * * @param encryptor * the encryptor. * @param classpathProperties * the classpath properties */ public static void loadEncryptedConfigurationFile(PBEStringCleanablePasswordEncryptor encryptor, String classpathProperties) { try { if (encryptedConfiguration == null) { encryptedConfiguration = new EncryptableProperties(encryptor); } encryptedConfiguration .load(ConfigurationUtils.class.getClassLoader().getResourceAsStream(classpathProperties)); } catch (Exception e) { logger.error("Error while loading BotMill properties file ({})", CONFIG_PATH, e); } }
@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); }
@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); }
final EncryptableProperties encrDbProps = new EncryptableProperties(encryptor); encrDbProps.putAll(dbProps); dbProps = encrDbProps;
protected static Properties wrapEncryption(final Properties dbProps) throws IOException { final EncryptionSecretKeyChecker checker = new EncryptionSecretKeyChecker(); checker.check(dbProps); if (EncryptionSecretKeyChecker.useEncryption()) { return dbProps; } else { final EncryptableProperties encrProps = new EncryptableProperties(EncryptionSecretKeyChecker.getEncryptor()); encrProps.putAll(dbProps); return encrProps; } } }
rslt = new EncryptableProperties(encryptor);