Reputation: 131
(Camel 2.9.2)
Very simple use case, but I can't seem to find the answer. My code boils down to this:
String user = "user";
String password = "foo&bar";
String uri = "smtp://hostname:25?username=" + user +
"&password=" + password +
"&[email protected]"; // etc. You get the idea
from("seda:queue:myqueue").to(uri);
Camel throws a ResolveEndpointFailedException with "Unknown parameters=[{bar=null}]."
If I try "foo%26bar," I get the same result.
If I try "foo&bar" camel responds with "Unknown parameters=[{amp;bar=null}]."
I tried using URISupport to create the URI. It escapes the & to %26, and then I get "Unknown parameters=[{bar=null}]" again.
Any ideas?
Upvotes: 8
Views: 3770
Reputation: 12070
The RAW()
syntax works, yet it is Camel-proprietary syntax. In our usecase it burdened following processing of URI.
We used alternative solution: component configured as using raw URIs (Component.useRawUri() == true
). Component parameters are then simply once encoded (foo%26bar
) and pass through Camel without change. I consider this solution better as percent-sign encoding is standard way of expressing sensitive characters.
Upvotes: 0
Reputation: 111
As from Camel 2.11 you could use raw syntax
For instance:
.to("ftp:[email protected]?password=RAW(se+re?t&23)&binary=true"
In the above example, we have declare the password value as raw, and the actual password would be as typed, eg se+re?t&23
https://cwiki.apache.org/confluence/display/CAMEL/How+do+I+configure+endpoints
Upvotes: 11
Reputation: 55550
You can specify the password as part of the authority of the uri, eg in the front. Also the & should be escaped to %26, but there was a bug in Camel that didnt parse the escaped value to well. Try 2.10 when its out.
Upvotes: 1