@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); }
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; }
private void initEncryptor(StandardPBEStringEncryptor encryptor, String secretKey) { encryptor.setAlgorithm("PBEWithMD5AndDES"); SimpleStringPBEConfig stringConfig = new SimpleStringPBEConfig(); stringConfig.setPassword(secretKey); encryptor.setConfig(stringConfig); }
public static void initEncryptorForMigration(String secretKey) { s_encryptor.setAlgorithm("PBEWithMD5AndDES"); SimpleStringPBEConfig stringConfig = new SimpleStringPBEConfig(); stringConfig.setPassword(secretKey); s_encryptor.setConfig(stringConfig); s_useEncryption = true; } }
SimplePBEConfig config = new SimplePBEConfig(); config.setAlgorithm("PBEWithMD5AndTripleDES"); config.setKeyObtentionIterations(1000); config.setPassword("propertiesFilePassword"); StandardPBEStringEncryptor encryptor = new org.jasypt.encryption.pbe.StandardPBEStringEncryptor(); encryptor.setConfig(config); encryptor.initialize();
s_encryptor.setConfig(stringConfig); s_useEncryption = true;
/** * <p> * Sets a <tt>{@link org.jasypt.encryption.pbe.config.PBEConfig}</tt> object * for the encryptor. If this config * object is set, it will be asked values for: * </p> * * <ul> * <li>Algorithm</li> * <li>Security Provider (or provider name)</li> * <li>Password</li> * <li>Hashing iterations for obtaining the encryption key</li> * <li>Salt generator</li> * <li>Output type (base64, hexadecimal) * (only <tt>StringPBEConfig</tt>)</li> * </ul> * * <p> * The non-null values it returns will override the default ones, * <i>and will be overriden by any values specified with a <tt>setX</tt> * method</i>. * </p> * * @param config the <tt>PBEConfig</tt> object to be used as the * source for configuration parameters. */ public synchronized void setConfig(final PBEConfig config) { this.firstEncryptor.setConfig(config); this.config = config; }
/** * <p> * Sets a <tt>{@link org.jasypt.encryption.pbe.config.PBEConfig}</tt> object * for the encryptor. If this config * object is set, it will be asked values for: * </p> * * <ul> * <li>Algorithm</li> * <li>Security Provider (or provider name)</li> * <li>Password</li> * <li>Hashing iterations for obtaining the encryption key</li> * <li>Salt generator</li> * <li>Output type (base64, hexadecimal) * (only <tt>StringPBEConfig</tt>)</li> * </ul> * * <p> * The non-null values it returns will override the default ones, * <i>and will be overriden by any values specified with a <tt>setX</tt> * method</i>. * </p> * * @param config the <tt>PBEConfig</tt> object to be used as the * source for configuration parameters. */ public synchronized void setConfig(final PBEConfig config) { this.firstEncryptor.setConfig(config); this.config = config; }
/** * <p> * Sets a <tt>{@link org.jasypt.encryption.pbe.config.PBEConfig}</tt> object * for the encryptor. If this config * object is set, it will be asked values for: * </p> * * <ul> * <li>Algorithm</li> * <li>Security Provider (or provider name)</li> * <li>Password</li> * <li>Hashing iterations for obtaining the encryption key</li> * <li>Salt generator</li> * <li>Output type (base64, hexadecimal) * (only <tt>StringPBEConfig</tt>)</li> * </ul> * * <p> * The non-null values it returns will override the default ones, * <i>and will be overriden by any values specified with a <tt>setX</tt> * method</i>. * </p> * * @param config the <tt>PBEConfig</tt> object to be used as the * source for configuration parameters. */ public synchronized void setConfig(final PBEConfig config) { this.firstEncryptor.setConfig(config); this.config = config; }
/** * 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); }
public static void initEncryptorForMigration(final String secretKey) { s_encryptor.setAlgorithm("PBEWithMD5AndDES"); final SimpleStringPBEConfig stringConfig = new SimpleStringPBEConfig(); stringConfig.setPassword(secretKey); s_encryptor.setConfig(stringConfig); s_useEncryption = true; }
@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); }
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; }
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 public Object execute() throws Exception { StandardPBEStringEncryptor enc = new StandardPBEStringEncryptor(); EnvironmentStringPBEConfig env = new EnvironmentStringPBEConfig(); env.setProvider(new BouncyCastleProvider()); env.setProviderName(PROVIDER_NAME); env.setAlgorithm(ALGORITHM); if (encryptionPassword != null) { env.setPassword(encryptionPassword); System.out.println("Specified password for decryption should be set to " + PASSWORD_ENV_NAME + " env variable"); } else { if (System.getenv(PASSWORD_ENV_NAME) != null) { env.setPasswordEnvName(PASSWORD_ENV_NAME); } else { System.out.println(PASSWORD_ENV_NAME + " system variable is not specified. "); System.out.println("Second parameter should be used to specify password."); return null; } } enc.setConfig(env); System.out.println(PropertyValueEncryptionUtils.encrypt(textToEncrypt, enc)); return null; } }
public WSPasswordCallbackHandler(String username, String password) { if(PropertyValueEncryptionUtils.isEncryptedValue(password)) { StandardPBEStringEncryptor enc = new StandardPBEStringEncryptor(); EnvironmentStringPBEConfig env = new EnvironmentStringPBEConfig(); env.setProvider(new BouncyCastleProvider()); env.setProviderName(PROVIDER_NAME); env.setAlgorithm(ALGORITHM); env.setPasswordEnvName(PASSWORD_ENV_NAME); enc.setConfig(env); pass = PropertyValueEncryptionUtils.decrypt(password, enc); } else { pass = password; } user = username; }
public WSPasswordCallbackHandler(String username, String password) { if(PropertyValueEncryptionUtils.isEncryptedValue(password)) { StandardPBEStringEncryptor enc = new StandardPBEStringEncryptor(); EnvironmentStringPBEConfig env = new EnvironmentStringPBEConfig(); env.setProvider(new BouncyCastleProvider()); env.setProviderName(PROVIDER_NAME); env.setAlgorithm(ALGORITHM); env.setPasswordEnvName(PASSWORD_ENV_NAME); enc.setConfig(env); pass = PropertyValueEncryptionUtils.decrypt(password, enc); } else { pass = password; } user = username; }
/** * Description: 解密<br> * * @author 王伟<br> * @taskId <br> * @param algorithm * @param password * @return <br> */ public static String decrypt(String password) { StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); // 加密配置 EnvironmentStringPBEConfig config = new EnvironmentStringPBEConfig(); config.setAlgorithm(ALGORITHM); // 自己在用的时候更改此密码 config.setPassword(SITE_WIDE_SECRET); // 应用配置 encryptor.setConfig(config); // 解密 return encryptor.decrypt(password); }
/** * Description: 可以解密的加密<br> * * @author 王伟<br> * @taskId <br> * @param algorithm * @param password * @return <br> */ public static String encrypt(String password) { // 加密工具 StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); // 加密配置 EnvironmentStringPBEConfig config = new EnvironmentStringPBEConfig(); config.setAlgorithm(ALGORITHM); // 自己在用的时候更改此密码 config.setPassword(SITE_WIDE_SECRET); // 应用配置 encryptor.setConfig(config); // 加密 return encryptor.encrypt(password); }