This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch chore-avro-jvm-wide-trust in repository https://gitbox.apache.org/repos/asf/camel.git
commit d496578635ab1bebd0218bb4d65bbebee91bf9ae Author: Claus Ibsen <[email protected]> AuthorDate: Fri Nov 27 20:10:01 2026 +0100 chore: camel-avro-rpc, camel-avro - document that trusted packages apply to the whole JVM The serializablePackages, protocol and protocolClassName options of an Avro RPC endpoint, and the instanceClassName, schema and serializablePackages options of the Avro data format, add packages to Avro's class validator, which is one for the whole JVM. A package trusted by one endpoint or data format is trusted for all Avro class resolution in the JVM and stays trusted until restart. Document this on the avro-rpc options and in a short section on both doc pages. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Claus Ibsen <[email protected]> --- .../org/apache/camel/catalog/components/avro.json | 12 ++--- .../apache/camel/catalog/docs/avro-component.adoc | 11 +++++ .../apache/camel/catalog/docs/avro-dataformat.adoc | 11 +++++ .../org/apache/camel/component/avro/avro.json | 12 ++--- .../src/main/docs/avro-component.adoc | 11 +++++ .../camel/component/avro/AvroConfiguration.java | 11 ++++- .../camel-avro/src/main/docs/avro-dataformat.adoc | 11 +++++ .../component/dsl/AvroComponentBuilderFactory.java | 14 ++++-- .../endpoint/dsl/AvroEndpointBuilderFactory.java | 54 +++++++++++++++++----- 9 files changed, 118 insertions(+), 29 deletions(-) diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/avro.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/avro.json index 4130965ceb82..ad53845f1d74 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/avro.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/avro.json @@ -24,8 +24,8 @@ "remote": true }, "componentProperties": { - "protocol": { "index": 0, "kind": "property", "displayName": "Protocol", "group": "common", "label": "", "required": false, "type": "object", "javaType": "org.apache.avro.Protocol", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "The Avro protocol (org.apache.avro.Protocol) that defines the messages, such as the PROTOCOL field of a class generate [...] - "protocolClassName": { "index": 1, "kind": "property", "displayName": "Protocol Class Name", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "The fully qualified name of the class that defines the protocol. For a class generated by the Avro compile [...] + "protocol": { "index": 0, "kind": "property", "displayName": "Protocol", "group": "common", "label": "", "required": false, "type": "object", "javaType": "org.apache.avro.Protocol", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "The Avro protocol (org.apache.avro.Protocol) that defines the messages, such as the PROTOCOL field of a class generate [...] + "protocolClassName": { "index": 1, "kind": "property", "displayName": "Protocol Class Name", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "The fully qualified name of the class that defines the protocol. For a class generated by the Avro compile [...] "protocolLocation": { "index": 2, "kind": "property", "displayName": "Protocol Location", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "Not used: the component does not read this option. Use protocol or protocolClassName instead." }, "reflectionProtocol": { "index": 3, "kind": "property", "displayName": "Reflection Protocol", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "Whether the protocol is a reflect protocol, built by Avro reflection from a Java interface [...] "singleParameter": { "index": 4, "kind": "property", "displayName": "Single Parameter", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "Whether the consumer sets the message body to the one parameter of the called message, instead o [...] @@ -34,7 +34,7 @@ "lazyStartProducer": { "index": 7, "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail [...] "autowiredEnabled": { "index": 8, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching t [...] "configuration": { "index": 9, "kind": "property", "displayName": "Configuration", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.avro.AvroConfiguration", "deprecated": false, "autowired": false, "secret": false, "description": "A shared configuration that every endpoint copies as its starting point. The options of the endpoint URI override its values." }, - "serializablePackages": { "index": 10, "kind": "property", "displayName": "Serializable Packages", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "security": "insecure:serialization", "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "Comma-separated list of additional packages that con [...] + "serializablePackages": { "index": 10, "kind": "property", "displayName": "Serializable Packages", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "security": "insecure:serialization", "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "Comma-separated list of additional packages that con [...] }, "headers": { "CamelAvroMessageName": { "index": 0, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "autowired": false, "secret": false, "description": "The name of the protocol message to call. The producer reads it, and it takes precedence over the messageName of the endpoint. The consumer sets it to the name of the called message.", "constantName": "org.apache.camel.component.avro.AvroConstants#AVRO_MESSAGE_NAME" } @@ -50,8 +50,8 @@ "port": { "index": 1, "kind": "path", "displayName": "Port", "group": "common", "label": "", "required": true, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "The port number. The consumer listens on it, and the producer connects to it." }, "host": { "index": 2, "kind": "path", "displayName": "Host", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "The host name or IP address. The consumer binds its server to it, and the producer connects to it." }, "messageName": { "index": 3, "kind": "path", "displayName": "Message Name", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "The name of the protocol message to call or serve. The producer calls it unless the CamelAvroMessageName header is set. A c [...] - "protocol": { "index": 4, "kind": "parameter", "displayName": "Protocol", "group": "common", "label": "", "required": false, "type": "object", "javaType": "org.apache.avro.Protocol", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "The Avro protocol (org.apache.avro.Protocol) that defines the messages, such as the PROTOCOL field of a class generat [...] - "protocolClassName": { "index": 5, "kind": "parameter", "displayName": "Protocol Class Name", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "The fully qualified name of the class that defines the protocol. For a class generated by the Avro compil [...] + "protocol": { "index": 4, "kind": "parameter", "displayName": "Protocol", "group": "common", "label": "", "required": false, "type": "object", "javaType": "org.apache.avro.Protocol", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "The Avro protocol (org.apache.avro.Protocol) that defines the messages, such as the PROTOCOL field of a class generat [...] + "protocolClassName": { "index": 5, "kind": "parameter", "displayName": "Protocol Class Name", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "The fully qualified name of the class that defines the protocol. For a class generated by the Avro compil [...] "protocolLocation": { "index": 6, "kind": "parameter", "displayName": "Protocol Location", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "Not used: the component does not read this option. Use protocol or protocolClassName instead." }, "reflectionProtocol": { "index": 7, "kind": "parameter", "displayName": "Reflection Protocol", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "Whether the protocol is a reflect protocol, built by Avro reflection from a Java interfac [...] "singleParameter": { "index": 8, "kind": "parameter", "displayName": "Single Parameter", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "Whether the consumer sets the message body to the one parameter of the called message, instead [...] @@ -60,6 +60,6 @@ "exceptionHandler": { "index": 11, "kind": "parameter", "displayName": "Exception Handler", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.spi.ExceptionHandler", "optionalPrefix": "consumer.", "deprecated": false, "autowired": false, "secret": false, "description": "To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By de [...] "exchangePattern": { "index": 12, "kind": "parameter", "displayName": "Exchange Pattern", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "enum", "javaType": "org.apache.camel.ExchangePattern", "enum": [ "InOnly", "InOut" ], "deprecated": false, "autowired": false, "secret": false, "description": "Sets the exchange pattern when the consumer creates an exchange." }, "lazyStartProducer": { "index": 13, "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a produ [...] - "serializablePackages": { "index": 14, "kind": "parameter", "displayName": "Serializable Packages", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "security": "insecure:serialization", "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "Comma-separated list of additional packages that co [...] + "serializablePackages": { "index": 14, "kind": "parameter", "displayName": "Serializable Packages", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "security": "insecure:serialization", "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "Comma-separated list of additional packages that co [...] } } diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/avro-component.adoc b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/avro-component.adoc index 572d94a7ef69..c186f9b588b4 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/avro-component.adoc +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/avro-component.adoc @@ -145,6 +145,17 @@ got only one parameter, *since 2.12* you can use `singleParameter` URI option to receive it directly in the "in" message body without array wrapping. +=== Trusted packages apply to the whole JVM + +Avro validates the classes it loads for a schema, and only loads classes from trusted packages. Camel adds the +packages of the `protocol` or `protocolClassName` option, and the packages of the `serializablePackages` option, to +these trusted packages. + +Avro has one class validator for the whole JVM. So a package trusted by one endpoint is trusted for all Avro class +resolution in the JVM: for every Avro RPC endpoint, every xref:dataformats:avro-dataformat.adoc[Avro data format] and +every Camel context in the same JVM. A trusted package stays trusted until the JVM is restarted; stopping the endpoint +or the route does not remove it. Only add packages that hold your own Avro model classes. + == Examples An example of using camel avro producers via http: diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/avro-dataformat.adoc b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/avro-dataformat.adoc index 88cdafa53a10..546b33f603ae 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/avro-dataformat.adoc +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/avro-dataformat.adoc @@ -40,6 +40,17 @@ http://avro.apache.org/docs/current/[Apache Avro documentation]. include::partial$dataformat-options.adoc[] // dataformat options: END +== Trusted packages apply to the whole JVM + +Avro validates the classes it loads for a schema, and only loads classes from trusted packages. Camel adds the +package of the `instanceClassName` option, the namespaces of the schema, and the packages of the +`serializablePackages` option to these trusted packages. + +Avro has one class validator for the whole JVM. So a package trusted by one data format is trusted for all Avro class +resolution in the JVM: for every Avro data format, every xref:components::avro-component.adoc[Avro RPC] endpoint and +every Camel context in the same JVM. A trusted package stays trusted until the JVM is restarted; stopping the route +does not remove it. Only add packages that hold your own Avro model classes. + == Examples === Avro Data Format usage diff --git a/components/camel-avro-rpc/camel-avro-rpc-component/src/generated/resources/META-INF/org/apache/camel/component/avro/avro.json b/components/camel-avro-rpc/camel-avro-rpc-component/src/generated/resources/META-INF/org/apache/camel/component/avro/avro.json index 4130965ceb82..ad53845f1d74 100644 --- a/components/camel-avro-rpc/camel-avro-rpc-component/src/generated/resources/META-INF/org/apache/camel/component/avro/avro.json +++ b/components/camel-avro-rpc/camel-avro-rpc-component/src/generated/resources/META-INF/org/apache/camel/component/avro/avro.json @@ -24,8 +24,8 @@ "remote": true }, "componentProperties": { - "protocol": { "index": 0, "kind": "property", "displayName": "Protocol", "group": "common", "label": "", "required": false, "type": "object", "javaType": "org.apache.avro.Protocol", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "The Avro protocol (org.apache.avro.Protocol) that defines the messages, such as the PROTOCOL field of a class generate [...] - "protocolClassName": { "index": 1, "kind": "property", "displayName": "Protocol Class Name", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "The fully qualified name of the class that defines the protocol. For a class generated by the Avro compile [...] + "protocol": { "index": 0, "kind": "property", "displayName": "Protocol", "group": "common", "label": "", "required": false, "type": "object", "javaType": "org.apache.avro.Protocol", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "The Avro protocol (org.apache.avro.Protocol) that defines the messages, such as the PROTOCOL field of a class generate [...] + "protocolClassName": { "index": 1, "kind": "property", "displayName": "Protocol Class Name", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "The fully qualified name of the class that defines the protocol. For a class generated by the Avro compile [...] "protocolLocation": { "index": 2, "kind": "property", "displayName": "Protocol Location", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "Not used: the component does not read this option. Use protocol or protocolClassName instead." }, "reflectionProtocol": { "index": 3, "kind": "property", "displayName": "Reflection Protocol", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "Whether the protocol is a reflect protocol, built by Avro reflection from a Java interface [...] "singleParameter": { "index": 4, "kind": "property", "displayName": "Single Parameter", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "Whether the consumer sets the message body to the one parameter of the called message, instead o [...] @@ -34,7 +34,7 @@ "lazyStartProducer": { "index": 7, "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail [...] "autowiredEnabled": { "index": 8, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching t [...] "configuration": { "index": 9, "kind": "property", "displayName": "Configuration", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.avro.AvroConfiguration", "deprecated": false, "autowired": false, "secret": false, "description": "A shared configuration that every endpoint copies as its starting point. The options of the endpoint URI override its values." }, - "serializablePackages": { "index": 10, "kind": "property", "displayName": "Serializable Packages", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "security": "insecure:serialization", "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "Comma-separated list of additional packages that con [...] + "serializablePackages": { "index": 10, "kind": "property", "displayName": "Serializable Packages", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "security": "insecure:serialization", "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "Comma-separated list of additional packages that con [...] }, "headers": { "CamelAvroMessageName": { "index": 0, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "autowired": false, "secret": false, "description": "The name of the protocol message to call. The producer reads it, and it takes precedence over the messageName of the endpoint. The consumer sets it to the name of the called message.", "constantName": "org.apache.camel.component.avro.AvroConstants#AVRO_MESSAGE_NAME" } @@ -50,8 +50,8 @@ "port": { "index": 1, "kind": "path", "displayName": "Port", "group": "common", "label": "", "required": true, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "The port number. The consumer listens on it, and the producer connects to it." }, "host": { "index": 2, "kind": "path", "displayName": "Host", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "The host name or IP address. The consumer binds its server to it, and the producer connects to it." }, "messageName": { "index": 3, "kind": "path", "displayName": "Message Name", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "The name of the protocol message to call or serve. The producer calls it unless the CamelAvroMessageName header is set. A c [...] - "protocol": { "index": 4, "kind": "parameter", "displayName": "Protocol", "group": "common", "label": "", "required": false, "type": "object", "javaType": "org.apache.avro.Protocol", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "The Avro protocol (org.apache.avro.Protocol) that defines the messages, such as the PROTOCOL field of a class generat [...] - "protocolClassName": { "index": 5, "kind": "parameter", "displayName": "Protocol Class Name", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "The fully qualified name of the class that defines the protocol. For a class generated by the Avro compil [...] + "protocol": { "index": 4, "kind": "parameter", "displayName": "Protocol", "group": "common", "label": "", "required": false, "type": "object", "javaType": "org.apache.avro.Protocol", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "The Avro protocol (org.apache.avro.Protocol) that defines the messages, such as the PROTOCOL field of a class generat [...] + "protocolClassName": { "index": 5, "kind": "parameter", "displayName": "Protocol Class Name", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "The fully qualified name of the class that defines the protocol. For a class generated by the Avro compil [...] "protocolLocation": { "index": 6, "kind": "parameter", "displayName": "Protocol Location", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "Not used: the component does not read this option. Use protocol or protocolClassName instead." }, "reflectionProtocol": { "index": 7, "kind": "parameter", "displayName": "Reflection Protocol", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "Whether the protocol is a reflect protocol, built by Avro reflection from a Java interfac [...] "singleParameter": { "index": 8, "kind": "parameter", "displayName": "Single Parameter", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "Whether the consumer sets the message body to the one parameter of the called message, instead [...] @@ -60,6 +60,6 @@ "exceptionHandler": { "index": 11, "kind": "parameter", "displayName": "Exception Handler", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.spi.ExceptionHandler", "optionalPrefix": "consumer.", "deprecated": false, "autowired": false, "secret": false, "description": "To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By de [...] "exchangePattern": { "index": 12, "kind": "parameter", "displayName": "Exchange Pattern", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "enum", "javaType": "org.apache.camel.ExchangePattern", "enum": [ "InOnly", "InOut" ], "deprecated": false, "autowired": false, "secret": false, "description": "Sets the exchange pattern when the consumer creates an exchange." }, "lazyStartProducer": { "index": 13, "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a produ [...] - "serializablePackages": { "index": 14, "kind": "parameter", "displayName": "Serializable Packages", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "security": "insecure:serialization", "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "Comma-separated list of additional packages that co [...] + "serializablePackages": { "index": 14, "kind": "parameter", "displayName": "Serializable Packages", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "security": "insecure:serialization", "configurationClass": "org.apache.camel.component.avro.AvroConfiguration", "configurationField": "configuration", "description": "Comma-separated list of additional packages that co [...] } } diff --git a/components/camel-avro-rpc/camel-avro-rpc-component/src/main/docs/avro-component.adoc b/components/camel-avro-rpc/camel-avro-rpc-component/src/main/docs/avro-component.adoc index 572d94a7ef69..c186f9b588b4 100644 --- a/components/camel-avro-rpc/camel-avro-rpc-component/src/main/docs/avro-component.adoc +++ b/components/camel-avro-rpc/camel-avro-rpc-component/src/main/docs/avro-component.adoc @@ -145,6 +145,17 @@ got only one parameter, *since 2.12* you can use `singleParameter` URI option to receive it directly in the "in" message body without array wrapping. +=== Trusted packages apply to the whole JVM + +Avro validates the classes it loads for a schema, and only loads classes from trusted packages. Camel adds the +packages of the `protocol` or `protocolClassName` option, and the packages of the `serializablePackages` option, to +these trusted packages. + +Avro has one class validator for the whole JVM. So a package trusted by one endpoint is trusted for all Avro class +resolution in the JVM: for every Avro RPC endpoint, every xref:dataformats:avro-dataformat.adoc[Avro data format] and +every Camel context in the same JVM. A trusted package stays trusted until the JVM is restarted; stopping the endpoint +or the route does not remove it. Only add packages that hold your own Avro model classes. + == Examples An example of using camel avro producers via http: diff --git a/components/camel-avro-rpc/camel-avro-rpc-component/src/main/java/org/apache/camel/component/avro/AvroConfiguration.java b/components/camel-avro-rpc/camel-avro-rpc-component/src/main/java/org/apache/camel/component/avro/AvroConfiguration.java index 910d7661afda..c83994860aed 100644 --- a/components/camel-avro-rpc/camel-avro-rpc-component/src/main/java/org/apache/camel/component/avro/AvroConfiguration.java +++ b/components/camel-avro-rpc/camel-avro-rpc-component/src/main/java/org/apache/camel/component/avro/AvroConfiguration.java @@ -49,11 +49,14 @@ public class AvroConfiguration implements Cloneable { private String protocolLocation; @UriParam(description = "The Avro protocol (org.apache.avro.Protocol) that defines the messages, such as the PROTOCOL field" + " of a class generated by the Avro compiler. Set this option or protocolClassName: the endpoint" - + " fails to start without a protocol.") + + " fails to start without a protocol." + + " Camel adds the packages of the protocol to the trusted packages of Avro, which apply to the whole JVM: see serializablePackages.") private Protocol protocol; @UriParam(description = "The fully qualified name of the class that defines the protocol. For a class generated by the Avro" + " compiler, its static PROTOCOL field is used; for any other class or interface, Avro reflection" - + " builds the protocol and reflectionProtocol is turned on. Ignored when protocol is set.") + + " builds the protocol and reflectionProtocol is turned on. Ignored when protocol is set." + + " Camel adds the package of the class to the trusted packages of Avro, which apply to the whole" + + " JVM: see serializablePackages.") private String protocolClassName; @UriParam(description = "The authority (host and port) of the endpoint URI, which the component sets from the URI." + " Consumers with the same authority share one Avro server, created with the protocol of the first" @@ -190,6 +193,10 @@ public class AvroConfiguration implements Cloneable { * Comma-separated list of additional packages that contain trusted Avro model classes. Avro 1.12+ validates classes * resolved from schemas; Camel automatically trusts {@code org.apache.avro} for IPC and packages derived from the * configured protocol. Use this option for any additional model packages not inferred from the protocol. + * <p> + * Avro has one class validator for the whole JVM. A package trusted by one endpoint is trusted for all Avro class + * resolution in the JVM, by every endpoint, Avro data format and Camel context, and stays trusted until the JVM is + * restarted: stopping the endpoint or the route does not remove it. */ public void setSerializablePackages(String serializablePackages) { this.serializablePackages = serializablePackages; diff --git a/components/camel-avro/src/main/docs/avro-dataformat.adoc b/components/camel-avro/src/main/docs/avro-dataformat.adoc index 88cdafa53a10..546b33f603ae 100644 --- a/components/camel-avro/src/main/docs/avro-dataformat.adoc +++ b/components/camel-avro/src/main/docs/avro-dataformat.adoc @@ -40,6 +40,17 @@ http://avro.apache.org/docs/current/[Apache Avro documentation]. include::partial$dataformat-options.adoc[] // dataformat options: END +== Trusted packages apply to the whole JVM + +Avro validates the classes it loads for a schema, and only loads classes from trusted packages. Camel adds the +package of the `instanceClassName` option, the namespaces of the schema, and the packages of the +`serializablePackages` option to these trusted packages. + +Avro has one class validator for the whole JVM. So a package trusted by one data format is trusted for all Avro class +resolution in the JVM: for every Avro data format, every xref:components::avro-component.adoc[Avro RPC] endpoint and +every Camel context in the same JVM. A trusted package stays trusted until the JVM is restarted; stopping the route +does not remove it. Only add packages that hold your own Avro model classes. + == Examples === Avro Data Format usage diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AvroComponentBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AvroComponentBuilderFactory.java index 663e0e301e01..f7e13ae39624 100644 --- a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AvroComponentBuilderFactory.java +++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AvroComponentBuilderFactory.java @@ -54,7 +54,9 @@ public interface AvroComponentBuilderFactory { * The Avro protocol (org.apache.avro.Protocol) that defines the * messages, such as the PROTOCOL field of a class generated by the Avro * compiler. Set this option or protocolClassName: the endpoint fails to - * start without a protocol. + * start without a protocol. Camel adds the packages of the protocol to + * the trusted packages of Avro, which apply to the whole JVM: see + * serializablePackages. * * The option is a: <code>org.apache.avro.Protocol</code> * type. @@ -74,7 +76,8 @@ public interface AvroComponentBuilderFactory { * a class generated by the Avro compiler, its static PROTOCOL field is * used; for any other class or interface, Avro reflection builds the * protocol and reflectionProtocol is turned on. Ignored when protocol - * is set. + * is set. Camel adds the package of the class to the trusted packages + * of Avro, which apply to the whole JVM: see serializablePackages. * * The option is a: <code>java.lang.String</code> type. * @@ -263,7 +266,12 @@ public interface AvroComponentBuilderFactory { * model classes. Avro 1.12+ validates classes resolved from schemas; * Camel automatically trusts org.apache.avro for IPC and packages * derived from the configured protocol. Use this option for any - * additional model packages not inferred from the protocol. + * additional model packages not inferred from the protocol. Avro has + * one class validator for the whole JVM. A package trusted by one + * endpoint is trusted for all Avro class resolution in the JVM, by + * every endpoint, Avro data format and Camel context, and stays trusted + * until the JVM is restarted: stopping the endpoint or the route does + * not remove it. * * The option is a: <code>java.lang.String</code> type. * diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/AvroEndpointBuilderFactory.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/AvroEndpointBuilderFactory.java index 24f55f4e2425..c1252c22f5a2 100644 --- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/AvroEndpointBuilderFactory.java +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/AvroEndpointBuilderFactory.java @@ -47,7 +47,9 @@ public interface AvroEndpointBuilderFactory { * The Avro protocol (org.apache.avro.Protocol) that defines the * messages, such as the PROTOCOL field of a class generated by the Avro * compiler. Set this option or protocolClassName: the endpoint fails to - * start without a protocol. + * start without a protocol. Camel adds the packages of the protocol to + * the trusted packages of Avro, which apply to the whole JVM: see + * serializablePackages. * * The option is a: <code>org.apache.avro.Protocol</code> type. * @@ -64,7 +66,9 @@ public interface AvroEndpointBuilderFactory { * The Avro protocol (org.apache.avro.Protocol) that defines the * messages, such as the PROTOCOL field of a class generated by the Avro * compiler. Set this option or protocolClassName: the endpoint fails to - * start without a protocol. + * start without a protocol. Camel adds the packages of the protocol to + * the trusted packages of Avro, which apply to the whole JVM: see + * serializablePackages. * * The option will be converted to a * <code>org.apache.avro.Protocol</code> type. @@ -83,7 +87,8 @@ public interface AvroEndpointBuilderFactory { * a class generated by the Avro compiler, its static PROTOCOL field is * used; for any other class or interface, Avro reflection builds the * protocol and reflectionProtocol is turned on. Ignored when protocol - * is set. + * is set. Camel adds the package of the class to the trusted packages + * of Avro, which apply to the whole JVM: see serializablePackages. * * The option is a: <code>java.lang.String</code> type. * @@ -212,7 +217,12 @@ public interface AvroEndpointBuilderFactory { * model classes. Avro 1.12+ validates classes resolved from schemas; * Camel automatically trusts org.apache.avro for IPC and packages * derived from the configured protocol. Use this option for any - * additional model packages not inferred from the protocol. + * additional model packages not inferred from the protocol. Avro has + * one class validator for the whole JVM. A package trusted by one + * endpoint is trusted for all Avro class resolution in the JVM, by + * every endpoint, Avro data format and Camel context, and stays trusted + * until the JVM is restarted: stopping the endpoint or the route does + * not remove it. * * The option is a: <code>java.lang.String</code> type. * @@ -369,7 +379,9 @@ public interface AvroEndpointBuilderFactory { * The Avro protocol (org.apache.avro.Protocol) that defines the * messages, such as the PROTOCOL field of a class generated by the Avro * compiler. Set this option or protocolClassName: the endpoint fails to - * start without a protocol. + * start without a protocol. Camel adds the packages of the protocol to + * the trusted packages of Avro, which apply to the whole JVM: see + * serializablePackages. * * The option is a: <code>org.apache.avro.Protocol</code> type. * @@ -386,7 +398,9 @@ public interface AvroEndpointBuilderFactory { * The Avro protocol (org.apache.avro.Protocol) that defines the * messages, such as the PROTOCOL field of a class generated by the Avro * compiler. Set this option or protocolClassName: the endpoint fails to - * start without a protocol. + * start without a protocol. Camel adds the packages of the protocol to + * the trusted packages of Avro, which apply to the whole JVM: see + * serializablePackages. * * The option will be converted to a * <code>org.apache.avro.Protocol</code> type. @@ -405,7 +419,8 @@ public interface AvroEndpointBuilderFactory { * a class generated by the Avro compiler, its static PROTOCOL field is * used; for any other class or interface, Avro reflection builds the * protocol and reflectionProtocol is turned on. Ignored when protocol - * is set. + * is set. Camel adds the package of the class to the trusted packages + * of Avro, which apply to the whole JVM: see serializablePackages. * * The option is a: <code>java.lang.String</code> type. * @@ -534,7 +549,12 @@ public interface AvroEndpointBuilderFactory { * model classes. Avro 1.12+ validates classes resolved from schemas; * Camel automatically trusts org.apache.avro for IPC and packages * derived from the configured protocol. Use this option for any - * additional model packages not inferred from the protocol. + * additional model packages not inferred from the protocol. Avro has + * one class validator for the whole JVM. A package trusted by one + * endpoint is trusted for all Avro class resolution in the JVM, by + * every endpoint, Avro data format and Camel context, and stays trusted + * until the JVM is restarted: stopping the endpoint or the route does + * not remove it. * * The option is a: <code>java.lang.String</code> type. * @@ -620,7 +640,9 @@ public interface AvroEndpointBuilderFactory { * The Avro protocol (org.apache.avro.Protocol) that defines the * messages, such as the PROTOCOL field of a class generated by the Avro * compiler. Set this option or protocolClassName: the endpoint fails to - * start without a protocol. + * start without a protocol. Camel adds the packages of the protocol to + * the trusted packages of Avro, which apply to the whole JVM: see + * serializablePackages. * * The option is a: <code>org.apache.avro.Protocol</code> type. * @@ -637,7 +659,9 @@ public interface AvroEndpointBuilderFactory { * The Avro protocol (org.apache.avro.Protocol) that defines the * messages, such as the PROTOCOL field of a class generated by the Avro * compiler. Set this option or protocolClassName: the endpoint fails to - * start without a protocol. + * start without a protocol. Camel adds the packages of the protocol to + * the trusted packages of Avro, which apply to the whole JVM: see + * serializablePackages. * * The option will be converted to a * <code>org.apache.avro.Protocol</code> type. @@ -656,7 +680,8 @@ public interface AvroEndpointBuilderFactory { * a class generated by the Avro compiler, its static PROTOCOL field is * used; for any other class or interface, Avro reflection builds the * protocol and reflectionProtocol is turned on. Ignored when protocol - * is set. + * is set. Camel adds the package of the class to the trusted packages + * of Avro, which apply to the whole JVM: see serializablePackages. * * The option is a: <code>java.lang.String</code> type. * @@ -785,7 +810,12 @@ public interface AvroEndpointBuilderFactory { * model classes. Avro 1.12+ validates classes resolved from schemas; * Camel automatically trusts org.apache.avro for IPC and packages * derived from the configured protocol. Use this option for any - * additional model packages not inferred from the protocol. + * additional model packages not inferred from the protocol. Avro has + * one class validator for the whole JVM. A package trusted by one + * endpoint is trusted for all Avro class resolution in the JVM, by + * every endpoint, Avro data format and Camel context, and stays trusted + * until the JVM is restarted: stopping the endpoint or the route does + * not remove it. * * The option is a: <code>java.lang.String</code> type. *
