djb
djb

Reputation: 1674

camel escaping special characters from property file

I've got a password in a property file

com.password=$&m

It is being inserted into an sftp camel route with {{com.password}} and I'm getting "Unknown parameters=[{m=}]"

& is being interpreted incorrectly. I've tried a few things, and can't find anything in the docs. What do I do to make it use the password verbatim?

EDIT:

<cm:property-placeholder id="blueprint.placeholder" persistent-id="com.props" >
</cm:property-placeholder>

ROUTE:

<camel:route id="uploadqueue">  
    <camel:from uri="file://{{com.dir}}/?antInclude=*.xml&amp;delay=10000&amp;move=processed/${file:name}&amp;moveFailed=error/${file:name}" />
    <camel:to uri="log:input?showAll=true&amp;level=INFO"/>
    <camel:to uri="sftp://192.168.0.1/?username={{com.user}}&amp;password={{com.password}}" />
</camel:route>

EDIT: Route now:

 <camel:to uri="sftp://192.168.0.1/?username={{com.user}}&amp;password=RAW({{com.password}})" />

Stacktrace. Slightly edited for confidentiality, but basically this. Password of $&m is interpreted as the HTML (%24) for $, as the password, & as the semantic ampersand, and m as a new parameter. i.e. RAW() did nothing.

Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: sftp://192.168.0.1/?password=%24&m=&username=USERNAME due to: There are 1 parameters that couldn't be set on the endpoint. Check the uri if the parameters are spelt correctly and that they are properties of the endpoint. Unknown parameters=[{m=}]
    at org.apache.camel.impl.DefaultComponent.validateParameters(DefaultComponent.java:215) ~[?:?]
    at org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:139) ~[?:?]
    at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:711) ~[?:?]
    at org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:80) ~[?:?]
    at org.apache.camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.java:219) ~[?:?]
    at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:115) ~[?:?]
    at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:121) ~[?:?]
    at org.apache.camel.model.SendDefinition.resolveEndpoint(SendDefinition.java:62) ~[?:?]
    at org.apache.camel.model.SendDefinition.createProcessor(SendDefinition.java:56) ~[?:?]
    at org.apache.camel.model.ProcessorDefinition.makeProcessorImpl(ProcessorDefinition.java:562) ~[?:?]
    at org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:523) ~[?:?]
    at org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:239) ~[?:?]
    at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1300) ~[?:?]
    ... 26 more

Upvotes: 0

Views: 2525

Answers (1)

pvpkiran
pvpkiran

Reputation: 27048

According to the documentation this should work.

<camel:to uri="sftp://192.168.0.1/?username={{com.user}}&amp;password=RAW({{com.password}})"

Upvotes: 2

Related Questions