Checkstyle fix. Formatting in javadoc. Moved public methods to the top.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/fee22c85 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/fee22c85 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/fee22c85 Branch: refs/heads/master Commit: fee22c855938cf07d9eb77a25fc73acb9b8f6f5b Parents: d74fe42 Author: Marius Thøring <mthor...@gmail.com> Authored: Fri Dec 26 18:53:19 2014 +0100 Committer: Claus Ibsen <davscl...@apache.org> Committed: Tue Dec 30 11:47:30 2014 +0100 ---------------------------------------------------------------------- .../jasypt/JasyptPropertiesParser.java | 34 +++++++++----------- 1 file changed, 16 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/fee22c85/components/camel-jasypt/src/main/java/org/apache/camel/component/jasypt/JasyptPropertiesParser.java ---------------------------------------------------------------------- diff --git a/components/camel-jasypt/src/main/java/org/apache/camel/component/jasypt/JasyptPropertiesParser.java b/components/camel-jasypt/src/main/java/org/apache/camel/component/jasypt/JasyptPropertiesParser.java index e0e40fc..c39d086 100755 --- a/components/camel-jasypt/src/main/java/org/apache/camel/component/jasypt/JasyptPropertiesParser.java +++ b/components/camel-jasypt/src/main/java/org/apache/camel/component/jasypt/JasyptPropertiesParser.java @@ -16,12 +16,12 @@ */ package org.apache.camel.component.jasypt; -import static java.lang.String.format; - import java.util.Properties; import java.util.regex.Matcher; import java.util.regex.Pattern; +import static java.lang.String.format; + import org.apache.camel.component.properties.DefaultPropertiesParser; import org.apache.camel.util.ObjectHelper; import org.jasypt.encryption.StringEncryptor; @@ -29,11 +29,9 @@ import org.jasypt.encryption.pbe.StandardPBEStringEncryptor; /** * A {@link org.apache.camel.component.properties.PropertiesParser} which is using - * <a href="http://www.jasypt.org/">Jasypt</a> to decrypt any encrypted values. + * <a href="http://www.jasypt.org/">Jasypt</a> to decrypt encrypted values. * <p/> * The parts of the values which should be decrpted must be enclosed in the prefix and suffix token. - * - * @version */ public class JasyptPropertiesParser extends DefaultPropertiesParser { @@ -51,6 +49,19 @@ public class JasyptPropertiesParser extends DefaultPropertiesParser { pattern = Pattern.compile(regex); } + @Override + public String parseProperty(String key, String value, Properties properties) { + log.trace(format("Parsing property '%s=%s'", key, value)); + initEncryptor(); + Matcher matcher = pattern.matcher(value); + while (matcher.find()) { + log.trace(format("Decrypting part '%s'", matcher.group(0))); + String decrypted = encryptor.decrypt(matcher.group(1)); + value = value.replace(matcher.group(0), decrypted); + } + return value; + } + private synchronized void initEncryptor() { if (encryptor == null) { ObjectHelper.notEmpty("password", password); @@ -66,19 +77,6 @@ public class JasyptPropertiesParser extends DefaultPropertiesParser { } } - @Override - public String parseProperty(String key, String value, Properties properties) { - log.trace(format("Parsing property '%s=%s'", key, value)); - initEncryptor(); - Matcher matcher = pattern.matcher(value); - while (matcher.find()) { - log.trace(format("Decrypting part '%s'", matcher.group(0))); - String decrypted = encryptor.decrypt(matcher.group(1)); - value = value.replace(matcher.group(0), decrypted); - } - return value; - } - public void setEncryptor(StringEncryptor encryptor) { this.encryptor = encryptor; }