This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch CAMEL-27748-minio-endpoint-scheme in repository https://gitbox.apache.org/repos/asf/camel.git
commit 28347dcef922bee4c3905e0d51d7036e2193dfdc Author: Claus Ibsen <[email protected]> AuthorDate: Fri Nov 27 21:21:45 2026 +0100 CAMEL-27748: camel-minio - the scheme of the endpoint is ignored when proxyPort is set With proxyPort, the endpoint used MinioClient.Builder.endpoint(endpoint, port, secure), which replaces the scheme of the endpoint with the secure flag (false by default). So an https:// endpoint with proxyPort connected with plain HTTP, and an http:// endpoint with secure=true used HTTPS. An endpoint with the http:// or https:// scheme now keeps its scheme; the secure option applies only to a host name without a scheme. secure=true with an http:// endpoint logs a WARN. Option descriptions and the upgrade guide are updated. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Claus Ibsen <[email protected]> --- .../org/apache/camel/catalog/components/minio.json | 8 +- .../org/apache/camel/component/minio/minio.json | 8 +- .../camel/component/minio/MinioConfiguration.java | 10 +- .../camel/component/minio/MinioEndpoint.java | 22 +++- .../component/minio/MinioProxyPortSchemeTest.java | 124 +++++++++++++++++++++ .../ROOT/pages/camel-4x-upgrade-guide-4_24.adoc | 7 ++ .../dsl/MinioComponentBuilderFactory.java | 10 +- .../endpoint/dsl/MinioEndpointBuilderFactory.java | 60 ++++++---- 8 files changed, 208 insertions(+), 41 deletions(-) diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/minio.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/minio.json index 2bdf9f0dcb17..8a012834b705 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/minio.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/minio.json @@ -30,9 +30,9 @@ "minioClient": { "index": 3, "kind": "property", "displayName": "Minio Client", "group": "common", "label": "common", "required": false, "type": "object", "javaType": "io.minio.MinioClient", "deprecated": false, "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "To use a custom io.minio.MinioClient. When this option is set or autowired, the endpoint, proxyPort, secure, [...] "objectLock": { "index": 4, "kind": "property", "displayName": "Object Lock", "group": "common", "label": "common", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "Whether to enable object locking on the buckets that the component creates (see autoCreateBucket). [...] "policy": { "index": 5, "kind": "property", "displayName": "Policy", "group": "common", "label": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "The bucket policy, as JSON, that the endpoint sets on the bucket at startup. Not applied when objectName is set." }, - "proxyPort": { "index": 6, "kind": "property", "displayName": "Proxy Port", "group": "common", "label": "common", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "The TCP port of the server. When set, it replaces the port of the endpoint option, and the secure option sets the [...] + "proxyPort": { "index": 6, "kind": "property", "displayName": "Proxy Port", "group": "common", "label": "common", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "The TCP port of the server. When set, it replaces the port of the endpoint option. An endpoint with the http:\/\/ [...] "region": { "index": 7, "kind": "property", "displayName": "Region", "group": "common", "label": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "The region of the server, for example us-east-1. The client signs its requests for this region, and the component creates [...] - "secure": { "index": 8, "kind": "property", "displayName": "Secure", "group": "common", "label": "common", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "Whether the client uses HTTPS (true) or HTTP (false) when proxyPort is set. Without proxyPort, this option [...] + "secure": { "index": 8, "kind": "property", "displayName": "Secure", "group": "common", "label": "common", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "Whether the client uses HTTPS (true) or HTTP (false) when proxyPort is set and the endpoint option is a hos [...] "autoCloseBody": { "index": 9, "kind": "property", "displayName": "Auto Close Body", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "Whether the consumer closes the stream that it read the content of the object from, when [...] "bridgeErrorHandler": { "index": 10, "kind": "property", "displayName": "Bridge Error Handler", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming messages, or the lik [...] "bypassGovernanceMode": { "index": 11, "kind": "property", "displayName": "Bypass Governance Mode", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "Whether the consumer bypasses the governance mode retention of object lo [...] @@ -111,9 +111,9 @@ "minioClient": { "index": 3, "kind": "parameter", "displayName": "Minio Client", "group": "common", "label": "common", "required": false, "type": "object", "javaType": "io.minio.MinioClient", "deprecated": false, "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "To use a custom io.minio.MinioClient. When this option is set or autowired, the endpoint, proxyPort, secure [...] "objectLock": { "index": 4, "kind": "parameter", "displayName": "Object Lock", "group": "common", "label": "common", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "Whether to enable object locking on the buckets that the component creates (see autoCreateBucket) [...] "policy": { "index": 5, "kind": "parameter", "displayName": "Policy", "group": "common", "label": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "The bucket policy, as JSON, that the endpoint sets on the bucket at startup. Not applied when objectName is set." }, - "proxyPort": { "index": 6, "kind": "parameter", "displayName": "Proxy Port", "group": "common", "label": "common", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "The TCP port of the server. When set, it replaces the port of the endpoint option, and the secure option sets th [...] + "proxyPort": { "index": 6, "kind": "parameter", "displayName": "Proxy Port", "group": "common", "label": "common", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "The TCP port of the server. When set, it replaces the port of the endpoint option. An endpoint with the http:\/\ [...] "region": { "index": 7, "kind": "parameter", "displayName": "Region", "group": "common", "label": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "The region of the server, for example us-east-1. The client signs its requests for this region, and the component creates [...] - "secure": { "index": 8, "kind": "parameter", "displayName": "Secure", "group": "common", "label": "common", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "Whether the client uses HTTPS (true) or HTTP (false) when proxyPort is set. Without proxyPort, this option [...] + "secure": { "index": 8, "kind": "parameter", "displayName": "Secure", "group": "common", "label": "common", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "Whether the client uses HTTPS (true) or HTTP (false) when proxyPort is set and the endpoint option is a ho [...] "autoCloseBody": { "index": 9, "kind": "parameter", "displayName": "Auto Close Body", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "Whether the consumer closes the stream that it read the content of the object from, whe [...] "bypassGovernanceMode": { "index": 10, "kind": "parameter", "displayName": "Bypass Governance Mode", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "Whether the consumer bypasses the governance mode retention of object l [...] "deleteAfterRead": { "index": 11, "kind": "parameter", "displayName": "Delete After Read", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "Whether the consumer deletes the object from the bucket after the exchange complet [...] diff --git a/components/camel-minio/src/generated/resources/META-INF/org/apache/camel/component/minio/minio.json b/components/camel-minio/src/generated/resources/META-INF/org/apache/camel/component/minio/minio.json index 2bdf9f0dcb17..8a012834b705 100644 --- a/components/camel-minio/src/generated/resources/META-INF/org/apache/camel/component/minio/minio.json +++ b/components/camel-minio/src/generated/resources/META-INF/org/apache/camel/component/minio/minio.json @@ -30,9 +30,9 @@ "minioClient": { "index": 3, "kind": "property", "displayName": "Minio Client", "group": "common", "label": "common", "required": false, "type": "object", "javaType": "io.minio.MinioClient", "deprecated": false, "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "To use a custom io.minio.MinioClient. When this option is set or autowired, the endpoint, proxyPort, secure, [...] "objectLock": { "index": 4, "kind": "property", "displayName": "Object Lock", "group": "common", "label": "common", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "Whether to enable object locking on the buckets that the component creates (see autoCreateBucket). [...] "policy": { "index": 5, "kind": "property", "displayName": "Policy", "group": "common", "label": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "The bucket policy, as JSON, that the endpoint sets on the bucket at startup. Not applied when objectName is set." }, - "proxyPort": { "index": 6, "kind": "property", "displayName": "Proxy Port", "group": "common", "label": "common", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "The TCP port of the server. When set, it replaces the port of the endpoint option, and the secure option sets the [...] + "proxyPort": { "index": 6, "kind": "property", "displayName": "Proxy Port", "group": "common", "label": "common", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "The TCP port of the server. When set, it replaces the port of the endpoint option. An endpoint with the http:\/\/ [...] "region": { "index": 7, "kind": "property", "displayName": "Region", "group": "common", "label": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "The region of the server, for example us-east-1. The client signs its requests for this region, and the component creates [...] - "secure": { "index": 8, "kind": "property", "displayName": "Secure", "group": "common", "label": "common", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "Whether the client uses HTTPS (true) or HTTP (false) when proxyPort is set. Without proxyPort, this option [...] + "secure": { "index": 8, "kind": "property", "displayName": "Secure", "group": "common", "label": "common", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "Whether the client uses HTTPS (true) or HTTP (false) when proxyPort is set and the endpoint option is a hos [...] "autoCloseBody": { "index": 9, "kind": "property", "displayName": "Auto Close Body", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "Whether the consumer closes the stream that it read the content of the object from, when [...] "bridgeErrorHandler": { "index": 10, "kind": "property", "displayName": "Bridge Error Handler", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming messages, or the lik [...] "bypassGovernanceMode": { "index": 11, "kind": "property", "displayName": "Bypass Governance Mode", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "Whether the consumer bypasses the governance mode retention of object lo [...] @@ -111,9 +111,9 @@ "minioClient": { "index": 3, "kind": "parameter", "displayName": "Minio Client", "group": "common", "label": "common", "required": false, "type": "object", "javaType": "io.minio.MinioClient", "deprecated": false, "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "To use a custom io.minio.MinioClient. When this option is set or autowired, the endpoint, proxyPort, secure [...] "objectLock": { "index": 4, "kind": "parameter", "displayName": "Object Lock", "group": "common", "label": "common", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "Whether to enable object locking on the buckets that the component creates (see autoCreateBucket) [...] "policy": { "index": 5, "kind": "parameter", "displayName": "Policy", "group": "common", "label": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "The bucket policy, as JSON, that the endpoint sets on the bucket at startup. Not applied when objectName is set." }, - "proxyPort": { "index": 6, "kind": "parameter", "displayName": "Proxy Port", "group": "common", "label": "common", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "The TCP port of the server. When set, it replaces the port of the endpoint option, and the secure option sets th [...] + "proxyPort": { "index": 6, "kind": "parameter", "displayName": "Proxy Port", "group": "common", "label": "common", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "The TCP port of the server. When set, it replaces the port of the endpoint option. An endpoint with the http:\/\ [...] "region": { "index": 7, "kind": "parameter", "displayName": "Region", "group": "common", "label": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "The region of the server, for example us-east-1. The client signs its requests for this region, and the component creates [...] - "secure": { "index": 8, "kind": "parameter", "displayName": "Secure", "group": "common", "label": "common", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "Whether the client uses HTTPS (true) or HTTP (false) when proxyPort is set. Without proxyPort, this option [...] + "secure": { "index": 8, "kind": "parameter", "displayName": "Secure", "group": "common", "label": "common", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "Whether the client uses HTTPS (true) or HTTP (false) when proxyPort is set and the endpoint option is a ho [...] "autoCloseBody": { "index": 9, "kind": "parameter", "displayName": "Auto Close Body", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "Whether the consumer closes the stream that it read the content of the object from, whe [...] "bypassGovernanceMode": { "index": 10, "kind": "parameter", "displayName": "Bypass Governance Mode", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "Whether the consumer bypasses the governance mode retention of object l [...] "deleteAfterRead": { "index": 11, "kind": "parameter", "displayName": "Delete After Read", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.minio.MinioConfiguration", "configurationField": "configuration", "description": "Whether the consumer deletes the object from the bucket after the exchange complet [...] diff --git a/components/camel-minio/src/main/java/org/apache/camel/component/minio/MinioConfiguration.java b/components/camel-minio/src/main/java/org/apache/camel/component/minio/MinioConfiguration.java index 48b6b2e8879c..5cbb40d9f3a4 100644 --- a/components/camel-minio/src/main/java/org/apache/camel/component/minio/MinioConfiguration.java +++ b/components/camel-minio/src/main/java/org/apache/camel/component/minio/MinioConfiguration.java @@ -42,12 +42,14 @@ public class MinioConfiguration implements Cloneable { + "443. Required unless minioClient is set.", label = "common") private String endpoint; - @UriParam(description = "The TCP port of the server. When set, it replaces the port of the endpoint option, and the " - + "secure option sets the scheme. Not used when minioClient is set.", + @UriParam(description = "The TCP port of the server. When set, it replaces the port of the endpoint option. An " + + "endpoint with the http:// or https:// scheme keeps its scheme; for a host name without a scheme, " + + "the secure option sets it. Not used when minioClient is set.", label = "common") private Integer proxyPort; - @UriParam(description = "Whether the client uses HTTPS (true) or HTTP (false) when proxyPort is set. Without proxyPort, " - + "this option is not used and the scheme of the endpoint option applies.", + @UriParam(description = "Whether the client uses HTTPS (true) or HTTP (false) when proxyPort is set and the endpoint " + + "option is a host name without a scheme. When the endpoint has the http:// or https:// scheme, " + + "or proxyPort is not set, this option is not used and the scheme of the endpoint applies.", label = "common") private boolean secure; @UriParam(description = "The region of the server, for example us-east-1. The client signs its requests for this region, " diff --git a/components/camel-minio/src/main/java/org/apache/camel/component/minio/MinioEndpoint.java b/components/camel-minio/src/main/java/org/apache/camel/component/minio/MinioEndpoint.java index 9abf542ddcca..8e1aa920e3a8 100644 --- a/components/camel-minio/src/main/java/org/apache/camel/component/minio/MinioEndpoint.java +++ b/components/camel-minio/src/main/java/org/apache/camel/component/minio/MinioEndpoint.java @@ -16,6 +16,8 @@ */ package org.apache.camel.component.minio; +import java.util.Locale; + import io.minio.BucketExistsArgs; import io.minio.MakeBucketArgs; import io.minio.MinioClient; @@ -185,7 +187,7 @@ public class MinioEndpoint extends ScheduledPollEndpoint implements EndpointServ if (isNotEmpty(configuration.getProxyPort())) { minioClientRequest.endpoint(configuration.getEndpoint(), configuration.getProxyPort(), - configuration.isSecure()); + isSecureForProxyPort(configuration.getEndpoint(), configuration.isSecure())); } else { minioClientRequest.endpoint(configuration.getEndpoint()); } @@ -205,6 +207,24 @@ public class MinioEndpoint extends ScheduledPollEndpoint implements EndpointServ } } + /** + * The MinIO client replaces the scheme of the endpoint with the secure flag when a port is given. An endpoint with + * a scheme keeps its scheme; the secure option applies only to a host name without a scheme. + */ + static boolean isSecureForProxyPort(String endpoint, boolean secure) { + String lower = endpoint.trim().toLowerCase(Locale.ROOT); + if (lower.startsWith("https://")) { + return true; + } + if (lower.startsWith("http://")) { + if (secure) { + LOG.warn("The secure option is not used, as the endpoint {} has the http:// scheme", endpoint); + } + return false; + } + return secure; + } + private boolean bucketExists(String bucketName) throws Exception { return minioClient.bucketExists(BucketExistsArgs.builder().bucket(bucketName).build()); } diff --git a/components/camel-minio/src/test/java/org/apache/camel/component/minio/MinioProxyPortSchemeTest.java b/components/camel-minio/src/test/java/org/apache/camel/component/minio/MinioProxyPortSchemeTest.java new file mode 100644 index 000000000000..d29898e7b9b1 --- /dev/null +++ b/components/camel-minio/src/test/java/org/apache/camel/component/minio/MinioProxyPortSchemeTest.java @@ -0,0 +1,124 @@ +/* + * 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.minio; + +import java.io.IOException; +import java.io.InputStream; +import java.net.InetAddress; +import java.net.ServerSocket; +import java.net.Socket; +import java.net.SocketException; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.TimeUnit; + +import io.minio.BucketExistsArgs; +import io.minio.MinioClient; +import org.apache.camel.test.junit6.CamelTestSupport; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.awaitility.Awaitility.await; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * With proxyPort, the scheme of the endpoint decides between HTTPS and HTTP; secure only applies to a host name without + * a scheme. A loopback socket records the first byte of each connection: 0x16 starts a TLS ClientHello, a plain HTTP + * request starts with the letter of its method. + */ +public class MinioProxyPortSchemeTest extends CamelTestSupport { + + private static final int TLS_HANDSHAKE = 0x16; + + private ServerSocket serverSocket; + private Thread acceptor; + private final List<Integer> firstBytes = new CopyOnWriteArrayList<>(); + + @BeforeEach + void startSocket() throws IOException { + serverSocket = new ServerSocket(0, 50, InetAddress.getLoopbackAddress()); + acceptor = new Thread(() -> { + while (!serverSocket.isClosed()) { + try (Socket socket = serverSocket.accept()) { + socket.setSoTimeout(10000); + InputStream in = socket.getInputStream(); + firstBytes.add(in.read()); + } catch (SocketException e) { + // closed + } catch (IOException e) { + firstBytes.add(-2); + } + } + }, "minio-scheme-test"); + acceptor.setDaemon(true); + acceptor.start(); + } + + @AfterEach + void stopSocket() throws Exception { + serverSocket.close(); + acceptor.join(10000); + } + + @Test + public void httpsEndpointWithProxyPortUsesTls() throws Exception { + assertEquals(TLS_HANDSHAKE, firstByteOfRequest("https://localhost", "")); + } + + @Test + public void httpEndpointWithProxyPortAndSecureUsesPlainHttp() throws Exception { + int first = firstByteOfRequest("http://localhost", "&secure=true"); + assertTrue(first != TLS_HANDSHAKE && first > 0, "plain HTTP request expected, got " + first); + } + + @Test + public void hostNameWithProxyPortUsesSecure() throws Exception { + assertEquals(TLS_HANDSHAKE, firstByteOfRequest("localhost", "&secure=true")); + + firstBytes.clear(); + int first = firstByteOfRequest("localhost", ""); + assertTrue(first != TLS_HANDSHAKE && first > 0, "plain HTTP request expected, got " + first); + } + + @Test + public void isSecureForProxyPort() { + assertTrue(MinioEndpoint.isSecureForProxyPort("https://host", false)); + assertTrue(MinioEndpoint.isSecureForProxyPort("HTTPS://host", false)); + assertFalse(MinioEndpoint.isSecureForProxyPort("http://host", true)); + assertTrue(MinioEndpoint.isSecureForProxyPort("host", true)); + assertFalse(MinioEndpoint.isSecureForProxyPort("host", false)); + } + + private int firstByteOfRequest(String endpoint, String options) throws Exception { + MinioEndpoint minio = (MinioEndpoint) context.getComponent("minio", MinioComponent.class).createEndpoint( + "minio://mybucket?accessKey=key&secretKey=RAW(secret)®ion=us-east-1&endpoint=" + endpoint + + "&proxyPort=" + + serverSocket + .getLocalPort() + + options); + MinioClient client = minio.createMinioClient(); + + // the socket closes the connection, so the call fails; only the first byte that it sent matters + assertThrows(Exception.class, () -> client.bucketExists(BucketExistsArgs.builder().bucket("mybucket").build())); + await().atMost(10, TimeUnit.SECONDS).until(() -> !firstBytes.isEmpty()); + return firstBytes.get(0); + } +} diff --git a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc index 17af91664876..b4434eb32c57 100644 --- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc +++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc @@ -12664,6 +12664,13 @@ ignored without a message. An endpoint with `sslContextParameters`, or with `use global `SSLContextParameters`, now fails to start. Remove the option, and configure the trust store (and the key store for a client certificate) with the `javax.net.ssl.*` system properties of the JVM. +=== camel-minio - an endpoint with a scheme keeps it when proxyPort is set + +When `proxyPort` is set, the scheme of the `endpoint` option is now used: `endpoint=https://host&proxyPort=9000` +connects with HTTPS, and `endpoint=http://host&proxyPort=9000` with HTTP, also with `secure=true` (a WARN is logged). +Before, the scheme was ignored and `secure` (false by default) decided, so an `https://` endpoint with `proxyPort` +connected with plain HTTP. The `secure` option still applies to an endpoint that is a host name without a scheme. + === Kamelets - removed Kamelets The Kamelet catalog (camel-kamelets 4.24) removes Kamelets that could not work on Camel 4.23 or 4.24: diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/MinioComponentBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/MinioComponentBuilderFactory.java index d7509d605858..b8d76ce9c217 100644 --- a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/MinioComponentBuilderFactory.java +++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/MinioComponentBuilderFactory.java @@ -161,8 +161,9 @@ public interface MinioComponentBuilderFactory { /** * The TCP port of the server. When set, it replaces the port of the - * endpoint option, and the secure option sets the scheme. Not used when - * minioClient is set. + * endpoint option. An endpoint with the http:// or https:// scheme + * keeps its scheme; for a host name without a scheme, the secure option + * sets it. Not used when minioClient is set. * * The option is a: <code>java.lang.Integer</code> type. * @@ -196,8 +197,9 @@ public interface MinioComponentBuilderFactory { /** * Whether the client uses HTTPS (true) or HTTP (false) when proxyPort - * is set. Without proxyPort, this option is not used and the scheme of - * the endpoint option applies. + * is set and the endpoint option is a host name without a scheme. When + * the endpoint has the http:// or https:// scheme, or proxyPort is not + * set, this option is not used and the scheme of the endpoint applies. * * The option is a: <code>boolean</code> type. * diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/MinioEndpointBuilderFactory.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/MinioEndpointBuilderFactory.java index 4ba1fee7ef54..05a53803bd42 100644 --- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/MinioEndpointBuilderFactory.java +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/MinioEndpointBuilderFactory.java @@ -181,8 +181,9 @@ public interface MinioEndpointBuilderFactory { } /** * The TCP port of the server. When set, it replaces the port of the - * endpoint option, and the secure option sets the scheme. Not used when - * minioClient is set. + * endpoint option. An endpoint with the http:// or https:// scheme + * keeps its scheme; for a host name without a scheme, the secure option + * sets it. Not used when minioClient is set. * * The option is a: <code>java.lang.Integer</code> type. * @@ -197,8 +198,9 @@ public interface MinioEndpointBuilderFactory { } /** * The TCP port of the server. When set, it replaces the port of the - * endpoint option, and the secure option sets the scheme. Not used when - * minioClient is set. + * endpoint option. An endpoint with the http:// or https:// scheme + * keeps its scheme; for a host name without a scheme, the secure option + * sets it. Not used when minioClient is set. * * The option will be converted to a <code>java.lang.Integer</code> * type. @@ -230,8 +232,9 @@ public interface MinioEndpointBuilderFactory { } /** * Whether the client uses HTTPS (true) or HTTP (false) when proxyPort - * is set. Without proxyPort, this option is not used and the scheme of - * the endpoint option applies. + * is set and the endpoint option is a host name without a scheme. When + * the endpoint has the http:// or https:// scheme, or proxyPort is not + * set, this option is not used and the scheme of the endpoint applies. * * The option is a: <code>boolean</code> type. * @@ -247,8 +250,9 @@ public interface MinioEndpointBuilderFactory { } /** * Whether the client uses HTTPS (true) or HTTP (false) when proxyPort - * is set. Without proxyPort, this option is not used and the scheme of - * the endpoint option applies. + * is set and the endpoint option is a host name without a scheme. When + * the endpoint has the http:// or https:// scheme, or proxyPort is not + * set, this option is not used and the scheme of the endpoint applies. * * The option will be converted to a <code>boolean</code> type. * @@ -1933,8 +1937,9 @@ public interface MinioEndpointBuilderFactory { } /** * The TCP port of the server. When set, it replaces the port of the - * endpoint option, and the secure option sets the scheme. Not used when - * minioClient is set. + * endpoint option. An endpoint with the http:// or https:// scheme + * keeps its scheme; for a host name without a scheme, the secure option + * sets it. Not used when minioClient is set. * * The option is a: <code>java.lang.Integer</code> type. * @@ -1949,8 +1954,9 @@ public interface MinioEndpointBuilderFactory { } /** * The TCP port of the server. When set, it replaces the port of the - * endpoint option, and the secure option sets the scheme. Not used when - * minioClient is set. + * endpoint option. An endpoint with the http:// or https:// scheme + * keeps its scheme; for a host name without a scheme, the secure option + * sets it. Not used when minioClient is set. * * The option will be converted to a <code>java.lang.Integer</code> * type. @@ -1982,8 +1988,9 @@ public interface MinioEndpointBuilderFactory { } /** * Whether the client uses HTTPS (true) or HTTP (false) when proxyPort - * is set. Without proxyPort, this option is not used and the scheme of - * the endpoint option applies. + * is set and the endpoint option is a host name without a scheme. When + * the endpoint has the http:// or https:// scheme, or proxyPort is not + * set, this option is not used and the scheme of the endpoint applies. * * The option is a: <code>boolean</code> type. * @@ -1999,8 +2006,9 @@ public interface MinioEndpointBuilderFactory { } /** * Whether the client uses HTTPS (true) or HTTP (false) when proxyPort - * is set. Without proxyPort, this option is not used and the scheme of - * the endpoint option applies. + * is set and the endpoint option is a host name without a scheme. When + * the endpoint has the http:// or https:// scheme, or proxyPort is not + * set, this option is not used and the scheme of the endpoint applies. * * The option will be converted to a <code>boolean</code> type. * @@ -2496,8 +2504,9 @@ public interface MinioEndpointBuilderFactory { } /** * The TCP port of the server. When set, it replaces the port of the - * endpoint option, and the secure option sets the scheme. Not used when - * minioClient is set. + * endpoint option. An endpoint with the http:// or https:// scheme + * keeps its scheme; for a host name without a scheme, the secure option + * sets it. Not used when minioClient is set. * * The option is a: <code>java.lang.Integer</code> type. * @@ -2512,8 +2521,9 @@ public interface MinioEndpointBuilderFactory { } /** * The TCP port of the server. When set, it replaces the port of the - * endpoint option, and the secure option sets the scheme. Not used when - * minioClient is set. + * endpoint option. An endpoint with the http:// or https:// scheme + * keeps its scheme; for a host name without a scheme, the secure option + * sets it. Not used when minioClient is set. * * The option will be converted to a <code>java.lang.Integer</code> * type. @@ -2545,8 +2555,9 @@ public interface MinioEndpointBuilderFactory { } /** * Whether the client uses HTTPS (true) or HTTP (false) when proxyPort - * is set. Without proxyPort, this option is not used and the scheme of - * the endpoint option applies. + * is set and the endpoint option is a host name without a scheme. When + * the endpoint has the http:// or https:// scheme, or proxyPort is not + * set, this option is not used and the scheme of the endpoint applies. * * The option is a: <code>boolean</code> type. * @@ -2562,8 +2573,9 @@ public interface MinioEndpointBuilderFactory { } /** * Whether the client uses HTTPS (true) or HTTP (false) when proxyPort - * is set. Without proxyPort, this option is not used and the scheme of - * the endpoint option applies. + * is set and the endpoint option is a host name without a scheme. When + * the endpoint has the http:// or https:// scheme, or proxyPort is not + * set, this option is not used and the scheme of the endpoint applies. * * The option will be converted to a <code>boolean</code> type. *
