use of org.jasypt.encryption.pbe.StandardPBEStringEncryptor in project divide by HiddenStage.
the class AuthTokenUtils method encrypt.
private static String encrypt(String string, String key) {
StandardPBEStringEncryptor encryptor = getEncryptor(key);
String encrypted = encryptor.encrypt(string);
return Base64.encode(encrypted);
}
use of org.jasypt.encryption.pbe.StandardPBEStringEncryptor in project divide by HiddenStage.
the class AuthTokenUtils method getEncryptor.
private static StandardPBEStringEncryptor getEncryptor(String key) {
StandardPBEStringEncryptor encryptor;
if (encryptors.containsKey(key))
encryptor = encryptors.get(key);
else {
encryptor = new StandardPBEStringEncryptor();
encryptor.setPassword(key);
}
return encryptor;
}
use of org.jasypt.encryption.pbe.StandardPBEStringEncryptor in project CloudStack-archive by CloudStack-extras.
the class DBEncryptionUtil method initialize.
private static void initialize() {
final File dbPropsFile = PropertiesUtil.findConfigFile("db.properties");
final Properties dbProps;
if (EncryptionSecretKeyChecker.useEncryption()) {
StandardPBEStringEncryptor encryptor = EncryptionSecretKeyChecker.getEncryptor();
dbProps = new EncryptableProperties(encryptor);
try {
dbProps.load(new FileInputStream(dbPropsFile));
} catch (FileNotFoundException e) {
throw new CloudRuntimeException("db.properties file not found while reading DB secret key", e);
} catch (IOException e) {
throw new CloudRuntimeException("Erroe while reading DB secret key from db.properties", e);
}
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");
}
}
use of org.jasypt.encryption.pbe.StandardPBEStringEncryptor in project CloudStack-archive by CloudStack-extras.
the class EncryptionSecretKeyChanger method migrateProperties.
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;
}
use of org.jasypt.encryption.pbe.StandardPBEStringEncryptor in project fb-botmill by BotMill.
the class AnnotatedTemplateTest method main.
public static void main(String[] args) {
StandardPBEStringEncryptor enc = new StandardPBEStringEncryptor();
// can be sourced out
enc.setPassword("password");
ConfigurationUtils.loadEncryptedConfigurationFile(enc, "botmill.properties");
List<BotDefinition> botDef = new ArrayList<BotDefinition>();
botDef.add(new AnnotatedTemplatedBehaviourTest());
ConfigurationUtils.loadBotConfig();
ConfigurationUtils.setBotDefinitionInstance(botDef);
for (int i = 0; i < 10; i++) {
new Thread(new Runnable() {
String json = "{\"sender\":{\"id\":\"1158621824216736\"},\"recipient\":{\"id\":\"1226565047419159\"},\"timestamp\":1490832021661,\"message\":{\"mid\":\"mid.$cAAUPCFn4ymdhTcignVbHH3rzpKd_\",\"seq\":844819,\"text\":\"Hi!\"}}";
MessageEnvelope envelope = FbBotMillJsonUtils.fromJson(json, MessageEnvelope.class);
@Override
public void run() {
try {
IncomingToOutgoingMessageHandler.getInstance().process(envelope);
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
}
}
Aggregations