use of org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig in project karaf by apache.
the class EncryptableConfigAdminPropertyPlaceholderTest method setUp.
@Before
public void setUp() throws Exception {
// Configure Jasypt
enc = new StandardPBEStringEncryptor();
env = new EnvironmentStringPBEConfig();
env.setAlgorithm("PBEWithMD5AndDES");
env.setPassword("password");
enc.setConfig(env);
System.setProperty("org.osgi.framework.storage", "target/osgi/" + System.currentTimeMillis());
System.setProperty("karaf.name", "root");
List<BundleDescriptor> bundles = new ClasspathScanner().scanForBundles("(Bundle-SymbolicName=*)");
bundles.add(getBundleDescriptor("target/jasypt2.jar", bundle().add("OSGI-INF/blueprint/karaf-jaas-jasypt.xml", getClass().getResource("/OSGI-INF/blueprint/karaf-jaas-jasypt.xml")).set("Manifest-Version", "2").set("Bundle-ManifestVersion", "2").set("Bundle-SymbolicName", "jasypt").set("Bundle-Version", "0.0.0")));
bundles.add(getBundleDescriptor("target/test2.jar", bundle().add("OSGI-INF/blueprint/configadmin-test.xml", getClass().getResource("configadmin-test.xml")).set("Manifest-Version", "2").set("Bundle-ManifestVersion", "2").set("Bundle-SymbolicName", "configtest").set("Bundle-Version", "0.0.0")));
Map config = new HashMap();
config.put(PojoServiceRegistryFactory.BUNDLE_DESCRIPTORS, bundles);
PojoServiceRegistry reg = new PojoServiceRegistryFactoryImpl().newPojoServiceRegistry(config);
bundleContext = reg.getBundleContext();
}
use of org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig in project tesb-rt-se by Talend.
the class TextEncryptor method execute.
@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;
}
use of org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig in project karaf by apache.
the class EncryptablePropertyPlaceholderTest method setUp.
@Before
public void setUp() throws Exception {
StandardPBEStringEncryptor enc = new StandardPBEStringEncryptor();
EnvironmentStringPBEConfig env = new EnvironmentStringPBEConfig();
env.setAlgorithm("PBEWithMD5AndDES");
env.setPassword("password");
enc.setConfig(env);
String val = enc.encrypt("bar");
System.setProperty("foo", val);
System.setProperty("org.bundles.framework.storage", "target/bundles/" + System.currentTimeMillis());
System.setProperty("karaf.name", "root");
List<BundleDescriptor> bundles = new ClasspathScanner().scanForBundles("(Bundle-SymbolicName=*)");
bundles.add(getBundleDescriptor("target/jasypt.jar", bundle().add("OSGI-INF/blueprint/karaf-jaas-jasypt.xml", getClass().getResource("/OSGI-INF/blueprint/karaf-jaas-jasypt.xml")).set("Manifest-Version", "2").set("Bundle-ManifestVersion", "2").set("Bundle-SymbolicName", "jasypt").set("Bundle-Version", "0.0.0")));
bundles.add(getBundleDescriptor("target/test.jar", bundle().add("OSGI-INF/blueprint/test.xml", getClass().getResource("test.xml")).set("Manifest-Version", "2").set("Bundle-ManifestVersion", "2").set("Bundle-SymbolicName", "test").set("Bundle-Version", "0.0.0")));
Map config = new HashMap();
config.put(PojoServiceRegistryFactory.BUNDLE_DESCRIPTORS, bundles);
PojoServiceRegistry reg = new PojoServiceRegistryFactoryImpl().newPojoServiceRegistry(config);
bundleContext = reg.getBundleContext();
}
use of org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig in project tesb-rt-se by Talend.
the class WSPasswordCallbackHandlerTest method getEncryptor.
private StandardPBEStringEncryptor getEncryptor() throws Exception {
StandardPBEStringEncryptor enc = new StandardPBEStringEncryptor();
EnvironmentStringPBEConfig env = new EnvironmentStringPBEConfig();
env.setProvider(new BouncyCastleProvider());
env.setProviderName(PROVIDER_NAME);
env.setAlgorithm(ALGORITHM);
env.setPassword("pwd");
enc.setConfig(env);
return enc;
}
use of org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig in project tesb-rt-se by Talend.
the class Configuration method setProperties.
/**
* Back this <code>Configuration</code> by the given properties from ConfigurationAdmin.
*
* @param properties the properties from ConfigurationAdmin, may be <code>null</code>.
* @throws ConfigurationException thrown if the property values are not of type String
*/
public void setProperties(Dictionary<?, ?> properties) throws ConfigurationException {
List<String> newArgumentList = new ArrayList<String>();
if (properties != null) {
for (Enumeration<?> keysEnum = properties.keys(); keysEnum.hasMoreElements(); ) {
String key = (String) keysEnum.nextElement();
Object val = properties.get(key);
if (val instanceof String) {
String value = (String) val;
if (PropertyValueEncryptionUtils.isEncryptedValue(value)) {
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);
val = PropertyValueEncryptionUtils.decrypt(value, enc);
}
String strval = convertArgument(key, (String) val);
if (strval != null) {
newArgumentList.add(strval);
}
} else {
throw new ConfigurationException(key, "Value is not of type String.");
}
}
}
argumentList = newArgumentList;
configAvailable.countDown();
}
Aggregations