You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2020/05/05 19:12:25 UTC
[camel] branch camel-2.25.x updated (6ee19c1 -> 1843dad)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a change to branch camel-2.25.x
in repository https://gitbox.apache.org/repos/asf/camel.git.
from 6ee19c1 Regen
new f46aeb5 CAMEL-15013: Template components - Add option to turn on|off allow using header with override template
new 165e704 CAMEL-15013: Template components - Add option to turn on|off allow using header with override template
new 0d1584a CAMEL-15013: Template components - Add option to turn on|off allow using header with override template
new b71d878 CAMEL-15013: Template components - Add option to turn on|off allow using header with override template
new a9bd316 CAMEL-15013: Template components - Add option to turn on|off allow using header with override template
new a2aa495 CAMEL-15013: Template components - Add option to turn on|off allow using header with override template
new ef2d2b1 CAMEL-15013: Template components - Add option to turn on|off allow using header with override template
new 1843dad CAMEL-15013: Regen
The 8 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../camel-chunk/src/main/docs/chunk-component.adoc | 19 ++++--
.../camel/component/chunk/ChunkComponent.java | 20 ++++++
.../camel/component/chunk/ChunkEndpoint.java | 29 ++++++++-
.../chunk/ChunkComponentTemplateTest.java | 2 +-
.../src/main/docs/freemarker-component.adoc | 9 ++-
.../component/freemarker/FreemarkerComponent.java | 19 ++++++
.../component/freemarker/FreemarkerEndpoint.java | 42 ++++++++++---
.../freemarker/FreemarkerEndpointTest.java | 1 +
...Test.java => FreemarkerOverrideHeaderTest.java} | 55 +++++++++++------
.../freemarker/FreemarkerTemplateInHeaderTest.java | 2 +-
.../camel/component/freemarker/FreemarkerTest.java | 2 +-
.../FreemarkerValuesInPropertiesTest.java | 3 +
.../camel-jolt/src/main/docs/jolt-component.adoc | 9 ++-
.../apache/camel/component/jolt/JoltComponent.java | 18 ++++++
.../apache/camel/component/jolt/JoltEndpoint.java | 31 ++++++++--
.../camel/component/jolt/JoltFirstSampleTest.java | 3 +
.../src/main/docs/mustache-component.adoc | 9 ++-
.../component/mustache/MustacheComponent.java | 18 ++++++
.../camel/component/mustache/MustacheEndpoint.java | 71 ++++++++++++++--------
.../component/mustache/MustacheComponentTest.java | 3 +
.../camel-mvel/src/main/docs/mvel-component.adoc | 17 +++++-
.../camel-mvel/src/main/docs/mvel-language.adoc | 5 +-
.../apache/camel/component/mvel/MvelComponent.java | 22 ++++++-
.../apache/camel/component/mvel/MvelEndpoint.java | 38 +++++++++---
.../camel/language/mvel/MvelComponentTest.java | 7 ++-
.../src/main/docs/string-template-component.adoc | 19 ++++--
.../stringtemplate/StringTemplateComponent.java | 21 +++++++
.../stringtemplate/StringTemplateEndpoint.java | 23 ++++++-
.../stringtemplate/StringTemplateTest.java | 29 ++++-----
.../src/main/docs/velocity-component.adoc | 9 ++-
.../component/velocity/VelocityComponent.java | 21 ++++++-
.../camel/component/velocity/VelocityEndpoint.java | 56 +++++++++++------
.../component/velocity/VelocityEndpointTest.java | 1 +
.../velocity/VelocitySetTemplateViaHeaderTest.java | 2 +-
.../velocity/VelocitySupplementalContextTest.java | 2 +-
.../velocity/VelocityTemplateInHeaderTest.java | 3 +
.../camel/component/velocity/VelocityTest.java | 2 +-
.../velocity/VelocityValuesInPropertiesTest.java | 2 +-
.../modules/ROOT/pages/chunk-component.adoc | 19 ++++--
.../modules/ROOT/pages/freemarker-component.adoc | 9 ++-
.../modules/ROOT/pages/jolt-component.adoc | 9 ++-
.../modules/ROOT/pages/mustache-component.adoc | 9 ++-
.../modules/ROOT/pages/mvel-component.adoc | 17 +++++-
.../modules/ROOT/pages/mvel-language.adoc | 5 +-
.../ROOT/pages/string-template-component.adoc | 19 ++++--
.../modules/ROOT/pages/velocity-component.adoc | 9 ++-
.../springboot/ChunkComponentConfiguration.java | 15 +++++
.../FreemarkerComponentConfiguration.java | 15 +++++
.../springboot/JoltComponentConfiguration.java | 15 +++++
.../springboot/MustacheComponentConfiguration.java | 15 +++++
.../springboot/MvelComponentConfiguration.java | 15 +++++
.../StringTemplateComponentConfiguration.java | 15 +++++
.../springboot/VelocityComponentConfiguration.java | 15 +++++
53 files changed, 682 insertions(+), 163 deletions(-)
copy components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/{FreemarkerLetterTest.java => FreemarkerOverrideHeaderTest.java} (64%)
[camel] 05/08: CAMEL-15013: Template components - Add option to
turn on|off allow using header with override template
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-2.25.x
in repository https://gitbox.apache.org/repos/asf/camel.git
commit a9bd316799d0ec43f5a75eb7d106dbc26dfba8d8
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue May 5 17:57:52 2020 +0200
CAMEL-15013: Template components - Add option to turn on|off allow using header with override template
---
.../stringtemplate/StringTemplateComponent.java | 21 ++++++++++++++++
.../stringtemplate/StringTemplateEndpoint.java | 23 ++++++++++++++---
.../stringtemplate/StringTemplateTest.java | 29 ++++++++++------------
3 files changed, 54 insertions(+), 19 deletions(-)
diff --git a/components/camel-stringtemplate/src/main/java/org/apache/camel/component/stringtemplate/StringTemplateComponent.java b/components/camel-stringtemplate/src/main/java/org/apache/camel/component/stringtemplate/StringTemplateComponent.java
index e6d3631..dace9fd 100644
--- a/components/camel-stringtemplate/src/main/java/org/apache/camel/component/stringtemplate/StringTemplateComponent.java
+++ b/components/camel-stringtemplate/src/main/java/org/apache/camel/component/stringtemplate/StringTemplateComponent.java
@@ -21,18 +21,23 @@ import java.util.Map;
import org.apache.camel.Endpoint;
import org.apache.camel.impl.UriEndpointComponent;
import org.apache.camel.util.ResourceHelper;
+import org.apache.camel.spi.Metadata;
/**
* @version
*/
public class StringTemplateComponent extends UriEndpointComponent {
+ @Metadata(defaultValue = "false")
+ private boolean allowTemplateFromHeader;
+
public StringTemplateComponent() {
super(StringTemplateEndpoint.class);
}
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
StringTemplateEndpoint answer = new StringTemplateEndpoint(uri, this, remaining);
+ answer.setAllowTemplateFromHeader(allowTemplateFromHeader);
setProperties(answer, parameters);
// if its a http resource then append any remaining parameters and update the resource uri
@@ -43,4 +48,20 @@ public class StringTemplateComponent extends UriEndpointComponent {
return answer;
}
+
+ public boolean isAllowTemplateFromHeader() {
+ return allowTemplateFromHeader;
+ }
+
+ /**
+ * Whether to allow to use resource template from header or not (default false).
+ *
+ * Enabling this allows to specify dynamic templates via message header. However this can
+ * be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care.
+ */
+ public void setAllowTemplateFromHeader(boolean allowTemplateFromHeader) {
+ this.allowTemplateFromHeader = allowTemplateFromHeader;
+ }
+
+
}
\ No newline at end of file
diff --git a/components/camel-stringtemplate/src/main/java/org/apache/camel/component/stringtemplate/StringTemplateEndpoint.java b/components/camel-stringtemplate/src/main/java/org/apache/camel/component/stringtemplate/StringTemplateEndpoint.java
index 03f1570..1f4696e 100644
--- a/components/camel-stringtemplate/src/main/java/org/apache/camel/component/stringtemplate/StringTemplateEndpoint.java
+++ b/components/camel-stringtemplate/src/main/java/org/apache/camel/component/stringtemplate/StringTemplateEndpoint.java
@@ -37,6 +37,8 @@ import org.stringtemplate.v4.STGroup;
@UriEndpoint(firstVersion = "1.2.0", scheme = "string-template", title = "String Template", syntax = "string-template:resourceUri", producerOnly = true, label = "transformation")
public class StringTemplateEndpoint extends ResourceEndpoint {
+ @UriParam(defaultValue = "false")
+ private boolean allowTemplateFromHeader;
@UriParam(defaultValue = "<")
private char delimiterStart = STGroup.defaultGroup.delimiterStartChar;
@UriParam(defaultValue = ">")
@@ -81,12 +83,27 @@ public class StringTemplateEndpoint extends ResourceEndpoint {
this.delimiterStop = delimiterStop;
}
+ public boolean isAllowTemplateFromHeader() {
+ return allowTemplateFromHeader;
+ }
+
+ /**
+ * Whether to allow to use resource template from header or not (default false).
+ *
+ * Enabling this allows to specify dynamic templates via message header. However this can
+ * be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care.
+ */
+ public void setAllowTemplateFromHeader(boolean allowTemplateFromHeader) {
+ this.allowTemplateFromHeader = allowTemplateFromHeader;
+ }
+
@Override
protected void onExchange(Exchange exchange) throws Exception {
StringWriter buffer = new StringWriter();
-
- @SuppressWarnings("unchecked")
- Map<String, Object> variableMap = exchange.getIn().getHeader(StringTemplateConstants.STRINGTEMPLATE_VARIABLE_MAP, Map.class);
+ Map<String, Object> variableMap = null;
+ if (allowTemplateFromHeader) {
+ variableMap = exchange.getIn().getHeader(StringTemplateConstants.STRINGTEMPLATE_VARIABLE_MAP, Map.class);
+ }
if (variableMap == null) {
variableMap = ExchangeHelper.createVariableMap(exchange);
}
diff --git a/components/camel-stringtemplate/src/test/java/org/apache/camel/component/stringtemplate/StringTemplateTest.java b/components/camel-stringtemplate/src/test/java/org/apache/camel/component/stringtemplate/StringTemplateTest.java
index e1be0a5..20bbd47 100644
--- a/components/camel-stringtemplate/src/test/java/org/apache/camel/component/stringtemplate/StringTemplateTest.java
+++ b/components/camel-stringtemplate/src/test/java/org/apache/camel/component/stringtemplate/StringTemplateTest.java
@@ -49,21 +49,18 @@ public class StringTemplateTest extends CamelTestSupport {
}
@Test
- public void testVelocityContext() throws Exception {
- Exchange exchange = template.request("direct:a", new Processor() {
- @Override
- public void process(Exchange exchange) throws Exception {
- exchange.getIn().setBody("");
- exchange.getIn().setHeader("name", "Christian");
- Map<String, Object> variableMap = new HashMap<>();
- Map<String, Object> headersMap = new HashMap<>();
- headersMap.put("name", "Willem");
- variableMap.put("headers", headersMap);
- variableMap.put("body", "Monday");
- variableMap.put("exchange", exchange);
- exchange.getIn().setHeader(StringTemplateConstants.STRINGTEMPLATE_VARIABLE_MAP, variableMap);
- exchange.setProperty("item", "7");
- }
+ public void testVariableMap() throws Exception {
+ Exchange exchange = template.request("direct:a", exchange1 -> {
+ exchange1.getIn().setBody("");
+ exchange1.getIn().setHeader("name", "Christian");
+ Map<String, Object> variableMap = new HashMap<>();
+ Map<String, Object> headersMap = new HashMap<>();
+ headersMap.put("name", "Willem");
+ variableMap.put("headers", headersMap);
+ variableMap.put("body", "Monday");
+ variableMap.put("exchange", exchange1);
+ exchange1.getIn().setHeader(StringTemplateConstants.STRINGTEMPLATE_VARIABLE_MAP, variableMap);
+ exchange1.setProperty("item", "7");
});
assertEquals("Dear Willem. You ordered item 7 on Monday.", exchange.getOut().getBody());
@@ -75,7 +72,7 @@ public class StringTemplateTest extends CamelTestSupport {
public void configure() {
// START SNIPPET: example
from("direct:a").
- to("string-template:org/apache/camel/component/stringtemplate/template.tm");
+ to("string-template:org/apache/camel/component/stringtemplate/template.tm?allowTemplateFromHeader=true");
// END SNIPPET: example
}
};
[camel] 03/08: CAMEL-15013: Template components - Add option to
turn on|off allow using header with override template
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-2.25.x
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 0d1584af9ebd0673de8778c61f9694b2d28bd38c
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue May 5 15:48:29 2020 +0200
CAMEL-15013: Template components - Add option to turn on|off allow using header with override template
---
.../apache/camel/component/mvel/MvelComponent.java | 22 ++++++++++++-
.../apache/camel/component/mvel/MvelEndpoint.java | 38 +++++++++++++++++-----
.../camel/language/mvel/MvelComponentTest.java | 7 ++--
3 files changed, 56 insertions(+), 11 deletions(-)
diff --git a/components/camel-mvel/src/main/java/org/apache/camel/component/mvel/MvelComponent.java b/components/camel-mvel/src/main/java/org/apache/camel/component/mvel/MvelComponent.java
index 5ac1cb6..53eb41d 100644
--- a/components/camel-mvel/src/main/java/org/apache/camel/component/mvel/MvelComponent.java
+++ b/components/camel-mvel/src/main/java/org/apache/camel/component/mvel/MvelComponent.java
@@ -21,6 +21,7 @@ import java.util.Map;
import org.apache.camel.Endpoint;
import org.apache.camel.impl.UriEndpointComponent;
import org.apache.camel.util.ResourceHelper;
+import org.apache.camel.spi.Metadata;
/**
* An <a href="http://camel.apache.org/mvel.html">Mvel Component</a>
@@ -28,6 +29,9 @@ import org.apache.camel.util.ResourceHelper;
*/
public class MvelComponent extends UriEndpointComponent {
+ @Metadata(defaultValue = "false")
+ private boolean allowTemplateFromHeader;
+
public MvelComponent() {
super(MvelEndpoint.class);
}
@@ -36,8 +40,10 @@ public class MvelComponent extends UriEndpointComponent {
boolean cache = getAndRemoveParameter(parameters, "contentCache", Boolean.class, Boolean.TRUE);
MvelEndpoint answer = new MvelEndpoint(uri, this, remaining);
- setProperties(answer, parameters);
answer.setContentCache(cache);
+ answer.setAllowTemplateFromHeader(allowTemplateFromHeader);
+
+ setProperties(answer, parameters);
// if its a http resource then append any remaining parameters and update the resource uri
if (ResourceHelper.isHttpUri(remaining)) {
@@ -48,4 +54,18 @@ public class MvelComponent extends UriEndpointComponent {
return answer;
}
+ public boolean isAllowTemplateFromHeader() {
+ return allowTemplateFromHeader;
+ }
+
+ /**
+ * Whether to allow to use resource template from header or not (default false).
+ *
+ * Enabling this allows to specify dynamic templates via message header. However this can
+ * be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care.
+ */
+ public void setAllowTemplateFromHeader(boolean allowTemplateFromHeader) {
+ this.allowTemplateFromHeader = allowTemplateFromHeader;
+ }
+
}
diff --git a/components/camel-mvel/src/main/java/org/apache/camel/component/mvel/MvelEndpoint.java b/components/camel-mvel/src/main/java/org/apache/camel/component/mvel/MvelEndpoint.java
index c82973c..4187413 100644
--- a/components/camel-mvel/src/main/java/org/apache/camel/component/mvel/MvelEndpoint.java
+++ b/components/camel-mvel/src/main/java/org/apache/camel/component/mvel/MvelEndpoint.java
@@ -40,8 +40,11 @@ import org.mvel2.templates.TemplateRuntime;
@UriEndpoint(firstVersion = "2.12.0", scheme = "mvel", title = "MVEL", syntax = "mvel:resourceUri", producerOnly = true, label = "transformation,script")
public class MvelEndpoint extends ResourceEndpoint {
+ @UriParam(defaultValue = "false")
+ private boolean allowTemplateFromHeader;
@UriParam
private String encoding;
+
private volatile String template;
private volatile CompiledTemplate compiled;
@@ -64,6 +67,20 @@ public class MvelEndpoint extends ResourceEndpoint {
return "mvel:" + getResourceUri();
}
+ public boolean isAllowTemplateFromHeader() {
+ return allowTemplateFromHeader;
+ }
+
+ /**
+ * Whether to allow to use resource template from header or not (default false).
+ *
+ * Enabling this allows to specify dynamic templates via message header. However this can
+ * be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care.
+ */
+ public void setAllowTemplateFromHeader(boolean allowTemplateFromHeader) {
+ this.allowTemplateFromHeader = allowTemplateFromHeader;
+ }
+
public String getEncoding() {
return encoding;
}
@@ -80,21 +97,26 @@ public class MvelEndpoint extends ResourceEndpoint {
String path = getResourceUri();
ObjectHelper.notNull(path, "resourceUri");
- String newResourceUri = exchange.getIn().getHeader(MvelConstants.MVEL_RESOURCE_URI, String.class);
- if (newResourceUri != null) {
- exchange.getIn().removeHeader(MvelConstants.MVEL_RESOURCE_URI);
+ if (allowTemplateFromHeader) {
+ String newResourceUri = exchange.getIn().getHeader(MvelConstants.MVEL_RESOURCE_URI, String.class);
+ if (newResourceUri != null) {
+ exchange.getIn().removeHeader(MvelConstants.MVEL_RESOURCE_URI);
- log.debug("{} set to {} creating new endpoint to handle exchange", MvelConstants.MVEL_RESOURCE_URI, newResourceUri);
- MvelEndpoint newEndpoint = findOrCreateEndpoint(getEndpointUri(), newResourceUri);
- newEndpoint.onExchange(exchange);
- return;
+ log.debug("{} set to {} creating new endpoint to handle exchange", MvelConstants.MVEL_RESOURCE_URI, newResourceUri);
+ MvelEndpoint newEndpoint = findOrCreateEndpoint(getEndpointUri(), newResourceUri);
+ newEndpoint.onExchange(exchange);
+ return;
+ }
}
CompiledTemplate compiled;
ParserContext mvelContext = ParserContext.create();
Map<String, Object> variableMap = ExchangeHelper.createVariableMap(exchange);
- String content = exchange.getIn().getHeader(MvelConstants.MVEL_TEMPLATE, String.class);
+ String content = null;
+ if (allowTemplateFromHeader) {
+ content = exchange.getIn().getHeader(MvelConstants.MVEL_TEMPLATE, String.class);
+ }
if (content != null) {
// use content from header
if (log.isDebugEnabled()) {
diff --git a/components/camel-mvel/src/test/java/org/apache/camel/language/mvel/MvelComponentTest.java b/components/camel-mvel/src/test/java/org/apache/camel/language/mvel/MvelComponentTest.java
index 996ae6f..768fecc 100644
--- a/components/camel-mvel/src/test/java/org/apache/camel/language/mvel/MvelComponentTest.java
+++ b/components/camel-mvel/src/test/java/org/apache/camel/language/mvel/MvelComponentTest.java
@@ -41,7 +41,7 @@ public class MvelComponentTest extends CamelTestSupport {
@Test
public void testMvelTemplate() throws Exception {
- Exchange exchange = template.request("direct:a", new Processor() {
+ Exchange exchange = template.request("direct:b", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setBody(7);
@@ -54,7 +54,7 @@ public class MvelComponentTest extends CamelTestSupport {
@Test
public void testMvelUri() throws Exception {
- Exchange exchange = template.request("direct:a", new Processor() {
+ Exchange exchange = template.request("direct:b", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setBody(7);
@@ -71,6 +71,9 @@ public class MvelComponentTest extends CamelTestSupport {
// START SNIPPET: example
from("direct:a").
to("mvel:template.mvel");
+
+ from("direct:b").
+ to("mvel:template.mvel?allowTemplateFromHeader=true");
// END SNIPPET: example
}
};
[camel] 08/08: CAMEL-15013: Regen
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-2.25.x
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 1843dad9ea47a2d00732a213f2fe719192a1a7c1
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue May 5 21:11:57 2020 +0200
CAMEL-15013: Regen
---
.../camel-chunk/src/main/docs/chunk-component.adoc | 19 +++++++++++++++----
.../src/main/docs/freemarker-component.adoc | 9 ++++++---
.../camel-jolt/src/main/docs/jolt-component.adoc | 9 ++++++---
.../src/main/docs/mustache-component.adoc | 9 ++++++---
.../camel-mvel/src/main/docs/mvel-component.adoc | 17 ++++++++++++++---
.../camel-mvel/src/main/docs/mvel-language.adoc | 5 +++--
.../src/main/docs/string-template-component.adoc | 19 +++++++++++++++----
.../src/main/docs/velocity-component.adoc | 9 ++++++---
.../modules/ROOT/pages/chunk-component.adoc | 19 +++++++++++++++----
.../modules/ROOT/pages/freemarker-component.adoc | 9 ++++++---
.../components/modules/ROOT/pages/jolt-component.adoc | 9 ++++++---
.../modules/ROOT/pages/mustache-component.adoc | 9 ++++++---
.../components/modules/ROOT/pages/mvel-component.adoc | 17 ++++++++++++++---
docs/components/modules/ROOT/pages/mvel-language.adoc | 5 +++--
.../modules/ROOT/pages/string-template-component.adoc | 19 +++++++++++++++----
.../modules/ROOT/pages/velocity-component.adoc | 9 ++++++---
.../chunk/springboot/ChunkComponentConfiguration.java | 15 +++++++++++++++
.../springboot/FreemarkerComponentConfiguration.java | 15 +++++++++++++++
.../jolt/springboot/JoltComponentConfiguration.java | 15 +++++++++++++++
.../springboot/MustacheComponentConfiguration.java | 15 +++++++++++++++
.../mvel/springboot/MvelComponentConfiguration.java | 15 +++++++++++++++
.../StringTemplateComponentConfiguration.java | 15 +++++++++++++++
.../springboot/VelocityComponentConfiguration.java | 15 +++++++++++++++
23 files changed, 247 insertions(+), 50 deletions(-)
diff --git a/components/camel-chunk/src/main/docs/chunk-component.adoc b/components/camel-chunk/src/main/docs/chunk-component.adoc
index 72af9f2..8e820d7 100644
--- a/components/camel-chunk/src/main/docs/chunk-component.adoc
+++ b/components/camel-chunk/src/main/docs/chunk-component.adoc
@@ -38,7 +38,16 @@ format, `?option=value&option=value&...`
// component options: START
-The Chunk component has no options.
+The Chunk component supports 2 options, which are listed below.
+
+
+
+[width="100%",cols="2,5,^1,2",options="header"]
+|===
+| Name | Description | Default | Type
+| *allowTemplateFrom Header* (producer) | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | boolean
+| *resolveProperty Placeholders* (advanced) | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | boolean
+|===
// component options: END
@@ -62,12 +71,13 @@ with the following path and query parameters:
|===
-=== Query Parameters (7 parameters):
+=== Query Parameters (8 parameters):
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
+| *allowTemplateFromHeader* (producer) | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | boolean
| *contentCache* (producer) | Sets whether to use resource content cache or not | false | boolean
| *encoding* (producer) | Define the encoding of the body | | String
| *extension* (producer) | Define the file extension of the template | | String
@@ -93,13 +103,14 @@ When using Spring Boot make sure to use the following Maven dependency to have s
----
-The component supports 2 options, which are listed below.
+The component supports 3 options, which are listed below.
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
+| *camel.component.chunk.allow-template-from-header* | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | Boolean
| *camel.component.chunk.enabled* | Enable chunk component | true | Boolean
| *camel.component.chunk.resolve-property-placeholders* | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | Boolean
|===
@@ -212,4 +223,4 @@ Thanks for the order of {$headers.item}.
Regards Camel Riders Bookstore
{$body}
-----------------------------------------------
\ No newline at end of file
+----------------------------------------------
diff --git a/components/camel-freemarker/src/main/docs/freemarker-component.adoc b/components/camel-freemarker/src/main/docs/freemarker-component.adoc
index 9c9656f..90d6443 100644
--- a/components/camel-freemarker/src/main/docs/freemarker-component.adoc
+++ b/components/camel-freemarker/src/main/docs/freemarker-component.adoc
@@ -41,7 +41,7 @@ You can append query options to the URI in the following format,
// component options: START
-The Freemarker component supports 2 options, which are listed below.
+The Freemarker component supports 3 options, which are listed below.
@@ -49,6 +49,7 @@ The Freemarker component supports 2 options, which are listed below.
|===
| Name | Description | Default | Type
| *configuration* (advanced) | To use an existing freemarker.template.Configuration instance as the configuration. | | Configuration
+| *allowTemplateFrom Header* (producer) | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | boolean
| *resolveProperty Placeholders* (advanced) | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | boolean
|===
// component options: END
@@ -76,12 +77,13 @@ with the following path and query parameters:
|===
-=== Query Parameters (5 parameters):
+=== Query Parameters (6 parameters):
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
+| *allowTemplateFromHeader* (producer) | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | boolean
| *configuration* (producer) | Sets the Freemarker configuration to use | | Configuration
| *contentCache* (producer) | Sets whether to use resource content cache or not | false | boolean
| *encoding* (producer) | Sets the encoding to be used for loading the template file. | | String
@@ -105,13 +107,14 @@ When using Spring Boot make sure to use the following Maven dependency to have s
----
-The component supports 3 options, which are listed below.
+The component supports 4 options, which are listed below.
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
+| *camel.component.freemarker.allow-template-from-header* | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | Boolean
| *camel.component.freemarker.configuration* | To use an existing freemarker.template.Configuration instance as the configuration. The option is a freemarker.template.Configuration type. | | String
| *camel.component.freemarker.enabled* | Enable freemarker component | true | Boolean
| *camel.component.freemarker.resolve-property-placeholders* | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | Boolean
diff --git a/components/camel-jolt/src/main/docs/jolt-component.adoc b/components/camel-jolt/src/main/docs/jolt-component.adoc
index 4882ca3..012a5bf 100644
--- a/components/camel-jolt/src/main/docs/jolt-component.adoc
+++ b/components/camel-jolt/src/main/docs/jolt-component.adoc
@@ -43,7 +43,7 @@ format, `?option=value&option=value&...`
// component options: START
-The JOLT component supports 2 options, which are listed below.
+The JOLT component supports 3 options, which are listed below.
@@ -51,6 +51,7 @@ The JOLT component supports 2 options, which are listed below.
|===
| Name | Description | Default | Type
| *transform* (advanced) | Explicitly sets the Transform to use. If not set a Transform specified by the transformDsl will be created | | Transform
+| *allowTemplateFrom Header* (producer) | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | boolean
| *resolveProperty Placeholders* (advanced) | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | boolean
|===
// component options: END
@@ -79,12 +80,13 @@ with the following path and query parameters:
|===
-=== Query Parameters (5 parameters):
+=== Query Parameters (6 parameters):
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
+| *allowTemplateFromHeader* (producer) | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | boolean
| *contentCache* (producer) | Sets whether to use resource content cache or not | false | boolean
| *inputType* (producer) | Specifies if the input is hydrated JSON or a JSON String. | Hydrated | JoltInputOutputType
| *outputType* (producer) | Specifies if the output should be hydrated JSON or a JSON String. | Hydrated | JoltInputOutputType
@@ -108,13 +110,14 @@ When using Spring Boot make sure to use the following Maven dependency to have s
----
-The component supports 3 options, which are listed below.
+The component supports 4 options, which are listed below.
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
+| *camel.component.jolt.allow-template-from-header* | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | Boolean
| *camel.component.jolt.enabled* | Enable jolt component | true | Boolean
| *camel.component.jolt.resolve-property-placeholders* | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | Boolean
| *camel.component.jolt.transform* | Explicitly sets the Transform to use. If not set a Transform specified by the transformDsl will be created. The option is a com.bazaarvoice.jolt.Transform type. | | String
diff --git a/components/camel-mustache/src/main/docs/mustache-component.adoc b/components/camel-mustache/src/main/docs/mustache-component.adoc
index 03b22de..2ce545c 100644
--- a/components/camel-mustache/src/main/docs/mustache-component.adoc
+++ b/components/camel-mustache/src/main/docs/mustache-component.adoc
@@ -39,7 +39,7 @@ You can append query options to the URI in the following format,
// component options: START
-The Mustache component supports 2 options, which are listed below.
+The Mustache component supports 3 options, which are listed below.
@@ -47,6 +47,7 @@ The Mustache component supports 2 options, which are listed below.
|===
| Name | Description | Default | Type
| *mustacheFactory* (advanced) | To use a custom MustacheFactory | | MustacheFactory
+| *allowTemplateFrom Header* (producer) | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | boolean
| *resolveProperty Placeholders* (advanced) | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | boolean
|===
// component options: END
@@ -77,12 +78,13 @@ with the following path and query parameters:
|===
-=== Query Parameters (5 parameters):
+=== Query Parameters (6 parameters):
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
+| *allowTemplateFromHeader* (producer) | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | boolean
| *contentCache* (producer) | Sets whether to use resource content cache or not | false | boolean
| *encoding* (producer) | Character encoding of the resource content. | | String
| *endDelimiter* (producer) | Characters used to mark template code end. | }} | String
@@ -106,13 +108,14 @@ When using Spring Boot make sure to use the following Maven dependency to have s
----
-The component supports 3 options, which are listed below.
+The component supports 4 options, which are listed below.
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
+| *camel.component.mustache.allow-template-from-header* | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | Boolean
| *camel.component.mustache.enabled* | Enable mustache component | true | Boolean
| *camel.component.mustache.mustache-factory* | To use a custom MustacheFactory. The option is a com.github.mustachejava.MustacheFactory type. | | String
| *camel.component.mustache.resolve-property-placeholders* | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | Boolean
diff --git a/components/camel-mvel/src/main/docs/mvel-component.adoc b/components/camel-mvel/src/main/docs/mvel-component.adoc
index c7e21b4..e342cb6 100644
--- a/components/camel-mvel/src/main/docs/mvel-component.adoc
+++ b/components/camel-mvel/src/main/docs/mvel-component.adoc
@@ -39,7 +39,16 @@ You can append query options to the URI in the following format,
// component options: START
-The MVEL component has no options.
+The MVEL component supports 2 options, which are listed below.
+
+
+
+[width="100%",cols="2,5,^1,2",options="header"]
+|===
+| Name | Description | Default | Type
+| *allowTemplateFrom Header* (producer) | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | boolean
+| *resolveProperty Placeholders* (advanced) | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | boolean
+|===
// component options: END
@@ -64,12 +73,13 @@ with the following path and query parameters:
|===
-=== Query Parameters (3 parameters):
+=== Query Parameters (4 parameters):
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
+| *allowTemplateFromHeader* (producer) | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | boolean
| *contentCache* (producer) | Sets whether to use resource content cache or not | false | boolean
| *encoding* (producer) | Character encoding of the resource content. | | String
| *synchronous* (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean
@@ -91,13 +101,14 @@ When using Spring Boot make sure to use the following Maven dependency to have s
----
-The component supports 4 options, which are listed below.
+The component supports 5 options, which are listed below.
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
+| *camel.component.mvel.allow-template-from-header* | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | Boolean
| *camel.component.mvel.enabled* | Enable mvel component | true | Boolean
| *camel.component.mvel.resolve-property-placeholders* | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | Boolean
| *camel.language.mvel.enabled* | Enable mvel language | true | Boolean
diff --git a/components/camel-mvel/src/main/docs/mvel-language.adoc b/components/camel-mvel/src/main/docs/mvel-language.adoc
index 210f48a..8a1f3f1 100644
--- a/components/camel-mvel/src/main/docs/mvel-language.adoc
+++ b/components/camel-mvel/src/main/docs/mvel-language.adoc
@@ -53,13 +53,14 @@ When using Spring Boot make sure to use the following Maven dependency to have s
----
-The component supports 4 options, which are listed below.
+The component supports 5 options, which are listed below.
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
+| *camel.component.mvel.allow-template-from-header* | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | Boolean
| *camel.component.mvel.enabled* | Enable mvel component | true | Boolean
| *camel.component.mvel.resolve-property-placeholders* | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | Boolean
| *camel.language.mvel.enabled* | Enable mvel language | true | Boolean
@@ -149,4 +150,4 @@ the download page for the latest versions).
<artifactId>camel-mvel</artifactId>
<version>x.x.x</version>
</dependency>
--------------------------------------
\ No newline at end of file
+-------------------------------------
diff --git a/components/camel-stringtemplate/src/main/docs/string-template-component.adoc b/components/camel-stringtemplate/src/main/docs/string-template-component.adoc
index 6bcdfc6..1c953cd 100644
--- a/components/camel-stringtemplate/src/main/docs/string-template-component.adoc
+++ b/components/camel-stringtemplate/src/main/docs/string-template-component.adoc
@@ -39,7 +39,16 @@ You can append query options to the URI in the following format,
// component options: START
-The String Template component has no options.
+The String Template component supports 2 options, which are listed below.
+
+
+
+[width="100%",cols="2,5,^1,2",options="header"]
+|===
+| Name | Description | Default | Type
+| *allowTemplateFrom Header* (producer) | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | boolean
+| *resolveProperty Placeholders* (advanced) | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | boolean
+|===
// component options: END
@@ -63,12 +72,13 @@ with the following path and query parameters:
|===
-=== Query Parameters (4 parameters):
+=== Query Parameters (5 parameters):
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
+| *allowTemplateFromHeader* (producer) | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | boolean
| *contentCache* (producer) | Sets whether to use resource content cache or not | false | boolean
| *delimiterStart* (producer) | The variable start delimiter | < | char
| *delimiterStop* (producer) | The variable end delimiter | > | char
@@ -91,13 +101,14 @@ When using Spring Boot make sure to use the following Maven dependency to have s
----
-The component supports 2 options, which are listed below.
+The component supports 3 options, which are listed below.
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
+| *camel.component.string-template.allow-template-from-header* | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | Boolean
| *camel.component.string-template.enabled* | Enable string-template component | true | Boolean
| *camel.component.string-template.resolve-property-placeholders* | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | Boolean
|===
@@ -162,4 +173,4 @@ Regards Camel Riders Bookstore
<body>
--------------------------------------------
-And the java code is as follows:
\ No newline at end of file
+And the java code is as follows:
diff --git a/components/camel-velocity/src/main/docs/velocity-component.adoc b/components/camel-velocity/src/main/docs/velocity-component.adoc
index 13d5fd3..9a8c0d2 100644
--- a/components/camel-velocity/src/main/docs/velocity-component.adoc
+++ b/components/camel-velocity/src/main/docs/velocity-component.adoc
@@ -41,7 +41,7 @@ You can append query options to the URI in the following format,
// component options: START
-The Velocity component supports 2 options, which are listed below.
+The Velocity component supports 3 options, which are listed below.
@@ -49,6 +49,7 @@ The Velocity component supports 2 options, which are listed below.
|===
| Name | Description | Default | Type
| *velocityEngine* (advanced) | To use the VelocityEngine otherwise a new engine is created | | VelocityEngine
+| *allowTemplateFrom Header* (producer) | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | boolean
| *resolveProperty Placeholders* (advanced) | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | boolean
|===
// component options: END
@@ -75,12 +76,13 @@ with the following path and query parameters:
|===
-=== Query Parameters (5 parameters):
+=== Query Parameters (6 parameters):
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
+| *allowTemplateFromHeader* (producer) | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | boolean
| *contentCache* (producer) | Sets whether to use resource content cache or not | false | boolean
| *encoding* (producer) | Character encoding of the resource content. | | String
| *loaderCache* (producer) | Enables / disables the velocity resource loader cache which is enabled by default | true | boolean
@@ -104,13 +106,14 @@ When using Spring Boot make sure to use the following Maven dependency to have s
----
-The component supports 3 options, which are listed below.
+The component supports 4 options, which are listed below.
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
+| *camel.component.velocity.allow-template-from-header* | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | Boolean
| *camel.component.velocity.enabled* | Enable velocity component | true | Boolean
| *camel.component.velocity.resolve-property-placeholders* | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | Boolean
| *camel.component.velocity.velocity-engine* | To use the VelocityEngine otherwise a new engine is created. The option is a org.apache.velocity.app.VelocityEngine type. | | String
diff --git a/docs/components/modules/ROOT/pages/chunk-component.adoc b/docs/components/modules/ROOT/pages/chunk-component.adoc
index d2df019..e320974 100644
--- a/docs/components/modules/ROOT/pages/chunk-component.adoc
+++ b/docs/components/modules/ROOT/pages/chunk-component.adoc
@@ -39,7 +39,16 @@ format, `?option=value&option=value&...`
// component options: START
-The Chunk component has no options.
+The Chunk component supports 2 options, which are listed below.
+
+
+
+[width="100%",cols="2,5,^1,2",options="header"]
+|===
+| Name | Description | Default | Type
+| *allowTemplateFrom Header* (producer) | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | boolean
+| *resolveProperty Placeholders* (advanced) | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | boolean
+|===
// component options: END
@@ -63,12 +72,13 @@ with the following path and query parameters:
|===
-=== Query Parameters (7 parameters):
+=== Query Parameters (8 parameters):
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
+| *allowTemplateFromHeader* (producer) | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | boolean
| *contentCache* (producer) | Sets whether to use resource content cache or not | false | boolean
| *encoding* (producer) | Define the encoding of the body | | String
| *extension* (producer) | Define the file extension of the template | | String
@@ -94,13 +104,14 @@ When using Spring Boot make sure to use the following Maven dependency to have s
----
-The component supports 2 options, which are listed below.
+The component supports 3 options, which are listed below.
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
+| *camel.component.chunk.allow-template-from-header* | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | Boolean
| *camel.component.chunk.enabled* | Enable chunk component | true | Boolean
| *camel.component.chunk.resolve-property-placeholders* | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | Boolean
|===
@@ -213,4 +224,4 @@ Thanks for the order of {$headers.item}.
Regards Camel Riders Bookstore
{$body}
-----------------------------------------------
\ No newline at end of file
+----------------------------------------------
diff --git a/docs/components/modules/ROOT/pages/freemarker-component.adoc b/docs/components/modules/ROOT/pages/freemarker-component.adoc
index 9d9b50c..ff60df7 100644
--- a/docs/components/modules/ROOT/pages/freemarker-component.adoc
+++ b/docs/components/modules/ROOT/pages/freemarker-component.adoc
@@ -42,7 +42,7 @@ You can append query options to the URI in the following format,
// component options: START
-The Freemarker component supports 2 options, which are listed below.
+The Freemarker component supports 3 options, which are listed below.
@@ -50,6 +50,7 @@ The Freemarker component supports 2 options, which are listed below.
|===
| Name | Description | Default | Type
| *configuration* (advanced) | To use an existing freemarker.template.Configuration instance as the configuration. | | Configuration
+| *allowTemplateFrom Header* (producer) | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | boolean
| *resolveProperty Placeholders* (advanced) | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | boolean
|===
// component options: END
@@ -77,12 +78,13 @@ with the following path and query parameters:
|===
-=== Query Parameters (5 parameters):
+=== Query Parameters (6 parameters):
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
+| *allowTemplateFromHeader* (producer) | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | boolean
| *configuration* (producer) | Sets the Freemarker configuration to use | | Configuration
| *contentCache* (producer) | Sets whether to use resource content cache or not | false | boolean
| *encoding* (producer) | Sets the encoding to be used for loading the template file. | | String
@@ -106,13 +108,14 @@ When using Spring Boot make sure to use the following Maven dependency to have s
----
-The component supports 3 options, which are listed below.
+The component supports 4 options, which are listed below.
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
+| *camel.component.freemarker.allow-template-from-header* | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | Boolean
| *camel.component.freemarker.configuration* | To use an existing freemarker.template.Configuration instance as the configuration. The option is a freemarker.template.Configuration type. | | String
| *camel.component.freemarker.enabled* | Enable freemarker component | true | Boolean
| *camel.component.freemarker.resolve-property-placeholders* | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | Boolean
diff --git a/docs/components/modules/ROOT/pages/jolt-component.adoc b/docs/components/modules/ROOT/pages/jolt-component.adoc
index d865c46..d0c6ad3 100644
--- a/docs/components/modules/ROOT/pages/jolt-component.adoc
+++ b/docs/components/modules/ROOT/pages/jolt-component.adoc
@@ -44,7 +44,7 @@ format, `?option=value&option=value&...`
// component options: START
-The JOLT component supports 2 options, which are listed below.
+The JOLT component supports 3 options, which are listed below.
@@ -52,6 +52,7 @@ The JOLT component supports 2 options, which are listed below.
|===
| Name | Description | Default | Type
| *transform* (advanced) | Explicitly sets the Transform to use. If not set a Transform specified by the transformDsl will be created | | Transform
+| *allowTemplateFrom Header* (producer) | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | boolean
| *resolveProperty Placeholders* (advanced) | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | boolean
|===
// component options: END
@@ -80,12 +81,13 @@ with the following path and query parameters:
|===
-=== Query Parameters (5 parameters):
+=== Query Parameters (6 parameters):
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
+| *allowTemplateFromHeader* (producer) | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | boolean
| *contentCache* (producer) | Sets whether to use resource content cache or not | false | boolean
| *inputType* (producer) | Specifies if the input is hydrated JSON or a JSON String. | Hydrated | JoltInputOutputType
| *outputType* (producer) | Specifies if the output should be hydrated JSON or a JSON String. | Hydrated | JoltInputOutputType
@@ -109,13 +111,14 @@ When using Spring Boot make sure to use the following Maven dependency to have s
----
-The component supports 3 options, which are listed below.
+The component supports 4 options, which are listed below.
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
+| *camel.component.jolt.allow-template-from-header* | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | Boolean
| *camel.component.jolt.enabled* | Enable jolt component | true | Boolean
| *camel.component.jolt.resolve-property-placeholders* | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | Boolean
| *camel.component.jolt.transform* | Explicitly sets the Transform to use. If not set a Transform specified by the transformDsl will be created. The option is a com.bazaarvoice.jolt.Transform type. | | String
diff --git a/docs/components/modules/ROOT/pages/mustache-component.adoc b/docs/components/modules/ROOT/pages/mustache-component.adoc
index 15aac3d..923d439 100644
--- a/docs/components/modules/ROOT/pages/mustache-component.adoc
+++ b/docs/components/modules/ROOT/pages/mustache-component.adoc
@@ -40,7 +40,7 @@ You can append query options to the URI in the following format,
// component options: START
-The Mustache component supports 2 options, which are listed below.
+The Mustache component supports 3 options, which are listed below.
@@ -48,6 +48,7 @@ The Mustache component supports 2 options, which are listed below.
|===
| Name | Description | Default | Type
| *mustacheFactory* (advanced) | To use a custom MustacheFactory | | MustacheFactory
+| *allowTemplateFrom Header* (producer) | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | boolean
| *resolveProperty Placeholders* (advanced) | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | boolean
|===
// component options: END
@@ -78,12 +79,13 @@ with the following path and query parameters:
|===
-=== Query Parameters (5 parameters):
+=== Query Parameters (6 parameters):
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
+| *allowTemplateFromHeader* (producer) | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | boolean
| *contentCache* (producer) | Sets whether to use resource content cache or not | false | boolean
| *encoding* (producer) | Character encoding of the resource content. | | String
| *endDelimiter* (producer) | Characters used to mark template code end. | }} | String
@@ -107,13 +109,14 @@ When using Spring Boot make sure to use the following Maven dependency to have s
----
-The component supports 3 options, which are listed below.
+The component supports 4 options, which are listed below.
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
+| *camel.component.mustache.allow-template-from-header* | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | Boolean
| *camel.component.mustache.enabled* | Enable mustache component | true | Boolean
| *camel.component.mustache.mustache-factory* | To use a custom MustacheFactory. The option is a com.github.mustachejava.MustacheFactory type. | | String
| *camel.component.mustache.resolve-property-placeholders* | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | Boolean
diff --git a/docs/components/modules/ROOT/pages/mvel-component.adoc b/docs/components/modules/ROOT/pages/mvel-component.adoc
index 53e45df..dfc7232 100644
--- a/docs/components/modules/ROOT/pages/mvel-component.adoc
+++ b/docs/components/modules/ROOT/pages/mvel-component.adoc
@@ -40,7 +40,16 @@ You can append query options to the URI in the following format,
// component options: START
-The MVEL component has no options.
+The MVEL component supports 2 options, which are listed below.
+
+
+
+[width="100%",cols="2,5,^1,2",options="header"]
+|===
+| Name | Description | Default | Type
+| *allowTemplateFrom Header* (producer) | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | boolean
+| *resolveProperty Placeholders* (advanced) | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | boolean
+|===
// component options: END
@@ -65,12 +74,13 @@ with the following path and query parameters:
|===
-=== Query Parameters (3 parameters):
+=== Query Parameters (4 parameters):
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
+| *allowTemplateFromHeader* (producer) | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | boolean
| *contentCache* (producer) | Sets whether to use resource content cache or not | false | boolean
| *encoding* (producer) | Character encoding of the resource content. | | String
| *synchronous* (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean
@@ -92,13 +102,14 @@ When using Spring Boot make sure to use the following Maven dependency to have s
----
-The component supports 4 options, which are listed below.
+The component supports 5 options, which are listed below.
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
+| *camel.component.mvel.allow-template-from-header* | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | Boolean
| *camel.component.mvel.enabled* | Enable mvel component | true | Boolean
| *camel.component.mvel.resolve-property-placeholders* | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | Boolean
| *camel.language.mvel.enabled* | Enable mvel language | true | Boolean
diff --git a/docs/components/modules/ROOT/pages/mvel-language.adoc b/docs/components/modules/ROOT/pages/mvel-language.adoc
index 54e67d2..23ecf8b 100644
--- a/docs/components/modules/ROOT/pages/mvel-language.adoc
+++ b/docs/components/modules/ROOT/pages/mvel-language.adoc
@@ -54,13 +54,14 @@ When using Spring Boot make sure to use the following Maven dependency to have s
----
-The component supports 4 options, which are listed below.
+The component supports 5 options, which are listed below.
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
+| *camel.component.mvel.allow-template-from-header* | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | Boolean
| *camel.component.mvel.enabled* | Enable mvel component | true | Boolean
| *camel.component.mvel.resolve-property-placeholders* | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | Boolean
| *camel.language.mvel.enabled* | Enable mvel language | true | Boolean
@@ -150,4 +151,4 @@ the download page for the latest versions).
<artifactId>camel-mvel</artifactId>
<version>x.x.x</version>
</dependency>
--------------------------------------
\ No newline at end of file
+-------------------------------------
diff --git a/docs/components/modules/ROOT/pages/string-template-component.adoc b/docs/components/modules/ROOT/pages/string-template-component.adoc
index 7ea7987..e6c6b81 100644
--- a/docs/components/modules/ROOT/pages/string-template-component.adoc
+++ b/docs/components/modules/ROOT/pages/string-template-component.adoc
@@ -40,7 +40,16 @@ You can append query options to the URI in the following format,
// component options: START
-The String Template component has no options.
+The String Template component supports 2 options, which are listed below.
+
+
+
+[width="100%",cols="2,5,^1,2",options="header"]
+|===
+| Name | Description | Default | Type
+| *allowTemplateFrom Header* (producer) | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | boolean
+| *resolveProperty Placeholders* (advanced) | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | boolean
+|===
// component options: END
@@ -64,12 +73,13 @@ with the following path and query parameters:
|===
-=== Query Parameters (4 parameters):
+=== Query Parameters (5 parameters):
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
+| *allowTemplateFromHeader* (producer) | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | boolean
| *contentCache* (producer) | Sets whether to use resource content cache or not | false | boolean
| *delimiterStart* (producer) | The variable start delimiter | < | char
| *delimiterStop* (producer) | The variable end delimiter | > | char
@@ -92,13 +102,14 @@ When using Spring Boot make sure to use the following Maven dependency to have s
----
-The component supports 2 options, which are listed below.
+The component supports 3 options, which are listed below.
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
+| *camel.component.string-template.allow-template-from-header* | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | Boolean
| *camel.component.string-template.enabled* | Enable string-template component | true | Boolean
| *camel.component.string-template.resolve-property-placeholders* | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | Boolean
|===
@@ -163,4 +174,4 @@ Regards Camel Riders Bookstore
<body>
--------------------------------------------
-And the java code is as follows:
\ No newline at end of file
+And the java code is as follows:
diff --git a/docs/components/modules/ROOT/pages/velocity-component.adoc b/docs/components/modules/ROOT/pages/velocity-component.adoc
index 261c87a..5f0818c 100644
--- a/docs/components/modules/ROOT/pages/velocity-component.adoc
+++ b/docs/components/modules/ROOT/pages/velocity-component.adoc
@@ -42,7 +42,7 @@ You can append query options to the URI in the following format,
// component options: START
-The Velocity component supports 2 options, which are listed below.
+The Velocity component supports 3 options, which are listed below.
@@ -50,6 +50,7 @@ The Velocity component supports 2 options, which are listed below.
|===
| Name | Description | Default | Type
| *velocityEngine* (advanced) | To use the VelocityEngine otherwise a new engine is created | | VelocityEngine
+| *allowTemplateFrom Header* (producer) | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | boolean
| *resolveProperty Placeholders* (advanced) | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | boolean
|===
// component options: END
@@ -76,12 +77,13 @@ with the following path and query parameters:
|===
-=== Query Parameters (5 parameters):
+=== Query Parameters (6 parameters):
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
+| *allowTemplateFromHeader* (producer) | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | boolean
| *contentCache* (producer) | Sets whether to use resource content cache or not | false | boolean
| *encoding* (producer) | Character encoding of the resource content. | | String
| *loaderCache* (producer) | Enables / disables the velocity resource loader cache which is enabled by default | true | boolean
@@ -105,13 +107,14 @@ When using Spring Boot make sure to use the following Maven dependency to have s
----
-The component supports 3 options, which are listed below.
+The component supports 4 options, which are listed below.
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
+| *camel.component.velocity.allow-template-from-header* | Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | Boolean
| *camel.component.velocity.enabled* | Enable velocity component | true | Boolean
| *camel.component.velocity.resolve-property-placeholders* | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | Boolean
| *camel.component.velocity.velocity-engine* | To use the VelocityEngine otherwise a new engine is created. The option is a org.apache.velocity.app.VelocityEngine type. | | String
diff --git a/platforms/spring-boot/components-starter/camel-chunk-starter/src/main/java/org/apache/camel/component/chunk/springboot/ChunkComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-chunk-starter/src/main/java/org/apache/camel/component/chunk/springboot/ChunkComponentConfiguration.java
index 220804f..6be6420 100644
--- a/platforms/spring-boot/components-starter/camel-chunk-starter/src/main/java/org/apache/camel/component/chunk/springboot/ChunkComponentConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-chunk-starter/src/main/java/org/apache/camel/component/chunk/springboot/ChunkComponentConfiguration.java
@@ -37,12 +37,27 @@ public class ChunkComponentConfiguration
*/
private Boolean enabled;
/**
+ * Whether to allow to use resource template from header or not (default
+ * false). Enabling this allows to specify dynamic templates via message
+ * header. However this can be seen as a potential security vulnerability if
+ * the header is coming from a malicious user, so use this with care.
+ */
+ private Boolean allowTemplateFromHeader = false;
+ /**
* Whether the component should resolve property placeholders on itself when
* starting. Only properties which are of String type can use property
* placeholders.
*/
private Boolean resolvePropertyPlaceholders = true;
+ public Boolean getAllowTemplateFromHeader() {
+ return allowTemplateFromHeader;
+ }
+
+ public void setAllowTemplateFromHeader(Boolean allowTemplateFromHeader) {
+ this.allowTemplateFromHeader = allowTemplateFromHeader;
+ }
+
public Boolean getResolvePropertyPlaceholders() {
return resolvePropertyPlaceholders;
}
diff --git a/platforms/spring-boot/components-starter/camel-freemarker-starter/src/main/java/org/apache/camel/component/freemarker/springboot/FreemarkerComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-freemarker-starter/src/main/java/org/apache/camel/component/freemarker/springboot/FreemarkerComponentConfiguration.java
index 220c6af..d73ee6c 100644
--- a/platforms/spring-boot/components-starter/camel-freemarker-starter/src/main/java/org/apache/camel/component/freemarker/springboot/FreemarkerComponentConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-freemarker-starter/src/main/java/org/apache/camel/component/freemarker/springboot/FreemarkerComponentConfiguration.java
@@ -42,6 +42,13 @@ public class FreemarkerComponentConfiguration
*/
private String configuration;
/**
+ * Whether to allow to use resource template from header or not (default
+ * false). Enabling this allows to specify dynamic templates via message
+ * header. However this can be seen as a potential security vulnerability if
+ * the header is coming from a malicious user, so use this with care.
+ */
+ private Boolean allowTemplateFromHeader = false;
+ /**
* Whether the component should resolve property placeholders on itself when
* starting. Only properties which are of String type can use property
* placeholders.
@@ -56,6 +63,14 @@ public class FreemarkerComponentConfiguration
this.configuration = configuration;
}
+ public Boolean getAllowTemplateFromHeader() {
+ return allowTemplateFromHeader;
+ }
+
+ public void setAllowTemplateFromHeader(Boolean allowTemplateFromHeader) {
+ this.allowTemplateFromHeader = allowTemplateFromHeader;
+ }
+
public Boolean getResolvePropertyPlaceholders() {
return resolvePropertyPlaceholders;
}
diff --git a/platforms/spring-boot/components-starter/camel-jolt-starter/src/main/java/org/apache/camel/component/jolt/springboot/JoltComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-jolt-starter/src/main/java/org/apache/camel/component/jolt/springboot/JoltComponentConfiguration.java
index c5a045d..20af5d2 100644
--- a/platforms/spring-boot/components-starter/camel-jolt-starter/src/main/java/org/apache/camel/component/jolt/springboot/JoltComponentConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-jolt-starter/src/main/java/org/apache/camel/component/jolt/springboot/JoltComponentConfiguration.java
@@ -44,6 +44,13 @@ public class JoltComponentConfiguration
*/
private String transform;
/**
+ * Whether to allow to use resource template from header or not (default
+ * false). Enabling this allows to specify dynamic templates via message
+ * header. However this can be seen as a potential security vulnerability if
+ * the header is coming from a malicious user, so use this with care.
+ */
+ private Boolean allowTemplateFromHeader = false;
+ /**
* Whether the component should resolve property placeholders on itself when
* starting. Only properties which are of String type can use property
* placeholders.
@@ -58,6 +65,14 @@ public class JoltComponentConfiguration
this.transform = transform;
}
+ public Boolean getAllowTemplateFromHeader() {
+ return allowTemplateFromHeader;
+ }
+
+ public void setAllowTemplateFromHeader(Boolean allowTemplateFromHeader) {
+ this.allowTemplateFromHeader = allowTemplateFromHeader;
+ }
+
public Boolean getResolvePropertyPlaceholders() {
return resolvePropertyPlaceholders;
}
diff --git a/platforms/spring-boot/components-starter/camel-mustache-starter/src/main/java/org/apache/camel/component/mustache/springboot/MustacheComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-mustache-starter/src/main/java/org/apache/camel/component/mustache/springboot/MustacheComponentConfiguration.java
index 06125c8..6f04767 100644
--- a/platforms/spring-boot/components-starter/camel-mustache-starter/src/main/java/org/apache/camel/component/mustache/springboot/MustacheComponentConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-mustache-starter/src/main/java/org/apache/camel/component/mustache/springboot/MustacheComponentConfiguration.java
@@ -42,6 +42,13 @@ public class MustacheComponentConfiguration
*/
private String mustacheFactory;
/**
+ * Whether to allow to use resource template from header or not (default
+ * false). Enabling this allows to specify dynamic templates via message
+ * header. However this can be seen as a potential security vulnerability if
+ * the header is coming from a malicious user, so use this with care.
+ */
+ private Boolean allowTemplateFromHeader = false;
+ /**
* Whether the component should resolve property placeholders on itself when
* starting. Only properties which are of String type can use property
* placeholders.
@@ -56,6 +63,14 @@ public class MustacheComponentConfiguration
this.mustacheFactory = mustacheFactory;
}
+ public Boolean getAllowTemplateFromHeader() {
+ return allowTemplateFromHeader;
+ }
+
+ public void setAllowTemplateFromHeader(Boolean allowTemplateFromHeader) {
+ this.allowTemplateFromHeader = allowTemplateFromHeader;
+ }
+
public Boolean getResolvePropertyPlaceholders() {
return resolvePropertyPlaceholders;
}
diff --git a/platforms/spring-boot/components-starter/camel-mvel-starter/src/main/java/org/apache/camel/component/mvel/springboot/MvelComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-mvel-starter/src/main/java/org/apache/camel/component/mvel/springboot/MvelComponentConfiguration.java
index 58e3ea0..7b16cbd 100644
--- a/platforms/spring-boot/components-starter/camel-mvel-starter/src/main/java/org/apache/camel/component/mvel/springboot/MvelComponentConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-mvel-starter/src/main/java/org/apache/camel/component/mvel/springboot/MvelComponentConfiguration.java
@@ -37,12 +37,27 @@ public class MvelComponentConfiguration
*/
private Boolean enabled;
/**
+ * Whether to allow to use resource template from header or not (default
+ * false). Enabling this allows to specify dynamic templates via message
+ * header. However this can be seen as a potential security vulnerability if
+ * the header is coming from a malicious user, so use this with care.
+ */
+ private Boolean allowTemplateFromHeader = false;
+ /**
* Whether the component should resolve property placeholders on itself when
* starting. Only properties which are of String type can use property
* placeholders.
*/
private Boolean resolvePropertyPlaceholders = true;
+ public Boolean getAllowTemplateFromHeader() {
+ return allowTemplateFromHeader;
+ }
+
+ public void setAllowTemplateFromHeader(Boolean allowTemplateFromHeader) {
+ this.allowTemplateFromHeader = allowTemplateFromHeader;
+ }
+
public Boolean getResolvePropertyPlaceholders() {
return resolvePropertyPlaceholders;
}
diff --git a/platforms/spring-boot/components-starter/camel-stringtemplate-starter/src/main/java/org/apache/camel/component/stringtemplate/springboot/StringTemplateComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-stringtemplate-starter/src/main/java/org/apache/camel/component/stringtemplate/springboot/StringTemplateComponentConfiguration.java
index a4affd8..de57699 100644
--- a/platforms/spring-boot/components-starter/camel-stringtemplate-starter/src/main/java/org/apache/camel/component/stringtemplate/springboot/StringTemplateComponentConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-stringtemplate-starter/src/main/java/org/apache/camel/component/stringtemplate/springboot/StringTemplateComponentConfiguration.java
@@ -37,12 +37,27 @@ public class StringTemplateComponentConfiguration
*/
private Boolean enabled;
/**
+ * Whether to allow to use resource template from header or not (default
+ * false). Enabling this allows to specify dynamic templates via message
+ * header. However this can be seen as a potential security vulnerability if
+ * the header is coming from a malicious user, so use this with care.
+ */
+ private Boolean allowTemplateFromHeader = false;
+ /**
* Whether the component should resolve property placeholders on itself when
* starting. Only properties which are of String type can use property
* placeholders.
*/
private Boolean resolvePropertyPlaceholders = true;
+ public Boolean getAllowTemplateFromHeader() {
+ return allowTemplateFromHeader;
+ }
+
+ public void setAllowTemplateFromHeader(Boolean allowTemplateFromHeader) {
+ this.allowTemplateFromHeader = allowTemplateFromHeader;
+ }
+
public Boolean getResolvePropertyPlaceholders() {
return resolvePropertyPlaceholders;
}
diff --git a/platforms/spring-boot/components-starter/camel-velocity-starter/src/main/java/org/apache/camel/component/velocity/springboot/VelocityComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-velocity-starter/src/main/java/org/apache/camel/component/velocity/springboot/VelocityComponentConfiguration.java
index 41c8d5a..a513de1 100644
--- a/platforms/spring-boot/components-starter/camel-velocity-starter/src/main/java/org/apache/camel/component/velocity/springboot/VelocityComponentConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-velocity-starter/src/main/java/org/apache/camel/component/velocity/springboot/VelocityComponentConfiguration.java
@@ -42,6 +42,13 @@ public class VelocityComponentConfiguration
*/
private String velocityEngine;
/**
+ * Whether to allow to use resource template from header or not (default
+ * false). Enabling this allows to specify dynamic templates via message
+ * header. However this can be seen as a potential security vulnerability if
+ * the header is coming from a malicious user, so use this with care.
+ */
+ private Boolean allowTemplateFromHeader = false;
+ /**
* Whether the component should resolve property placeholders on itself when
* starting. Only properties which are of String type can use property
* placeholders.
@@ -56,6 +63,14 @@ public class VelocityComponentConfiguration
this.velocityEngine = velocityEngine;
}
+ public Boolean getAllowTemplateFromHeader() {
+ return allowTemplateFromHeader;
+ }
+
+ public void setAllowTemplateFromHeader(Boolean allowTemplateFromHeader) {
+ this.allowTemplateFromHeader = allowTemplateFromHeader;
+ }
+
public Boolean getResolvePropertyPlaceholders() {
return resolvePropertyPlaceholders;
}
[camel] 06/08: CAMEL-15013: Template components - Add option to
turn on|off allow using header with override template
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-2.25.x
in repository https://gitbox.apache.org/repos/asf/camel.git
commit a2aa4956f871be74f6b5975603229ded483fd2a0
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue May 5 18:03:57 2020 +0200
CAMEL-15013: Template components - Add option to turn on|off allow using header with override template
---
.../camel/component/chunk/ChunkComponent.java | 20 +++++++++++++++
.../camel/component/chunk/ChunkEndpoint.java | 29 +++++++++++++++++++---
.../chunk/ChunkComponentTemplateTest.java | 2 +-
3 files changed, 47 insertions(+), 4 deletions(-)
diff --git a/components/camel-chunk/src/main/java/org/apache/camel/component/chunk/ChunkComponent.java b/components/camel-chunk/src/main/java/org/apache/camel/component/chunk/ChunkComponent.java
index 40b6fee..a07c001 100644
--- a/components/camel-chunk/src/main/java/org/apache/camel/component/chunk/ChunkComponent.java
+++ b/components/camel-chunk/src/main/java/org/apache/camel/component/chunk/ChunkComponent.java
@@ -20,9 +20,13 @@ import java.util.Map;
import org.apache.camel.Endpoint;
import org.apache.camel.impl.UriEndpointComponent;
+import org.apache.camel.spi.Metadata;
public class ChunkComponent extends UriEndpointComponent {
+ @Metadata(defaultValue = "false")
+ private boolean allowTemplateFromHeader;
+
public ChunkComponent() {
super(ChunkEndpoint.class);
}
@@ -30,7 +34,23 @@ public class ChunkComponent extends UriEndpointComponent {
@Override
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
ChunkEndpoint endpoint = new ChunkEndpoint(uri, this, remaining);
+ endpoint.setAllowTemplateFromHeader(allowTemplateFromHeader);
setProperties(endpoint, parameters);
return endpoint;
}
+
+ public boolean isAllowTemplateFromHeader() {
+ return allowTemplateFromHeader;
+ }
+
+ /**
+ * Whether to allow to use resource template from header or not (default false).
+ *
+ * Enabling this allows to specify dynamic templates via message header. However this can
+ * be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care.
+ */
+ public void setAllowTemplateFromHeader(boolean allowTemplateFromHeader) {
+ this.allowTemplateFromHeader = allowTemplateFromHeader;
+ }
+
}
diff --git a/components/camel-chunk/src/main/java/org/apache/camel/component/chunk/ChunkEndpoint.java b/components/camel-chunk/src/main/java/org/apache/camel/component/chunk/ChunkEndpoint.java
index e5c671c..ddd8058f 100644
--- a/components/camel-chunk/src/main/java/org/apache/camel/component/chunk/ChunkEndpoint.java
+++ b/components/camel-chunk/src/main/java/org/apache/camel/component/chunk/ChunkEndpoint.java
@@ -48,7 +48,10 @@ public class ChunkEndpoint extends ResourceEndpoint {
private Theme theme;
private Chunk chunk;
-
+
+ @UriParam(defaultValue = "false")
+ private boolean allowTemplateFromHeader;
+
@UriParam(description = "Define the encoding of the body")
private String encoding;
@@ -95,9 +98,16 @@ public class ChunkEndpoint extends ResourceEndpoint {
@Override
protected void onExchange(Exchange exchange) throws Exception {
boolean fromTemplate;
- String newResourceUri = exchange.getIn().getHeader(CHUNK_RESOURCE_URI, String.class);
+
+ String newResourceUri = null;
+ if (allowTemplateFromHeader) {
+ newResourceUri = exchange.getIn().getHeader(CHUNK_RESOURCE_URI, String.class);
+ }
if (newResourceUri == null) {
- String newTemplate = exchange.getIn().getHeader(CHUNK_TEMPLATE, String.class);
+ String newTemplate = null;
+ if (allowTemplateFromHeader) {
+ newTemplate = exchange.getIn().getHeader(CHUNK_TEMPLATE, String.class);
+ }
Chunk newChunk;
if (newTemplate == null) {
fromTemplate = false;
@@ -245,6 +255,19 @@ public class ChunkEndpoint extends ResourceEndpoint {
this.extension = extension;
}
+ public boolean isAllowTemplateFromHeader() {
+ return allowTemplateFromHeader;
+ }
+
+ /**
+ * Whether to allow to use resource template from header or not (default false).
+ *
+ * Enabling this allows to specify dynamic templates via message header. However this can
+ * be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care.
+ */
+ public void setAllowTemplateFromHeader(boolean allowTemplateFromHeader) {
+ this.allowTemplateFromHeader = allowTemplateFromHeader;
+ }
@Override
protected void doStart() throws Exception {
super.doStart();
diff --git a/components/camel-chunk/src/test/java/org/apache/camel/component/chunk/ChunkComponentTemplateTest.java b/components/camel-chunk/src/test/java/org/apache/camel/component/chunk/ChunkComponentTemplateTest.java
index 1f6c751..c5ee414 100644
--- a/components/camel-chunk/src/test/java/org/apache/camel/component/chunk/ChunkComponentTemplateTest.java
+++ b/components/camel-chunk/src/test/java/org/apache/camel/component/chunk/ChunkComponentTemplateTest.java
@@ -59,7 +59,7 @@ public class ChunkComponentTemplateTest extends CamelTestSupport {
@Override
public void configure() {
from("direct:startSimple")
- .to("chunk://hello")
+ .to("chunk://hello?allowTemplateFromHeader=true")
.to("mock:endSimple");
}
};
[camel] 04/08: CAMEL-15013: Template components - Add option to
turn on|off allow using header with override template
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-2.25.x
in repository https://gitbox.apache.org/repos/asf/camel.git
commit b71d8780b9d3b84be6c343f4128b5e4d75a5f08e
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue May 5 17:50:36 2020 +0200
CAMEL-15013: Template components - Add option to turn on|off allow using header with override template
---
.../component/mustache/MustacheComponent.java | 18 ++++++
.../camel/component/mustache/MustacheEndpoint.java | 71 ++++++++++++++--------
.../component/mustache/MustacheComponentTest.java | 3 +
3 files changed, 68 insertions(+), 24 deletions(-)
diff --git a/components/camel-mustache/src/main/java/org/apache/camel/component/mustache/MustacheComponent.java b/components/camel-mustache/src/main/java/org/apache/camel/component/mustache/MustacheComponent.java
index bbcf6dc..ab955a1 100644
--- a/components/camel-mustache/src/main/java/org/apache/camel/component/mustache/MustacheComponent.java
+++ b/components/camel-mustache/src/main/java/org/apache/camel/component/mustache/MustacheComponent.java
@@ -36,6 +36,9 @@ import org.apache.camel.spi.Metadata;
*/
public class MustacheComponent extends UriEndpointComponent {
+ @Metadata(defaultValue = "false")
+ private boolean allowTemplateFromHeader;
+
@Metadata(label = "advanced")
private MustacheFactory mustacheFactory = new DefaultMustacheFactory();
@@ -47,6 +50,7 @@ public class MustacheComponent extends UriEndpointComponent {
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
MustacheEndpoint endpoint = new MustacheEndpoint(uri, this, remaining);
endpoint.setMustacheFactory(getMustacheFactory());
+ endpoint.setAllowTemplateFromHeader(allowTemplateFromHeader);
setProperties(endpoint, parameters);
return endpoint;
}
@@ -62,4 +66,18 @@ public class MustacheComponent extends UriEndpointComponent {
this.mustacheFactory = mustacheFactory;
}
+ public boolean isAllowTemplateFromHeader() {
+ return allowTemplateFromHeader;
+ }
+
+ /**
+ * Whether to allow to use resource template from header or not (default false).
+ *
+ * Enabling this allows to specify dynamic templates via message header. However this can
+ * be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care.
+ */
+ public void setAllowTemplateFromHeader(boolean allowTemplateFromHeader) {
+ this.allowTemplateFromHeader = allowTemplateFromHeader;
+ }
+
}
diff --git a/components/camel-mustache/src/main/java/org/apache/camel/component/mustache/MustacheEndpoint.java b/components/camel-mustache/src/main/java/org/apache/camel/component/mustache/MustacheEndpoint.java
index 09f876e..7949356 100644
--- a/components/camel-mustache/src/main/java/org/apache/camel/component/mustache/MustacheEndpoint.java
+++ b/components/camel-mustache/src/main/java/org/apache/camel/component/mustache/MustacheEndpoint.java
@@ -47,6 +47,9 @@ public class MustacheEndpoint extends ResourceEndpoint {
private MustacheFactory mustacheFactory;
private Mustache mustache;
+
+ @UriParam(defaultValue = "false")
+ private boolean allowTemplateFromHeader;
@UriParam
private String encoding;
@UriParam(defaultValue = "{{")
@@ -84,34 +87,40 @@ public class MustacheEndpoint extends ResourceEndpoint {
@Override
protected void onExchange(Exchange exchange) throws Exception {
- String newResourceUri = exchange.getIn().getHeader(MUSTACHE_RESOURCE_URI, String.class);
- if (newResourceUri == null) {
- // Get Mustache
- String newTemplate = exchange.getIn().getHeader(MUSTACHE_TEMPLATE, String.class);
- Mustache newMustache;
- if (newTemplate == null) {
- newMustache = getOrCreateMustache();
- } else {
- newMustache = createMustache(new StringReader(newTemplate), "mustache:temp#" + newTemplate.hashCode());
- exchange.getIn().removeHeader(MUSTACHE_TEMPLATE);
- }
-
- // Execute Mustache
- Map<String, Object> variableMap = ExchangeHelper.createVariableMap(exchange);
- StringWriter writer = new StringWriter();
- newMustache.execute(writer, variableMap);
- writer.flush();
-
- // Fill out message
- Message out = exchange.getOut();
- out.setBody(writer.toString());
- out.setHeaders(exchange.getIn().getHeaders());
- out.setAttachments(exchange.getIn().getAttachments());
- } else {
+ String newResourceUri = null;
+ if (allowTemplateFromHeader) {
+ newResourceUri = exchange.getIn().getHeader(MUSTACHE_RESOURCE_URI, String.class);
+ }
+ if (newResourceUri != null) {
exchange.getIn().removeHeader(MustacheConstants.MUSTACHE_RESOURCE_URI);
MustacheEndpoint newEndpoint = getCamelContext().getEndpoint(MUSTACHE_ENDPOINT_URI_PREFIX + newResourceUri, MustacheEndpoint.class);
newEndpoint.onExchange(exchange);
+ return;
+ }
+
+ // Get Mustache
+ String newTemplate = null;
+ if (allowTemplateFromHeader) {
+ newTemplate = exchange.getIn().getHeader(MUSTACHE_TEMPLATE, String.class);
+ }
+ Mustache newMustache;
+ if (newTemplate == null) {
+ newMustache = getOrCreateMustache();
+ } else {
+ newMustache = createMustache(new StringReader(newTemplate), "mustache:temp#" + newTemplate.hashCode());
+ exchange.getIn().removeHeader(MUSTACHE_TEMPLATE);
}
+
+ // Execute Mustache
+ Map<String, Object> variableMap = ExchangeHelper.createVariableMap(exchange);
+ StringWriter writer = new StringWriter();
+ newMustache.execute(writer, variableMap);
+ writer.flush();
+
+ // Fill out message
+ Message out = exchange.getOut();
+ out.setBody(writer.toString());
+ out.setHeaders(exchange.getIn().getHeaders());
}
/**
@@ -212,4 +221,18 @@ public class MustacheEndpoint extends ResourceEndpoint {
this.endDelimiter = endDelimiter;
}
+ public boolean isAllowTemplateFromHeader() {
+ return allowTemplateFromHeader;
+ }
+
+ /**
+ * Whether to allow to use resource template from header or not (default false).
+ *
+ * Enabling this allows to specify dynamic templates via message header. However this can
+ * be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care.
+ */
+ public void setAllowTemplateFromHeader(boolean allowTemplateFromHeader) {
+ this.allowTemplateFromHeader = allowTemplateFromHeader;
+ }
+
}
diff --git a/components/camel-mustache/src/test/java/org/apache/camel/component/mustache/MustacheComponentTest.java b/components/camel-mustache/src/test/java/org/apache/camel/component/mustache/MustacheComponentTest.java
index 5ac5339..2bcfd55 100644
--- a/components/camel-mustache/src/test/java/org/apache/camel/component/mustache/MustacheComponentTest.java
+++ b/components/camel-mustache/src/test/java/org/apache/camel/component/mustache/MustacheComponentTest.java
@@ -137,6 +137,9 @@ public class MustacheComponentTest extends CamelTestSupport {
return new RouteBuilder() {
@Override
public void configure() {
+ MustacheComponent mc = context.getComponent("mustache", MustacheComponent.class);
+ mc.setAllowTemplateFromHeader(true);
+
from("direct:startSimple")
.to("mustache://simple.mustache")
.to("mock:endSimple");
[camel] 07/08: CAMEL-15013: Template components - Add option to
turn on|off allow using header with override template
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-2.25.x
in repository https://gitbox.apache.org/repos/asf/camel.git
commit ef2d2b1a9b9b08ddcab4b0a9ef37603d9048b474
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue May 5 18:12:09 2020 +0200
CAMEL-15013: Template components - Add option to turn on|off allow using header with override template
---
.../apache/camel/component/jolt/JoltComponent.java | 18 +++++++++++++
.../apache/camel/component/jolt/JoltEndpoint.java | 31 ++++++++++++++++++----
.../camel/component/jolt/JoltFirstSampleTest.java | 3 +++
3 files changed, 47 insertions(+), 5 deletions(-)
diff --git a/components/camel-jolt/src/main/java/org/apache/camel/component/jolt/JoltComponent.java b/components/camel-jolt/src/main/java/org/apache/camel/component/jolt/JoltComponent.java
index 9579f1f..da18984 100644
--- a/components/camel-jolt/src/main/java/org/apache/camel/component/jolt/JoltComponent.java
+++ b/components/camel-jolt/src/main/java/org/apache/camel/component/jolt/JoltComponent.java
@@ -25,6 +25,9 @@ import org.apache.camel.spi.Metadata;
import org.apache.camel.util.ResourceHelper;
public class JoltComponent extends UriEndpointComponent {
+
+ @Metadata(defaultValue = "false")
+ private boolean allowTemplateFromHeader;
@Metadata(label = "advanced")
private Transform transform;
@@ -36,6 +39,7 @@ public class JoltComponent extends UriEndpointComponent {
boolean cache = getAndRemoveParameter(parameters, "contentCache", Boolean.class, Boolean.TRUE);
JoltEndpoint answer = new JoltEndpoint(uri, this, remaining);
+ answer.setAllowTemplateFromHeader(allowTemplateFromHeader);
answer.setContentCache(cache);
answer.setTransform(transform);
@@ -59,5 +63,19 @@ public class JoltComponent extends UriEndpointComponent {
this.transform = transform;
}
+ public boolean isAllowTemplateFromHeader() {
+ return allowTemplateFromHeader;
+ }
+
+ /**
+ * Whether to allow to use resource template from header or not (default false).
+ *
+ * Enabling this allows to specify dynamic templates via message header. However this can
+ * be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care.
+ */
+ public void setAllowTemplateFromHeader(boolean allowTemplateFromHeader) {
+ this.allowTemplateFromHeader = allowTemplateFromHeader;
+ }
+
}
diff --git a/components/camel-jolt/src/main/java/org/apache/camel/component/jolt/JoltEndpoint.java b/components/camel-jolt/src/main/java/org/apache/camel/component/jolt/JoltEndpoint.java
index 0188471..0eca1ed 100644
--- a/components/camel-jolt/src/main/java/org/apache/camel/component/jolt/JoltEndpoint.java
+++ b/components/camel-jolt/src/main/java/org/apache/camel/component/jolt/JoltEndpoint.java
@@ -54,6 +54,9 @@ public class JoltEndpoint extends ResourceEndpoint {
@UriParam(defaultValue = "Chainr")
private JoltTransformType transformDsl = JoltTransformType.Chainr;
+ @UriParam(defaultValue = "false")
+ private boolean allowTemplateFromHeader;
+
public JoltEndpoint() {
}
@@ -150,6 +153,20 @@ public class JoltEndpoint extends ResourceEndpoint {
this.transformDsl = transformType;
}
+ public boolean isAllowTemplateFromHeader() {
+ return allowTemplateFromHeader;
+ }
+
+ /**
+ * Whether to allow to use resource template from header or not (default false).
+ *
+ * Enabling this allows to specify dynamic templates via message header. However this can
+ * be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care.
+ */
+ public void setAllowTemplateFromHeader(boolean allowTemplateFromHeader) {
+ this.allowTemplateFromHeader = allowTemplateFromHeader;
+ }
+
public JoltEndpoint findOrCreateEndpoint(String uri, String newResourceUri) {
String newUri = uri.replace(getResourceUri(), newResourceUri);
log.debug("Getting endpoint with URI: {}", newUri);
@@ -161,10 +178,12 @@ public class JoltEndpoint extends ResourceEndpoint {
String path = getResourceUri();
ObjectHelper.notNull(path, "resourceUri");
- String newResourceUri = exchange.getIn().getHeader(JoltConstants.JOLT_RESOURCE_URI, String.class);
+ String newResourceUri = null;
+ if (allowTemplateFromHeader) {
+ newResourceUri = exchange.getIn().getHeader(JoltConstants.JOLT_RESOURCE_URI, String.class);
+ }
if (newResourceUri != null) {
exchange.getIn().removeHeader(JoltConstants.JOLT_RESOURCE_URI);
-
log.debug("{} set to {} creating new endpoint to handle exchange", JoltConstants.JOLT_RESOURCE_URI, newResourceUri);
JoltEndpoint newEndpoint = findOrCreateEndpoint(getEndpointUri(), newResourceUri);
newEndpoint.onExchange(exchange);
@@ -178,10 +197,11 @@ public class JoltEndpoint extends ResourceEndpoint {
input = exchange.getIn().getBody();
}
+ Map<String, Object> inputContextMap = null;
+ if (allowTemplateFromHeader) {
+ inputContextMap = exchange.getIn().getHeader(JoltConstants.JOLT_CONTEXT, Map.class);
+ }
Object output;
-
- @SuppressWarnings("unchecked")
- Map<String, Object> inputContextMap = exchange.getIn().getHeader(JoltConstants.JOLT_CONTEXT, Map.class);
if (inputContextMap != null) {
output = ((ContextualTransform)getTransform()).transform(input, inputContextMap);
} else {
@@ -198,4 +218,5 @@ public class JoltEndpoint extends ResourceEndpoint {
out.setHeaders(exchange.getIn().getHeaders());
out.setAttachments(exchange.getIn().getAttachments());
}
+
}
diff --git a/components/camel-jolt/src/test/java/org/apache/camel/component/jolt/JoltFirstSampleTest.java b/components/camel-jolt/src/test/java/org/apache/camel/component/jolt/JoltFirstSampleTest.java
index 4bcc95f..f474088 100644
--- a/components/camel-jolt/src/test/java/org/apache/camel/component/jolt/JoltFirstSampleTest.java
+++ b/components/camel-jolt/src/test/java/org/apache/camel/component/jolt/JoltFirstSampleTest.java
@@ -62,6 +62,9 @@ public class JoltFirstSampleTest extends CamelTestSupport {
return new RouteBuilder() {
public void configure() {
+ JoltComponent jolt = context.getComponent("jolt", JoltComponent.class);
+ jolt.setAllowTemplateFromHeader(true);
+
from("direct://start")
.process(processor)
.to("jolt:org/apache/camel/component/jolt/firstSample/spec.json?inputType=JsonString&outputType=JsonString")
[camel] 02/08: CAMEL-15013: Template components - Add option to
turn on|off allow using header with override template
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-2.25.x
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 165e7041b6e86d9e9c1503f6632862a43dd812d1
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue May 5 15:31:25 2020 +0200
CAMEL-15013: Template components - Add option to turn on|off allow using header with override template
---
.../component/freemarker/FreemarkerComponent.java | 3 +-
.../component/freemarker/FreemarkerEndpoint.java | 3 +-
.../component/velocity/VelocityComponent.java | 21 +++++++-
.../camel/component/velocity/VelocityEndpoint.java | 56 +++++++++++++++-------
.../component/velocity/VelocityEndpointTest.java | 1 +
.../velocity/VelocitySetTemplateViaHeaderTest.java | 2 +-
.../velocity/VelocitySupplementalContextTest.java | 2 +-
.../velocity/VelocityTemplateInHeaderTest.java | 3 ++
.../camel/component/velocity/VelocityTest.java | 2 +-
.../velocity/VelocityValuesInPropertiesTest.java | 2 +-
10 files changed, 70 insertions(+), 25 deletions(-)
diff --git a/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerComponent.java b/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerComponent.java
index b911b89..2ef2749 100644
--- a/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerComponent.java
+++ b/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerComponent.java
@@ -67,12 +67,13 @@ public class FreemarkerComponent extends UriEndpointComponent {
endpoint.setConfiguration(config);
endpoint.setTemplateUpdateDelay(templateUpdateDelay);
+ setProperties(endpoint, parameters);
+
// if its a http resource then append any remaining parameters and update the resource uri
if (ResourceHelper.isHttpUri(remaining)) {
remaining = ResourceHelper.appendParameters(remaining, parameters);
endpoint.setResourceUri(remaining);
}
- setProperties(endpoint, parameters);
return endpoint;
}
diff --git a/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerEndpoint.java b/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerEndpoint.java
index 85f02b4..ddbd271 100644
--- a/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerEndpoint.java
+++ b/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerEndpoint.java
@@ -28,7 +28,6 @@ import org.apache.camel.Exchange;
import org.apache.camel.ExchangePattern;
import org.apache.camel.Message;
import org.apache.camel.component.ResourceEndpoint;
-import org.apache.camel.spi.Metadata;
import org.apache.camel.spi.UriEndpoint;
import org.apache.camel.spi.UriParam;
import org.apache.camel.util.ExchangeHelper;
@@ -40,7 +39,7 @@ import org.apache.camel.util.ObjectHelper;
@UriEndpoint(firstVersion = "2.10.0", scheme = "freemarker", title = "Freemarker", syntax = "freemarker:resourceUri", producerOnly = true, label = "transformation")
public class FreemarkerEndpoint extends ResourceEndpoint {
- @Metadata(defaultValue = "false")
+ @UriParam(defaultValue = "false")
private boolean allowTemplateFromHeader;
@UriParam
private String encoding;
diff --git a/components/camel-velocity/src/main/java/org/apache/camel/component/velocity/VelocityComponent.java b/components/camel-velocity/src/main/java/org/apache/camel/component/velocity/VelocityComponent.java
index da02a84..a10e750 100644
--- a/components/camel-velocity/src/main/java/org/apache/camel/component/velocity/VelocityComponent.java
+++ b/components/camel-velocity/src/main/java/org/apache/camel/component/velocity/VelocityComponent.java
@@ -29,6 +29,8 @@ import org.apache.velocity.app.VelocityEngine;
*/
public class VelocityComponent extends UriEndpointComponent {
+ @Metadata(defaultValue = "false")
+ private boolean allowTemplateFromHeader;
@Metadata(label = "advanced")
private VelocityEngine velocityEngine;
@@ -47,13 +49,30 @@ public class VelocityComponent extends UriEndpointComponent {
this.velocityEngine = velocityEngine;
}
+ public boolean isAllowTemplateFromHeader() {
+ return allowTemplateFromHeader;
+ }
+
+ /**
+ * Whether to allow to use resource template from header or not (default false).
+ *
+ * Enabling this allows to specify dynamic templates via message header. However this can
+ * be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care.
+ */
+ public void setAllowTemplateFromHeader(boolean allowTemplateFromHeader) {
+ this.allowTemplateFromHeader = allowTemplateFromHeader;
+ }
+
+ @Override
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
boolean cache = getAndRemoveParameter(parameters, "contentCache", Boolean.class, Boolean.TRUE);
VelocityEndpoint answer = new VelocityEndpoint(uri, this, remaining);
- setProperties(answer, parameters);
answer.setContentCache(cache);
answer.setVelocityEngine(velocityEngine);
+ answer.setAllowTemplateFromHeader(allowTemplateFromHeader);
+
+ setProperties(answer, parameters);
// if its a http resource then append any remaining parameters and update the resource uri
if (ResourceHelper.isHttpUri(remaining)) {
diff --git a/components/camel-velocity/src/main/java/org/apache/camel/component/velocity/VelocityEndpoint.java b/components/camel-velocity/src/main/java/org/apache/camel/component/velocity/VelocityEndpoint.java
index 5594e49..ead3a19 100644
--- a/components/camel-velocity/src/main/java/org/apache/camel/component/velocity/VelocityEndpoint.java
+++ b/components/camel-velocity/src/main/java/org/apache/camel/component/velocity/VelocityEndpoint.java
@@ -50,6 +50,8 @@ public class VelocityEndpoint extends ResourceEndpoint {
private VelocityEngine velocityEngine;
+ @UriParam(defaultValue = "false")
+ private boolean allowTemplateFromHeader;
@UriParam(defaultValue = "true")
private boolean loaderCache = true;
@UriParam
@@ -94,8 +96,6 @@ public class VelocityEndpoint extends ResourceEndpoint {
properties.setProperty("class.resource.loader.class", CamelVelocityClasspathResourceLoader.class.getName());
final Logger velocityLogger = LoggerFactory.getLogger("org.apache.camel.maven.Velocity");
properties.setProperty(RuntimeConstants.RUNTIME_LOG_NAME, velocityLogger.getName());
-
-
// load the velocity properties from property file which may overrides the default ones
if (ObjectHelper.isNotEmpty(getPropertiesFile())) {
@@ -126,6 +126,20 @@ public class VelocityEndpoint extends ResourceEndpoint {
this.velocityEngine = velocityEngine;
}
+ public boolean isAllowTemplateFromHeader() {
+ return allowTemplateFromHeader;
+ }
+
+ /**
+ * Whether to allow to use resource template from header or not (default false).
+ *
+ * Enabling this allows to specify dynamic templates via message header. However this can
+ * be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care.
+ */
+ public void setAllowTemplateFromHeader(boolean allowTemplateFromHeader) {
+ this.allowTemplateFromHeader = allowTemplateFromHeader;
+ }
+
public boolean isLoaderCache() {
return loaderCache;
}
@@ -170,18 +184,23 @@ public class VelocityEndpoint extends ResourceEndpoint {
String path = getResourceUri();
ObjectHelper.notNull(path, "resourceUri");
- String newResourceUri = exchange.getIn().getHeader(VelocityConstants.VELOCITY_RESOURCE_URI, String.class);
- if (newResourceUri != null) {
- exchange.getIn().removeHeader(VelocityConstants.VELOCITY_RESOURCE_URI);
+ if (allowTemplateFromHeader) {
+ String newResourceUri = exchange.getIn().getHeader(VelocityConstants.VELOCITY_RESOURCE_URI, String.class);
+ if (newResourceUri != null) {
+ exchange.getIn().removeHeader(VelocityConstants.VELOCITY_RESOURCE_URI);
- log.debug("{} set to {} creating new endpoint to handle exchange", VelocityConstants.VELOCITY_RESOURCE_URI, newResourceUri);
- VelocityEndpoint newEndpoint = findOrCreateEndpoint(getEndpointUri(), newResourceUri);
- newEndpoint.onExchange(exchange);
- return;
+ log.debug("{} set to {} creating new endpoint to handle exchange", VelocityConstants.VELOCITY_RESOURCE_URI, newResourceUri);
+ VelocityEndpoint newEndpoint = findOrCreateEndpoint(getEndpointUri(), newResourceUri);
+ newEndpoint.onExchange(exchange);
+ return;
+ }
}
Reader reader;
- String content = exchange.getIn().getHeader(VelocityConstants.VELOCITY_TEMPLATE, String.class);
+ String content = null;
+ if (allowTemplateFromHeader) {
+ content = exchange.getIn().getHeader(VelocityConstants.VELOCITY_TEMPLATE, String.class);
+ }
if (content != null) {
// use content from header
reader = new StringReader(content);
@@ -200,16 +219,19 @@ public class VelocityEndpoint extends ResourceEndpoint {
// getResourceAsInputStream also considers the content cache
StringWriter buffer = new StringWriter();
String logTag = getClass().getName();
- Context velocityContext = exchange.getIn().getHeader(VelocityConstants.VELOCITY_CONTEXT, Context.class);
+ Context velocityContext = null;
+ if (allowTemplateFromHeader) {
+ velocityContext = exchange.getIn().getHeader(VelocityConstants.VELOCITY_CONTEXT, Context.class);
+ }
if (velocityContext == null) {
Map<String, Object> variableMap = ExchangeHelper.createVariableMap(exchange);
-
- @SuppressWarnings("unchecked")
- Map<String, Object> supplementalMap = exchange.getIn().getHeader(VelocityConstants.VELOCITY_SUPPLEMENTAL_CONTEXT, Map.class);
- if (supplementalMap != null) {
- variableMap.putAll(supplementalMap);
+ if (allowTemplateFromHeader) {
+ @SuppressWarnings("unchecked")
+ Map<String, Object> supplementalMap = exchange.getIn().getHeader(VelocityConstants.VELOCITY_SUPPLEMENTAL_CONTEXT, Map.class);
+ if (supplementalMap != null) {
+ variableMap.putAll(supplementalMap);
+ }
}
-
velocityContext = new VelocityContext(variableMap);
}
diff --git a/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocityEndpointTest.java b/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocityEndpointTest.java
index 096475e..5a38969 100644
--- a/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocityEndpointTest.java
+++ b/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocityEndpointTest.java
@@ -29,6 +29,7 @@ public class VelocityEndpointTest extends VelocityTest {
VelocityEndpoint endpoint = new VelocityEndpoint();
endpoint.setCamelContext(context);
endpoint.setResourceUri("org/apache/camel/component/velocity/example.vm");
+ endpoint.setAllowTemplateFromHeader(true);
context.addEndpoint("velo", endpoint);
diff --git a/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocitySetTemplateViaHeaderTest.java b/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocitySetTemplateViaHeaderTest.java
index faa22ba..29c3daa 100644
--- a/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocitySetTemplateViaHeaderTest.java
+++ b/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocitySetTemplateViaHeaderTest.java
@@ -59,7 +59,7 @@ public class VelocitySetTemplateViaHeaderTest extends CamelTestSupport {
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
public void configure() throws Exception {
- from("direct:a").to("velocity:dummy").to("mock:result");
+ from("direct:a").to("velocity:dummy?allowTemplateFromHeader=true").to("mock:result");
}
};
}
diff --git a/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocitySupplementalContextTest.java b/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocitySupplementalContextTest.java
index ac22301..93244b4 100644
--- a/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocitySupplementalContextTest.java
+++ b/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocitySupplementalContextTest.java
@@ -61,7 +61,7 @@ public class VelocitySupplementalContextTest extends CamelTestSupport {
public void configure() throws Exception {
from("direct:input")
.setHeader(VelocityConstants.VELOCITY_SUPPLEMENTAL_CONTEXT).constant(supplementalContext)
- .to("velocity:template-in-header")
+ .to("velocity:template-in-header?allowTemplateFromHeader=true")
.to("mock:results");
}
};
diff --git a/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocityTemplateInHeaderTest.java b/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocityTemplateInHeaderTest.java
index 16582f3..9065503 100644
--- a/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocityTemplateInHeaderTest.java
+++ b/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocityTemplateInHeaderTest.java
@@ -78,6 +78,9 @@ public class VelocityTemplateInHeaderTest extends CamelTestSupport {
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
+ VelocityComponent vc = context.getComponent("velocity", VelocityComponent.class);
+ vc.setAllowTemplateFromHeader(true);
+
from("direct:a").to("velocity://dummy");
}
};
diff --git a/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocityTest.java b/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocityTest.java
index 7e97ac1..423e8d7f 100644
--- a/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocityTest.java
+++ b/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocityTest.java
@@ -76,7 +76,7 @@ public class VelocityTest extends CamelTestSupport {
public void configure() {
// START SNIPPET: example
from("direct:a").
- to("velocity:org/apache/camel/component/velocity/example.vm");
+ to("velocity:org/apache/camel/component/velocity/example.vm?allowTemplateFromHeader=true");
// END SNIPPET: example
}
};
diff --git a/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocityValuesInPropertiesTest.java b/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocityValuesInPropertiesTest.java
index 65aa9b0..2fa24a5 100644
--- a/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocityValuesInPropertiesTest.java
+++ b/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocityValuesInPropertiesTest.java
@@ -49,7 +49,7 @@ public class VelocityValuesInPropertiesTest extends CamelTestSupport {
return new RouteBuilder() {
public void configure() throws Exception {
from("direct:a")
- .to("velocity:dummy")
+ .to("velocity:dummy?allowTemplateFromHeader=true")
.to("mock:result");
}
};
[camel] 01/08: CAMEL-15013: Template components - Add option to
turn on|off allow using header with override template
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-2.25.x
in repository https://gitbox.apache.org/repos/asf/camel.git
commit f46aeb5eaaae7984355b8c7d81fabf928799b0d2
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue May 5 11:41:43 2020 +0200
CAMEL-15013: Template components - Add option to turn on|off allow using header with override template
---
.../component/freemarker/FreemarkerComponent.java | 18 +++++
.../component/freemarker/FreemarkerEndpoint.java | 43 ++++++++---
.../freemarker/FreemarkerEndpointTest.java | 1 +
.../freemarker/FreemarkerOverrideHeaderTest.java | 87 ++++++++++++++++++++++
.../freemarker/FreemarkerTemplateInHeaderTest.java | 2 +-
.../camel/component/freemarker/FreemarkerTest.java | 2 +-
.../FreemarkerValuesInPropertiesTest.java | 3 +
7 files changed, 145 insertions(+), 11 deletions(-)
diff --git a/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerComponent.java b/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerComponent.java
index f584e39..b911b89 100644
--- a/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerComponent.java
+++ b/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerComponent.java
@@ -33,6 +33,8 @@ import org.apache.camel.util.ResourceHelper;
*/
public class FreemarkerComponent extends UriEndpointComponent {
+ @Metadata(defaultValue = "false")
+ private boolean allowTemplateFromHeader;
@Metadata(label = "advanced")
private Configuration configuration;
private Configuration noCacheConfiguration;
@@ -60,6 +62,7 @@ public class FreemarkerComponent extends UriEndpointComponent {
if (ObjectHelper.isNotEmpty(encoding)) {
endpoint.setEncoding(encoding);
}
+ endpoint.setAllowTemplateFromHeader(allowTemplateFromHeader);
endpoint.setContentCache(cache);
endpoint.setConfiguration(config);
endpoint.setTemplateUpdateDelay(templateUpdateDelay);
@@ -69,6 +72,7 @@ public class FreemarkerComponent extends UriEndpointComponent {
remaining = ResourceHelper.appendParameters(remaining, parameters);
endpoint.setResourceUri(remaining);
}
+ setProperties(endpoint, parameters);
return endpoint;
}
@@ -99,6 +103,20 @@ public class FreemarkerComponent extends UriEndpointComponent {
this.configuration = configuration;
}
+ public boolean isAllowTemplateFromHeader() {
+ return allowTemplateFromHeader;
+ }
+
+ /**
+ * Whether to allow to use resource template from header or not (default false).
+ *
+ * Enabling this allows to specify dynamic templates via message header. However this can
+ * be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care.
+ */
+ public void setAllowTemplateFromHeader(boolean allowTemplateFromHeader) {
+ this.allowTemplateFromHeader = allowTemplateFromHeader;
+ }
+
private synchronized Configuration getNoCacheConfiguration() {
if (noCacheConfiguration == null) {
// create a clone of the regular configuration
diff --git a/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerEndpoint.java b/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerEndpoint.java
index 03d9f5a..85f02b4 100644
--- a/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerEndpoint.java
+++ b/components/camel-freemarker/src/main/java/org/apache/camel/component/freemarker/FreemarkerEndpoint.java
@@ -28,6 +28,7 @@ import org.apache.camel.Exchange;
import org.apache.camel.ExchangePattern;
import org.apache.camel.Message;
import org.apache.camel.component.ResourceEndpoint;
+import org.apache.camel.spi.Metadata;
import org.apache.camel.spi.UriEndpoint;
import org.apache.camel.spi.UriParam;
import org.apache.camel.util.ExchangeHelper;
@@ -39,6 +40,8 @@ import org.apache.camel.util.ObjectHelper;
@UriEndpoint(firstVersion = "2.10.0", scheme = "freemarker", title = "Freemarker", syntax = "freemarker:resourceUri", producerOnly = true, label = "transformation")
public class FreemarkerEndpoint extends ResourceEndpoint {
+ @Metadata(defaultValue = "false")
+ private boolean allowTemplateFromHeader;
@UriParam
private String encoding;
@UriParam
@@ -68,6 +71,20 @@ public class FreemarkerEndpoint extends ResourceEndpoint {
return "freemarker:" + getResourceUri();
}
+ public boolean isAllowTemplateFromHeader() {
+ return allowTemplateFromHeader;
+ }
+
+ /**
+ * Whether to allow to use resource template from header or not (default false).
+ *
+ * Enabling this allows to specify dynamic templates via message header. However this can
+ * be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care.
+ */
+ public void setAllowTemplateFromHeader(boolean allowTemplateFromHeader) {
+ this.allowTemplateFromHeader = allowTemplateFromHeader;
+ }
+
/**
* Sets the encoding to be used for loading the template file.
*/
@@ -118,25 +135,33 @@ public class FreemarkerEndpoint extends ResourceEndpoint {
ObjectHelper.notNull(configuration, "configuration");
ObjectHelper.notNull(path, "resourceUri");
- String newResourceUri = exchange.getIn().getHeader(FreemarkerConstants.FREEMARKER_RESOURCE_URI, String.class);
- if (newResourceUri != null) {
- exchange.getIn().removeHeader(FreemarkerConstants.FREEMARKER_RESOURCE_URI);
+ if (allowTemplateFromHeader) {
+ String newResourceUri = exchange.getIn().getHeader(FreemarkerConstants.FREEMARKER_RESOURCE_URI, String.class);
+ if (newResourceUri != null) {
+ exchange.getIn().removeHeader(FreemarkerConstants.FREEMARKER_RESOURCE_URI);
- log.debug("{} set to {} creating new endpoint to handle exchange", FreemarkerConstants.FREEMARKER_RESOURCE_URI, newResourceUri);
- FreemarkerEndpoint newEndpoint = findOrCreateEndpoint(getEndpointUri(), newResourceUri);
- newEndpoint.onExchange(exchange);
- return;
+ log.debug("{} set to {} creating new endpoint to handle exchange", FreemarkerConstants.FREEMARKER_RESOURCE_URI, newResourceUri);
+ FreemarkerEndpoint newEndpoint = findOrCreateEndpoint(getEndpointUri(), newResourceUri);
+ newEndpoint.onExchange(exchange);
+ return;
+ }
}
Reader reader = null;
- String content = exchange.getIn().getHeader(FreemarkerConstants.FREEMARKER_TEMPLATE, String.class);
+ String content = null;
+ if (allowTemplateFromHeader) {
+ content = exchange.getIn().getHeader(FreemarkerConstants.FREEMARKER_TEMPLATE, String.class);
+ }
if (content != null) {
// use content from header
reader = new StringReader(content);
// remove the header to avoid it being propagated in the routing
exchange.getIn().removeHeader(FreemarkerConstants.FREEMARKER_TEMPLATE);
}
- Object dataModel = exchange.getIn().getHeader(FreemarkerConstants.FREEMARKER_DATA_MODEL, Object.class);
+ Object dataModel = null;
+ if (allowTemplateFromHeader) {
+ dataModel = exchange.getIn().getHeader(FreemarkerConstants.FREEMARKER_DATA_MODEL, Object.class);
+ }
if (dataModel == null) {
dataModel = ExchangeHelper.createVariableMap(exchange);
}
diff --git a/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerEndpointTest.java b/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerEndpointTest.java
index 8d3d39e..f4de5d7 100644
--- a/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerEndpointTest.java
+++ b/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerEndpointTest.java
@@ -31,6 +31,7 @@ public class FreemarkerEndpointTest extends FreemarkerTest {
public void configure() throws Exception {
FreemarkerEndpoint endpoint = new FreemarkerEndpoint();
endpoint.setCamelContext(context);
+ endpoint.setAllowTemplateFromHeader(true);
endpoint.setResourceUri("org/apache/camel/component/freemarker/example.ftl");
Configuration configuraiton = new Configuration();
diff --git a/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerOverrideHeaderTest.java b/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerOverrideHeaderTest.java
new file mode 100644
index 0000000..8191b68
--- /dev/null
+++ b/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerOverrideHeaderTest.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.freemarker;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class FreemarkerOverrideHeaderTest extends CamelTestSupport {
+
+ @Override
+ public boolean isUseRouteBuilder() {
+ return false;
+ }
+
+ private Exchange createLetter() {
+ Exchange exchange = context.getEndpoint("direct:a").createExchange();
+
+ Message msg = exchange.getIn();
+ msg.setHeader("firstName", "Claus");
+ msg.setHeader("lastName", "Ibsen");
+ msg.setHeader("item", "Camel in Action");
+ msg.setBody("PS: Next beer is on me, James");
+ msg.setHeader(FreemarkerConstants.FREEMARKER_RESOURCE_URI, "org/apache/camel/component/freemarker/letter.ftl");
+ return exchange;
+ }
+
+ @Test
+ public void testFreemarkerLetter() throws Exception {
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:a")
+ .to("freemarker:org/apache/camel/component/freemarker/example.ftl")
+ .to("mock:result");
+ }
+ });
+ context.start();
+
+ Exchange out = template.send("direct:a", createLetter());
+ assertTrue(out.isFailed());
+
+ context.stop();
+ }
+
+ @Test
+ public void testFreemarkerLetterAllowed() throws Exception {
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:a")
+ .to("freemarker:org/apache/camel/component/freemarker/example.ftl?allowTemplateFromHeader=true")
+ .to("mock:result");
+ }
+ });
+ context.start();
+
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMessageCount(1);
+ mock.message(0).body().contains("Dear Ibsen, Claus");
+ mock.message(0).body().contains("Thanks for the order of Camel in Action.");
+
+ template.send("direct:a", createLetter());
+
+ mock.assertIsSatisfied();
+
+ context.stop();
+ }
+
+}
diff --git a/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerTemplateInHeaderTest.java b/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerTemplateInHeaderTest.java
index b42ea5e..c90abe0 100644
--- a/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerTemplateInHeaderTest.java
+++ b/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerTemplateInHeaderTest.java
@@ -79,7 +79,7 @@ public class FreemarkerTemplateInHeaderTest extends CamelTestSupport {
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
- from("direct:a").to("freemarker://dummy");
+ from("direct:a").to("freemarker://dummy?allowTemplateFromHeader=true");
}
};
}
diff --git a/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerTest.java b/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerTest.java
index e44156a2..5d06fd5 100644
--- a/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerTest.java
+++ b/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerTest.java
@@ -78,7 +78,7 @@ public class FreemarkerTest extends CamelTestSupport {
public void configure() {
// START SNIPPET: example
from("direct:a").
- to("freemarker:org/apache/camel/component/freemarker/example.ftl");
+ to("freemarker:org/apache/camel/component/freemarker/example.ftl?allowTemplateFromHeader=true");
// END SNIPPET: example
}
};
diff --git a/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerValuesInPropertiesTest.java b/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerValuesInPropertiesTest.java
index 4caec7e..a755a5a 100644
--- a/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerValuesInPropertiesTest.java
+++ b/components/camel-freemarker/src/test/java/org/apache/camel/component/freemarker/FreemarkerValuesInPropertiesTest.java
@@ -48,6 +48,9 @@ public class FreemarkerValuesInPropertiesTest extends CamelTestSupport {
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
public void configure() throws Exception {
+ FreemarkerComponent fc = context.getComponent("freemarker", FreemarkerComponent.class);
+ fc.setAllowTemplateFromHeader(true);
+
from("direct:a")
.to("freemarker:dummy")
.to("mock:result");