You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by anakin59490 <je...@voila.fr> on 2013/11/29 18:16:46 UTC
set property before starting
Hi,
I wrote this route :
@Component
public class MassPaymentInRoute extends SpringRouteBuilder {
@Value("${user.password}")
String cryptedPwd;
String decryptedPwd;
@Override
public void configure() {
Cipher cs = new Cipher();
try {
decryptedPwd = cs.decrypt(cryptedPwd);
getContext().getProperties().put("*decPwd*", decryptedPwd);
// getContext().
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
.from("{{source.endpoint.1}}")
etc.....
The value {{source.endpoint.1}} is defined in a properties file :
source.endpoint.1=ftp://${user.name}:${properties:{{decPwd}}@xxxxxx//echange/MassPayment/IN/?noop=false&initialDelay=0&idempotent=true&stepwise=false
but when i run it , i get this message :
"Property with key [decPwd] not found in properties from text"
I also try to use the function decrypt directly in the properties file, like
this :
source.endpoint.1=ftp://${user.name}:#{cipher.decrypt('${user.password}')}@xxxxxx//echange/MassPayment/IN/?noop=false&initialDelay=0&idempotent=true&stepwise=false
cipher is defined in the camel context
but it doesn't work...
What is the best way to get my password decrypted ?
thank's in advance
--
View this message in context: http://camel.465427.n5.nabble.com/set-property-before-starting-tp5744088.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: set property before starting
Posted by Claus Ibsen <cl...@gmail.com>.
Yes %s is a replacer in the String.format method. See the javadoc of
how that works.
Its expected to not be possible to use in a .properties file. You
still need to use fromF("url", password) and pass in the decryped
password as the 2nd parameter.
fromF is using String.format under the covers.
On Mon, Dec 2, 2013 at 12:08 PM, anakin59490 <je...@voila.fr> wrote:
> Hi,
>
> It doesn't work by using properties file, this is what i tried :
>
> In my route,
>
> fromF("ftp://{{user.name}}:%s@xxxxxx//echange/MassPayment/IN/?noop=false&initialDelay=0&idempotent=true&stepwise=false",
> decryptedPwd) --> OK, it works !
>
> but if i use my properties file :
>
> fromF("{{source.endpoint.1}}", decryptedPwd) in my route, with from my
> properties file,
> source.endpoint.1=ftp://${user.name}:%s@xxxxxx//echange/MassPayment/IN/?noop=false&initialDelay=0&idempotent=true&stepwise=false
> it doesn't work,
>
> it's as if %s is just text, not the decryptedPwd value
>
> I try with :
>
> source.endpoint.1=ftp://${user.name}:{{%s}}@xxxxxx//echange/MassPayment/IN/?noop=false&initialDelay=0&idempotent=true&stepwise=false
>
> or
>
> source.endpoint.1=ftp://${user.name}:$simple{%s}@xxxxxx//echange/MassPayment/IN/?noop=false&initialDelay=0&idempotent=true&stepwise=false
>
>
> but it doesn't work
>
>
> Thank's for your help
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/set-property-before-starting-tp5744088p5744177.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Re: set property before starting
Posted by anakin59490 <je...@voila.fr>.
Hi,
It doesn't work by using properties file, this is what i tried :
In my route,
fromF("ftp://{{user.name}}:%s@xxxxxx//echange/MassPayment/IN/?noop=false&initialDelay=0&idempotent=true&stepwise=false",
decryptedPwd) --> OK, it works !
but if i use my properties file :
fromF("{{source.endpoint.1}}", decryptedPwd) in my route, with from my
properties file,
source.endpoint.1=ftp://${user.name}:%s@xxxxxx//echange/MassPayment/IN/?noop=false&initialDelay=0&idempotent=true&stepwise=false
it doesn't work,
it's as if %s is just text, not the decryptedPwd value
I try with :
source.endpoint.1=ftp://${user.name}:{{%s}}@xxxxxx//echange/MassPayment/IN/?noop=false&initialDelay=0&idempotent=true&stepwise=false
or
source.endpoint.1=ftp://${user.name}:$simple{%s}@xxxxxx//echange/MassPayment/IN/?noop=false&initialDelay=0&idempotent=true&stepwise=false
but it doesn't work
Thank's for your help
--
View this message in context: http://camel.465427.n5.nabble.com/set-property-before-starting-tp5744088p5744177.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: set property before starting
Posted by Claus Ibsen <cl...@gmail.com>.
The Camel property placeholder / component
http://camel.apache.org/using-propertyplaceholder.html
is not the same as context.getProperties. The latter is seldom used
but allows configuring arbitrary options that can be retrieved from
the context. Though there is only a few options usually to set some
logging restrictions or max cache sizes on templates.
As its just java code, then you can just use string concat to set the
decrypted password.
For example you can use String.format placeholders, and have %s in the uri
source.endpoint.1=ftp://${user.name}:%s@xxxxxx//echange/MassPayment/IN/?noop=false&initialDelay=0&idempotent=true&stepwise=false
And then use fromF to pass in the password
.fromF("{{source.endpoint.1}}", decryptedPwd);
On Fri, Nov 29, 2013 at 6:16 PM, anakin59490 <je...@voila.fr> wrote:
> Hi,
>
> I wrote this route :
>
> @Component
> public class MassPaymentInRoute extends SpringRouteBuilder {
> @Value("${user.password}")
> String cryptedPwd;
>
> String decryptedPwd;
>
> @Override
> public void configure() {
>
>
> Cipher cs = new Cipher();
> try {
> decryptedPwd = cs.decrypt(cryptedPwd);
> getContext().getProperties().put("*decPwd*", decryptedPwd);
>
> // getContext().
> } catch (Exception e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
>
> .from("{{source.endpoint.1}}")
> etc.....
>
>
> The value {{source.endpoint.1}} is defined in a properties file :
>
> source.endpoint.1=ftp://${user.name}:${properties:{{decPwd}}@xxxxxx//echange/MassPayment/IN/?noop=false&initialDelay=0&idempotent=true&stepwise=false
>
>
>
> but when i run it , i get this message :
> "Property with key [decPwd] not found in properties from text"
>
>
> I also try to use the function decrypt directly in the properties file, like
> this :
> source.endpoint.1=ftp://${user.name}:#{cipher.decrypt('${user.password}')}@xxxxxx//echange/MassPayment/IN/?noop=false&initialDelay=0&idempotent=true&stepwise=false
>
> cipher is defined in the camel context
>
> but it doesn't work...
>
>
> What is the best way to get my password decrypted ?
>
> thank's in advance
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/set-property-before-starting-tp5744088.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen