Hi All, while tracing the log I could see inside the below
JasyptPropertiesParser.class => log.trace("Decrypting property {}", text)
in the logs than camel stops and throws nullpointerexception .
Any suggestion ?
===================================================================
package org.apache.camel.component.jasypt;
import java.util.Properties;
import org.apache.camel.component.properties.DefaultPropertiesParser;
import org.apache.camel.util.ObjectHelper;
import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;
/**
* A {@link org.apache.camel.component.properties.PropertiesParser} which is
using
* Jasypt <http://www.jasypt.org/> to decrypt any encrypted values.
* <p/>
* The values must be enclosed in the prefix and suffix token.
*
* @version
*/
public class JasyptPropertiesParser extends DefaultPropertiesParser {
public static final String JASYPT_PREFIX_TOKEN = "ENC(";
public static final String JASYPT_SUFFIX_TOKEN = ")";
private StandardPBEStringEncryptor encryptor;
private String password;
private String algorithm;
public String getPassword() {
return password;
}
public void setPassword(String password) {
// lookup password as either environment or JVM system property
if (password.startsWith("sysenv:")) {
password = System.getenv(ObjectHelper.after(password,
"sysenv:"));
}
if (password.startsWith("sys:")) {
password = System.getProperty(ObjectHelper.after(password,
"sys:"));
}
this.password = password;
}
public String getAlgorithm() {
return algorithm;
}
public void setAlgorithm(String algorithm) {
this.algorithm = algorithm;
}
public synchronized StandardPBEStringEncryptor getEncryptor() {
if (encryptor == null) {
// password is mandatory
ObjectHelper.notEmpty("password", getPassword());
encryptor = new StandardPBEStringEncryptor();
encryptor.setPassword(getPassword());
if (algorithm != null) {
encryptor.setAlgorithm(getAlgorithm());
}
}
return encryptor;
}
@Override
public String parseProperty(String key, String value, Properties
properties) {
// check if the value is using the tokens
String text = ObjectHelper.between(value, JASYPT_PREFIX_TOKEN,
JASYPT_SUFFIX_TOKEN);
if (text == null) {
// not encrypted
log.trace("Property is not encrypted {}", text);
return value;
} else {
log.trace("Decrypting property {}", text);
// do not log the decrypted text as it could be sensitive
information such as a password
return getEncryptor().decrypt(text);
}
}
}
--
View this message in context:
http://camel.465427.n5.nabble.com/Problem-encrypting-the-password-using-Camel-Jasypt-component-tp5753644p5754740.html
Sent from the Camel - Users mailing list archive at Nabble.com.