Skip to content

Commit

Permalink
Document allowContextMapAll native mode limitations
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesnetherton committed Sep 30, 2020
1 parent 81d6094 commit 847fe8b
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 32 deletions.
9 changes: 9 additions & 0 deletions docs/modules/ROOT/pages/reference/extensions/qute.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ Check the xref:user-guide/index.adoc[User guide] for more information about writ
Please refer to the https://quarkus.io/guides/qute[Quarkus Qute].


== Camel Quarkus limitations

== allowContextMapAll option in native mode

The `allowContextMapAll` option is not supported in native mode as it requires reflective access to security sensitive camel core classes such as
`CamelContext` & `Exchange`. This is considered a security risk and thus access to the feature is not provided by default.



== Additional Camel Quarkus configuration

By default, all files located in the src/main/resources/templates directory and its subdirectories
Expand Down
10 changes: 0 additions & 10 deletions docs/modules/ROOT/pages/reference/extensions/stringtemplate.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,3 @@ Please refer to the above link for usage and configuration details.
----

Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.

== Camel Quarkus limitations

If property `allowContextMapAll` is set to `true` there is a limitation in native mode. Reflective calls to methods
of several classes in camel are not allowed (for example `org.apache.camel.support.DefaultExchange`). Therefore
some expressions won't work (for example `<exchange.properties.*>).

You can allow reflective calls to such classes (for example by using application.properties), but keep in mind that it brings
some security risks.

10 changes: 0 additions & 10 deletions docs/modules/ROOT/pages/reference/extensions/velocity.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,6 @@ Please refer to the above link for usage and configuration details.

Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.

== Camel Quarkus limitations

If property `allowContextMapAll` is set to `true` there is a limitation in native mode. Reflective calls to methods
of several classes in camel are not allowed (for example `org.apache.camel.support.DefaultExchange`). Therefore
some expressions won't work (for example `${exchange.properties.*}).

You can allow reflective calls to such classes (for example by using application.properties), but keep in mind that it brings
some security risks.


== Additional Camel Quarkus configuration

Beyond standard usages described above, a trick is needed when using velocity templates from classpath resources in native mode. In such a situation, one needs to explicitly embed the resources in the native executable by specifying the `include-patterns` option.
Expand Down
5 changes: 5 additions & 0 deletions extensions/qute/runtime/src/main/doc/limitations.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
== allowContextMapAll option in native mode

The `allowContextMapAll` option is not supported in native mode as it requires reflective access to security sensitive camel core classes such as
`CamelContext` & `Exchange`. This is considered a security risk and thus access to the feature is not provided by default.

This file was deleted.

6 changes: 0 additions & 6 deletions extensions/velocity/runtime/src/main/doc/limitations.adoc

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import java.util.stream.Stream;
Expand All @@ -46,6 +47,7 @@
import org.apache.camel.catalog.Kind;
import org.apache.camel.tooling.model.ArtifactModel;
import org.apache.camel.tooling.model.BaseModel;
import org.apache.camel.tooling.model.ComponentModel;
import org.apache.maven.model.Dependency;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
Expand Down Expand Up @@ -120,6 +122,8 @@ public void execute() throws MojoExecutionException, MojoFailureException {
model.put("limitations", loadSection(basePath, "limitations.adoc", charset, null));
model.put("activatesNativeSsl", ext.isNativeSupported() && detectNativeSsl(multiModuleProjectDirectory.toPath(),
basePath, ext.getRuntimeArtifactId(), ext.getDependencies(), nativeSslActivators));
model.put("activatesContextMapAll",
ext.isNativeSupported() && detectAllowContextMapAll(catalog, ext.getRuntimeArtifactIdBase()));
model.put("configOptions", listConfigOptions(basePath, multiModuleProjectDirectory.toPath()));
model.put("humanReadableKind", new TemplateMethodModelEx() {
@Override
Expand Down Expand Up @@ -316,6 +320,29 @@ static boolean detectNativeSsl(Path deploymentBasePath) {
}
}

static boolean detectAllowContextMapAll(CqCatalog catalog, String artifactId) {
final String allowContextMapAll = "allowContextMapAll";
Optional<ArtifactModel<?>> optional = catalog.filterModels(artifactId).findFirst();
if (optional.isPresent()) {
ArtifactModel<?> artifactModel = optional.get();
if (artifactModel instanceof ComponentModel) {
ComponentModel componentModel = (ComponentModel) artifactModel;
for (ComponentModel.ComponentOptionModel model : componentModel.getOptions()) {
if (model.getName().equals(allowContextMapAll)) {
return true;
}
}

for (ComponentModel.EndpointOptionModel model : componentModel.getEndpointOptions()) {
if (model.getName().equals(allowContextMapAll)) {
return true;
}
}
}
}
return false;
}

private static String loadSection(Path basePath, String fileName, Charset charset, String default_) {
Path p = basePath.resolve("src/main/doc/" + fileName);
if (Files.exists(p)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ Check the xref:user-guide/index.adoc[User guide] for more information about writ
== Camel Quarkus limitations

[=limitations]
[#if activatesContextMapAll ]
=== allowContextMapAll option in native mode

The `allowContextMapAll` option is not supported in native mode as it requires reflective access to security sensitive camel core classes such as
`CamelContext` & `Exchange`. This is considered a security risk and thus access to the feature is not provided by default.
[/#if]
[/#if]
[#if activatesNativeSsl ]

Expand Down

0 comments on commit 847fe8b

Please sign in to comment.