com.mozu.encryptor.PropertyEncryptionUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mozu-java-security Show documentation
Show all versions of mozu-java-security Show documentation
Mozu Java Security is an add=on library to provide security helper functions for applications using Mozu
package com.mozu.encryptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class PropertyEncryptionUtil {
private static final Logger logger = LoggerFactory.getLogger(PropertyEncryptionUtil.class);
/**
* Encrypt a Property Value
* @param key the salt key to use for the property.
* @param property the clear text tp encrypt
* @return an encrypted value for the text
*/
public static String encryptProperty(String key, String property) {
String encryptedProperty = null;
try {
encryptedProperty = EncryptionUtil.encrypt(key, property);
} catch (Exception e) {
StringBuilder msg = new StringBuilder().append("Unable to encrypt property: ").append(e.getMessage());
logger.error (msg.toString());
}
return encryptedProperty;
}
public static String decryptProperty (String key, String property) {
String decryptedProperty = null;
try {
decryptedProperty = EncryptionUtil.decrypt(key, property);
} catch (Exception e) {
StringBuilder msg = new StringBuilder().append("Unable to decrypt property: ").append(e.getMessage());
logger.warn (msg.toString());
// go ahead and return the property because it probably wasn't encrypted in the first place.
decryptedProperty = property;
}
return decryptedProperty;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy