From 97f5eeb025c85de53eb5744d6c112f9699226f9c Mon Sep 17 00:00:00 2001 From: Jono Date: Mon, 26 Feb 2024 23:30:17 +1300 Subject: [PATCH 1/5] CAMEL-20019 add Vertx cookie handler implementation --- .../http/vertx/VertxPlatformHttpConsumer.java | 56 ++++ .../vertx/VertxPlatformHttpCookieTest.java | 264 ++++++++++++++++++ .../platform/http/PlatformHttpEndpoint.java | 26 ++ .../http/cookie/CookieConfiguration.java | 167 +++++++++++ .../platform/http/cookie/CookieHandler.java | 47 ++++ 5 files changed, 560 insertions(+) create mode 100644 components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpCookieTest.java create mode 100644 components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/cookie/CookieConfiguration.java create mode 100644 components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/cookie/CookieHandler.java diff --git a/components/camel-platform-http-vertx/src/main/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpConsumer.java b/components/camel-platform-http-vertx/src/main/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpConsumer.java index 446811ae9ca23..5fb666ef6dbe4 100644 --- a/components/camel-platform-http-vertx/src/main/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpConsumer.java +++ b/components/camel-platform-http-vertx/src/main/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpConsumer.java @@ -30,6 +30,8 @@ import io.vertx.core.Handler; import io.vertx.core.MultiMap; import io.vertx.core.Vertx; +import io.vertx.core.http.Cookie; +import io.vertx.core.http.CookieSameSite; import io.vertx.core.http.HttpMethod; import io.vertx.ext.auth.User; import io.vertx.ext.web.FileUpload; @@ -46,6 +48,8 @@ import org.apache.camel.attachment.AttachmentMessage; import org.apache.camel.attachment.CamelFileDataSource; import org.apache.camel.component.platform.http.PlatformHttpEndpoint; +import org.apache.camel.component.platform.http.cookie.CookieConfiguration; +import org.apache.camel.component.platform.http.cookie.CookieHandler; import org.apache.camel.component.platform.http.spi.Method; import org.apache.camel.spi.HeaderFilterStrategy; import org.apache.camel.support.DefaultConsumer; @@ -75,6 +79,7 @@ public class VertxPlatformHttpConsumer extends DefaultConsumer implements Suspen private Route route; private VertxPlatformHttpRouter router; private HttpRequestBodyHandler httpRequestBodyHandler; + private CookieConfiguration cookieConfiguration; public VertxPlatformHttpConsumer(PlatformHttpEndpoint endpoint, Processor processor, @@ -103,6 +108,9 @@ protected void doInit() throws Exception { } else { httpRequestBodyHandler = new DefaultHttpRequestBodyHandler(router.bodyHandler()); } + if (getEndpoint().isUseCookieHandler()) { + cookieConfiguration = getEndpoint().getCookieConfiguration(); + } } @Override @@ -269,6 +277,9 @@ protected Future processHttpRequest(Exchange exchange, RoutingContext ctx) if (user != null) { in.setHeader(VertxPlatformHttpConstants.AUTHENTICATED_USER, user); } + if (getEndpoint().isUseCookieHandler()) { + exchange.setProperty(Exchange.COOKIE_HANDLER, new VertxCookieHandler(ctx)); + } return populateCamelMessage(ctx, exchange, in); } @@ -335,4 +346,49 @@ protected void populateAttachments(List uploads, Message message) { } } } + + class VertxCookieHandler implements CookieHandler { + + private RoutingContext routingContext; + + VertxCookieHandler(RoutingContext routingContext) { + this.routingContext = routingContext; + } + + @Override + public void addCookie(String name, String value) { + Cookie cookie = Cookie.cookie(name, value) + .setPath(cookieConfiguration.getPath()) + .setDomain(cookieConfiguration.getDomain()) + .setSecure(cookieConfiguration.isSecure()) + .setHttpOnly(cookieConfiguration.isHttpOnly()) + .setSameSite(getSameSite(cookieConfiguration.getSameSite())); + if (cookieConfiguration.getMaxAge() != null) { + cookie.setMaxAge(cookieConfiguration.getMaxAge()); + } + routingContext.response().addCookie(cookie); + } + + private CookieSameSite getSameSite(CookieConfiguration.CookieSameSite sameSite) { + for (CookieSameSite css : CookieSameSite.values()) { + // 'Strict', 'Lax', or 'None' + if (css.toString().equals(sameSite.getValue())) { + return css; + } + } + return null; + } + + @Override + public String removeCookie(String name) { + Cookie cookie = routingContext.response().removeCookie(name); + return cookie == null ? null : cookie.getValue(); + } + + @Override + public String getCookieValue(String name) { + Cookie cookie = routingContext.request().getCookie(name); + return cookie == null ? null : cookie.getValue(); + } + } } diff --git a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpCookieTest.java b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpCookieTest.java new file mode 100644 index 0000000000000..6a0d054c0011c --- /dev/null +++ b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpCookieTest.java @@ -0,0 +1,264 @@ +/* + * 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.platform.http.vertx; + +import io.restassured.RestAssured; +import org.apache.camel.CamelContext; +import org.apache.camel.Exchange; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.platform.http.cookie.CookieConfiguration; +import org.apache.camel.component.platform.http.cookie.CookieHandler; +import org.apache.camel.impl.DefaultCamelContext; +import org.apache.camel.test.AvailablePortFinder; +import org.junit.jupiter.api.Test; + +import static io.restassured.RestAssured.given; +import static io.restassured.matcher.RestAssuredMatchers.detailedCookie; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.notNullValue; + +public class VertxPlatformHttpCookieTest { + + // add a cookie using the default cookie configuration + @Test + public void testAddCookie() throws Exception { + CamelContext context = createCamelContext(); + try { + context.addRoutes(new RouteBuilder() { + @Override + public void configure() { + from("platform-http:/add?useCookieHandler=true") + .process(exchange -> { + getCookieHandler(exchange).addCookie("foo", "bar"); + }) + .setBody().constant("add"); + } + }); + context.start(); + + given() + .when() + .get("/add") + .then() + .statusCode(200) + .cookie("foo", + detailedCookie() + .value("bar") + .path(CookieConfiguration.DEFAULT_PATH) + .domain((String) null) + .sameSite(CookieConfiguration.DEFAULT_SAME_SITE.getValue())) + .body(equalTo("add")); + } finally { + context.stop(); + } + } + + // add a cookie with specified CookieConfiguration properties + @Test + public void testAddCookieCustomConfiguration() throws Exception { + CamelContext context = createCamelContext(); + long cookieMaxAge = 60L * 60 * 24 * 7; // 1 week + context.getRegistry().bind("cookieConfiguration", + new CookieConfiguration.Builder() + .setPath("/testpath") + .setDomain("apache.org") + .setHttpOnly(true) + .setSecure(true) + .setMaxAge(cookieMaxAge) + .setSameSite(CookieConfiguration.CookieSameSite.LAX) + .build()); + + try { + context.addRoutes(new RouteBuilder() { + @Override + public void configure() { + from("platform-http:/add/custom?useCookieHandler=true&cookieConfiguration=#cookieConfiguration") + .process(exchange -> { + getCookieHandler(exchange).addCookie("foo", "bar"); + }) + .setBody().constant("add-custom"); + } + }); + context.start(); + + given() + .when() + .get("/add/custom") + .then() + .statusCode(200) + .cookie("foo", + detailedCookie() + .value("bar") + .path("/testpath") + .domain("apache.org") + .secured(true) + .httpOnly(true) + .maxAge(cookieMaxAge) + .sameSite("Lax")) + .body(equalTo("add-custom")); + } finally { + context.stop(); + } + } + + // get a cookie value from the cookieJar + @Test + public void testGetCookieValue() throws Exception { + CamelContext context = createCamelContext(); + try { + context.addRoutes(new RouteBuilder() { + @Override + public void configure() { + from("platform-http:/get?useCookieHandler=true") + .process(exchange -> { + // write cookie name/value as a header so we can verify it was read + String cookieName = "foo"; + String cookieVal = getCookieHandler(exchange).getCookieValue(cookieName); + exchange.getMessage().setHeader( + "cookie_name_val", String.format("%s=%s", cookieName, cookieVal)); + }) + .setBody().constant("get"); + } + }); + context.start(); + + given() + .header("cookie", "foo=bar") + .when() + .get("/get") + .then() + .statusCode(200) + .header("cookie_name_val", "foo=bar") // verify cookie read + .body(equalTo("get")); + } finally { + context.stop(); + } + } + + // expire a cookie in the user-agent/producers cookieJar + @Test + public void testRemoveCookie() throws Exception { + CamelContext context = createCamelContext(); + try { + context.addRoutes(new RouteBuilder() { + @Override + public void configure() { + from("platform-http:/remove?useCookieHandler=true") + .process(exchange -> { + getCookieHandler(exchange).removeCookie("foo"); + }) + .setBody().constant("remove"); + } + }); + context.start(); + + given() + .header("cookie", "foo=bar") + .when() + .get("/remove") + .then() + .statusCode(200) + .cookie("foo", + detailedCookie() + .maxAge(0) + .expiryDate(notNullValue())) + .body(equalTo("remove")); + } finally { + context.stop(); + } + } + + // attempt to expire a cookie that is not held in the cookieJar + @Test + public void testRemoveNoCookie() throws Exception { + CamelContext context = createCamelContext(); + try { + context.addRoutes(new RouteBuilder() { + @Override + public void configure() { + from("platform-http:/remove?useCookieHandler=true") + .process(exchange -> { + getCookieHandler(exchange).removeCookie("foo"); + }) + .setBody().constant("remove"); + } + }); + context.start(); + + given() + .when() + .get("/remove") + .then() + .statusCode(200) + .header("foo-cookie", (String) null) + .body(equalTo("remove")); + } finally { + context.stop(); + } + } + + // replace a cookie held in the cookieJar + @Test + public void testReplaceCookie() throws Exception { + CamelContext context = createCamelContext(); + try { + context.addRoutes(new RouteBuilder() { + @Override + public void configure() { + from("platform-http:/replace?useCookieHandler=true") + .process(exchange -> { + getCookieHandler(exchange) + .addCookie("XSRF-TOKEN", "88533580000c314"); + }) + .setBody().constant("replace"); + } + }); + context.start(); + + given() + .header("XSRF-TOKEN", "c359b44aef83415") + .when() + .get("/replace") + .then() + .statusCode(200) + .cookie("XSRF-TOKEN", + detailedCookie() + .value("88533580000c314") + .path(CookieConfiguration.DEFAULT_PATH) + .sameSite(CookieConfiguration.DEFAULT_SAME_SITE.getValue())) + .body(equalTo("replace")); + } finally { + context.stop(); + } + } + + private CookieHandler getCookieHandler(Exchange exchange) { + return exchange.getProperty(Exchange.COOKIE_HANDLER, CookieHandler.class); + } + + static CamelContext createCamelContext() throws Exception { + int port = AvailablePortFinder.getNextAvailable(); + VertxPlatformHttpServerConfiguration conf = new VertxPlatformHttpServerConfiguration(); + conf.setBindPort(port); + + RestAssured.port = port; + + CamelContext context = new DefaultCamelContext(); + context.addService(new VertxPlatformHttpServer(conf)); + return context; + } +} diff --git a/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpEndpoint.java b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpEndpoint.java index 3716e0b0f1ffe..4cd2a32793a83 100644 --- a/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpEndpoint.java +++ b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpEndpoint.java @@ -22,6 +22,7 @@ import org.apache.camel.Consumer; import org.apache.camel.Processor; import org.apache.camel.Producer; +import org.apache.camel.component.platform.http.cookie.CookieConfiguration; import org.apache.camel.component.platform.http.spi.PlatformHttpEngine; import org.apache.camel.spi.HeaderFilterStrategy; import org.apache.camel.spi.HeaderFilterStrategyAware; @@ -73,6 +74,15 @@ public class PlatformHttpEndpoint extends DefaultEndpoint implements AsyncEndpoi description = "Whether to use streaming for large requests and responses (currently only supported by camel-platform-http-vertx)") private boolean useStreaming; + @UriParam(label = "consumer", description = "The properties set on a Cookies when a Cookie is added (currently" + + " only supported by camel-platform-http-vertx)") + private CookieConfiguration cookieConfiguration = new CookieConfiguration(); + + @UriParam(label = "consumer", + description = "Whether to enable the Cookie Handler that allows Cookie addition, expiry, and retrieval" + + " (currently only supported by camel-platform-http-vertx)") + private boolean useCookieHandler; + public PlatformHttpEndpoint(String uri, String remaining, Component component) { super(uri, component); path = remaining; @@ -179,6 +189,22 @@ public void setUseStreaming(boolean useStreaming) { this.useStreaming = useStreaming; } + public CookieConfiguration getCookieConfiguration() { + return cookieConfiguration; + } + + public void setCookieConfiguration(CookieConfiguration cookieConfiguration) { + this.cookieConfiguration = cookieConfiguration; + } + + public boolean isUseCookieHandler() { + return useCookieHandler; + } + + public void setUseCookieHandler(boolean useCookieHandler) { + this.useCookieHandler = useCookieHandler; + } + PlatformHttpEngine getOrCreateEngine() { return platformHttpEngine != null ? platformHttpEngine diff --git a/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/cookie/CookieConfiguration.java b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/cookie/CookieConfiguration.java new file mode 100644 index 0000000000000..690a5b345fc83 --- /dev/null +++ b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/cookie/CookieConfiguration.java @@ -0,0 +1,167 @@ +/* + * 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.platform.http.cookie; + +/** + * Attributes that are set when creating Cookies. + */ +public class CookieConfiguration { + + public static final String DEFAULT_PATH = "/"; + public static final boolean DEFAULT_SECURE_FLAG = false; + public static final boolean DEFAULT_HTTP_ONLY_FLAG = false; + public static final CookieSameSite DEFAULT_SAME_SITE = CookieSameSite.LAX; + private String path = DEFAULT_PATH; + private String domain; + private Long maxAge; + private boolean secure = DEFAULT_SECURE_FLAG; + private boolean httpOnly = DEFAULT_HTTP_ONLY_FLAG; + private CookieSameSite sameSite = DEFAULT_SAME_SITE; + + public CookieConfiguration() { + } + + public CookieConfiguration(String path, String domain, Long maxAge, + boolean secure, boolean httpOnly, CookieSameSite sameSite) { + this.path = path; + this.domain = domain; + this.maxAge = maxAge; + this.secure = secure; + this.httpOnly = httpOnly; + this.sameSite = sameSite; + } + + public String getPath() { + return path; + } + + public String getDomain() { + return domain; + } + + public Long getMaxAge() { + return maxAge; + } + + public boolean isSecure() { + return secure; + } + + public boolean isHttpOnly() { + return httpOnly; + } + + public CookieSameSite getSameSite() { + return sameSite; + } + + public static class Builder { + private String path = DEFAULT_PATH; + private String domain; + private Long maxAge; + private boolean secure = DEFAULT_SECURE_FLAG; + private boolean httpOnly = DEFAULT_HTTP_ONLY_FLAG; + private CookieSameSite sameSite = DEFAULT_SAME_SITE; + + public Builder() { + + } + + /** + * Sets the URL path that must exist in the requested URL in order to send the Cookie. + */ + public Builder setPath(String path) { + this.path = path; + return this; + } + + /** + * Sets which server can receive cookies. + */ + public Builder setDomain(String domain) { + this.domain = domain; + return this; + } + + /** + * Sets the maximum cookie age in seconds. + */ + public Builder setMaxAge(long maxAge) { + this.maxAge = maxAge; + return this; + } + + /** + * Sets whether the cookie is only sent to the server with an encrypted request over HTTPS. + */ + public Builder setSecure(boolean secure) { + this.secure = secure; + return this; + } + + /** + * Sets whether to prevent client side scripts from accessing created cookies. + */ + public Builder setHttpOnly(boolean httpOnly) { + this.httpOnly = httpOnly; + return this; + } + + /** + * Sets whether to prevent the browser from sending cookies along with cross-site requests. + */ + public Builder setSameSite(CookieSameSite sameSite) { + this.sameSite = sameSite; + return this; + } + + public CookieConfiguration build() { + return new CookieConfiguration(path, domain, maxAge, secure, httpOnly, sameSite); + } + } + + /** + * The Cookie {@code SameSite} policy that declares whether a Cookie should be sent with cross-site requests. + */ + public enum CookieSameSite { + + /** + * Prevents cookies from being sent to the target site in all cross-site browsing contexts. + */ + STRICT("Strict"), + + /** + * Cookies are sent in a first-party context, also when following a link to the origin site. + */ + LAX("Lax"), + + /** + * Cookies are set in all first-party and cross-origin contexts. + */ + NONE("None"); + + CookieSameSite(String value) { + this.value = value; + } + + private final String value; + + public String getValue() { + return value; + } + } +} diff --git a/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/cookie/CookieHandler.java b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/cookie/CookieHandler.java new file mode 100644 index 0000000000000..57df35077ac68 --- /dev/null +++ b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/cookie/CookieHandler.java @@ -0,0 +1,47 @@ +/* + * 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.platform.http.cookie; + +/** + * A cookie handler that allows Platform consumers to add, retrieve, and expire cookies. + */ +public interface CookieHandler { + + /** + * Adds a cookie that will be sent back in the response. + * + * @param cookieName the cookie name + * @param cookieValue the cookie value + */ + void addCookie(String cookieName, String cookieValue); + + /** + * Expires a cookie notifying the user-agent or producer to remove it from their cookie-store. + * + * @param cookieName the cookie name + * @return the value of the cookie to expire if one exists, otherwise {@code null} + */ + String removeCookie(String cookieName); + + /** + * Accesses the cookie value. + * + * @param cookieName the cookie name + * @return the value of the cookie if one exists, otherwise {@code null} + */ + String getCookieValue(String cookieName); +} From 75e536f5b7c9422c7257fee632a7e42a46bd8a9a Mon Sep 17 00:00:00 2001 From: Jono Date: Mon, 26 Feb 2024 23:31:34 +1300 Subject: [PATCH 2/5] CAMEL-20019 add generated changes --- .../catalog/components/platform-http.json | 24 ++++--- .../http/PlatformHttpEndpointConfigurer.java | 12 ++++ .../http/PlatformHttpEndpointUriFactory.java | 4 +- .../platform/http/platform-http.json | 24 ++++--- .../PlatformHttpEndpointBuilderFactory.java | 71 +++++++++++++++++++ .../kotlin/components/PlatformHttpUriDsl.kt | 12 ++++ 6 files changed, 124 insertions(+), 23 deletions(-) diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/platform-http.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/platform-http.json index e856c6a695cb8..76bf6bb9a707d 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/platform-http.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/platform-http.json @@ -30,16 +30,18 @@ "properties": { "path": { "index": 0, "kind": "path", "displayName": "Path", "group": "consumer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The path under which this endpoint serves the HTTP requests, for proxy use 'proxy'" }, "consumes": { "index": 1, "kind": "parameter", "displayName": "Consumes", "group": "consumer", "label": "consumer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The content type this endpoint accepts as an input, such as application\/xml or application\/json. null or *\/* mean no restriction." }, - "httpMethodRestrict": { "index": 2, "kind": "parameter", "displayName": "Http Method Restrict", "group": "consumer", "label": "consumer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "A comma separated list of HTTP methods to serve, e.g. GET,POST . If no methods are specified, all methods will be served." }, - "matchOnUriPrefix": { "index": 3, "kind": "parameter", "displayName": "Match On Uri Prefix", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether or not the consumer should try to find a target consumer by matching the URI prefix if no exact match is found." }, - "muteException": { "index": 4, "kind": "parameter", "displayName": "Mute Exception", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "If enabled and an Exchange failed processing on the consumer side the response's body won't contain the exception's stack trace." }, - "produces": { "index": 5, "kind": "parameter", "displayName": "Produces", "group": "consumer", "label": "consumer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The content type this endpoint produces, such as application\/xml or application\/json." }, - "useStreaming": { "index": 6, "kind": "parameter", "displayName": "Use Streaming", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to use streaming for large requests and responses (currently only supported by camel-platform-http-vertx)" }, - "bridgeErrorHandler": { "index": 7, "kind": "parameter", "displayName": "Bridge Error Handler", "group": "consumer (advanced)", "label": "consumer,advanced", "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 likes, will now be processed as a message and handled by the routing Error Handler. Important: This is only possible if the 3rd party component allows Camel to be alerted if an exception was thrown. Some components handle this internally only, and therefore bridgeErrorHandler is not possible. In other situations we may improve the Camel component to hook into the 3rd party component and make this possible for future releases. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored." }, - "exceptionHandler": { "index": 8, "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 default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored." }, - "exchangePattern": { "index": 9, "kind": "parameter", "displayName": "Exchange Pattern", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "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." }, - "fileNameExtWhitelist": { "index": 10, "kind": "parameter", "displayName": "File Name Ext Whitelist", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "A comma or whitespace separated list of file extensions. Uploads having these extensions will be stored locally. Null value or asterisk () will allow all files." }, - "headerFilterStrategy": { "index": 11, "kind": "parameter", "displayName": "Header Filter Strategy", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.spi.HeaderFilterStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom HeaderFilterStrategy to filter headers to and from Camel message." }, - "platformHttpEngine": { "index": 12, "kind": "parameter", "displayName": "Platform Http Engine", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.platform.http.spi.PlatformHttpEngine", "deprecated": false, "autowired": false, "secret": false, "description": "An HTTP Server engine implementation to serve the requests of this endpoint." } + "cookieConfiguration": { "index": 2, "kind": "parameter", "displayName": "Cookie Configuration", "group": "consumer", "label": "consumer", "required": false, "type": "object", "javaType": "org.apache.camel.component.platform.http.cookie.CookieConfiguration", "deprecated": false, "autowired": false, "secret": false, "description": "The properties set on a Cookies when a Cookie is added (currently only supported by camel-platform-http-vertx)" }, + "httpMethodRestrict": { "index": 3, "kind": "parameter", "displayName": "Http Method Restrict", "group": "consumer", "label": "consumer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "A comma separated list of HTTP methods to serve, e.g. GET,POST . If no methods are specified, all methods will be served." }, + "matchOnUriPrefix": { "index": 4, "kind": "parameter", "displayName": "Match On Uri Prefix", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether or not the consumer should try to find a target consumer by matching the URI prefix if no exact match is found." }, + "muteException": { "index": 5, "kind": "parameter", "displayName": "Mute Exception", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "If enabled and an Exchange failed processing on the consumer side the response's body won't contain the exception's stack trace." }, + "produces": { "index": 6, "kind": "parameter", "displayName": "Produces", "group": "consumer", "label": "consumer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The content type this endpoint produces, such as application\/xml or application\/json." }, + "useCookieHandler": { "index": 7, "kind": "parameter", "displayName": "Use Cookie Handler", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to enable the Cookie Handler that allows Cookie addition, expiry, and retrieval (currently only supported by camel-platform-http-vertx)" }, + "useStreaming": { "index": 8, "kind": "parameter", "displayName": "Use Streaming", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to use streaming for large requests and responses (currently only supported by camel-platform-http-vertx)" }, + "bridgeErrorHandler": { "index": 9, "kind": "parameter", "displayName": "Bridge Error Handler", "group": "consumer (advanced)", "label": "consumer,advanced", "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 likes, will now be processed as a message and handled by the routing Error Handler. Important: This is only possible if the 3rd party component allows Camel to be alerted if an exception was thrown. Some components handle this internally only, and therefore bridgeErrorHandler is not possible. In other situations we may improve the Camel component to hook into the 3rd party component and make this possible for future releases. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored." }, + "exceptionHandler": { "index": 10, "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 default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored." }, + "exchangePattern": { "index": 11, "kind": "parameter", "displayName": "Exchange Pattern", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "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." }, + "fileNameExtWhitelist": { "index": 12, "kind": "parameter", "displayName": "File Name Ext Whitelist", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "A comma or whitespace separated list of file extensions. Uploads having these extensions will be stored locally. Null value or asterisk () will allow all files." }, + "headerFilterStrategy": { "index": 13, "kind": "parameter", "displayName": "Header Filter Strategy", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.spi.HeaderFilterStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom HeaderFilterStrategy to filter headers to and from Camel message." }, + "platformHttpEngine": { "index": 14, "kind": "parameter", "displayName": "Platform Http Engine", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.platform.http.spi.PlatformHttpEngine", "deprecated": false, "autowired": false, "secret": false, "description": "An HTTP Server engine implementation to serve the requests of this endpoint." } } } diff --git a/components/camel-platform-http/src/generated/java/org/apache/camel/component/platform/http/PlatformHttpEndpointConfigurer.java b/components/camel-platform-http/src/generated/java/org/apache/camel/component/platform/http/PlatformHttpEndpointConfigurer.java index 6223fdd295b6a..df0936460b3d0 100644 --- a/components/camel-platform-http/src/generated/java/org/apache/camel/component/platform/http/PlatformHttpEndpointConfigurer.java +++ b/components/camel-platform-http/src/generated/java/org/apache/camel/component/platform/http/PlatformHttpEndpointConfigurer.java @@ -24,6 +24,8 @@ public boolean configure(CamelContext camelContext, Object obj, String name, Obj case "bridgeerrorhandler": case "bridgeErrorHandler": target.setBridgeErrorHandler(property(camelContext, boolean.class, value)); return true; case "consumes": target.setConsumes(property(camelContext, java.lang.String.class, value)); return true; + case "cookieconfiguration": + case "cookieConfiguration": target.setCookieConfiguration(property(camelContext, org.apache.camel.component.platform.http.cookie.CookieConfiguration.class, value)); return true; case "exceptionhandler": case "exceptionHandler": target.setExceptionHandler(property(camelContext, org.apache.camel.spi.ExceptionHandler.class, value)); return true; case "exchangepattern": @@ -41,6 +43,8 @@ public boolean configure(CamelContext camelContext, Object obj, String name, Obj case "platformhttpengine": case "platformHttpEngine": target.setPlatformHttpEngine(property(camelContext, org.apache.camel.component.platform.http.spi.PlatformHttpEngine.class, value)); return true; case "produces": target.setProduces(property(camelContext, java.lang.String.class, value)); return true; + case "usecookiehandler": + case "useCookieHandler": target.setUseCookieHandler(property(camelContext, boolean.class, value)); return true; case "usestreaming": case "useStreaming": target.setUseStreaming(property(camelContext, boolean.class, value)); return true; default: return false; @@ -53,6 +57,8 @@ public Class getOptionType(String name, boolean ignoreCase) { case "bridgeerrorhandler": case "bridgeErrorHandler": return boolean.class; case "consumes": return java.lang.String.class; + case "cookieconfiguration": + case "cookieConfiguration": return org.apache.camel.component.platform.http.cookie.CookieConfiguration.class; case "exceptionhandler": case "exceptionHandler": return org.apache.camel.spi.ExceptionHandler.class; case "exchangepattern": @@ -70,6 +76,8 @@ public Class getOptionType(String name, boolean ignoreCase) { case "platformhttpengine": case "platformHttpEngine": return org.apache.camel.component.platform.http.spi.PlatformHttpEngine.class; case "produces": return java.lang.String.class; + case "usecookiehandler": + case "useCookieHandler": return boolean.class; case "usestreaming": case "useStreaming": return boolean.class; default: return null; @@ -83,6 +91,8 @@ public Object getOptionValue(Object obj, String name, boolean ignoreCase) { case "bridgeerrorhandler": case "bridgeErrorHandler": return target.isBridgeErrorHandler(); case "consumes": return target.getConsumes(); + case "cookieconfiguration": + case "cookieConfiguration": return target.getCookieConfiguration(); case "exceptionhandler": case "exceptionHandler": return target.getExceptionHandler(); case "exchangepattern": @@ -100,6 +110,8 @@ public Object getOptionValue(Object obj, String name, boolean ignoreCase) { case "platformhttpengine": case "platformHttpEngine": return target.getPlatformHttpEngine(); case "produces": return target.getProduces(); + case "usecookiehandler": + case "useCookieHandler": return target.isUseCookieHandler(); case "usestreaming": case "useStreaming": return target.isUseStreaming(); default: return null; diff --git a/components/camel-platform-http/src/generated/java/org/apache/camel/component/platform/http/PlatformHttpEndpointUriFactory.java b/components/camel-platform-http/src/generated/java/org/apache/camel/component/platform/http/PlatformHttpEndpointUriFactory.java index 78a658d5a8ac5..abdbb458f4c4f 100644 --- a/components/camel-platform-http/src/generated/java/org/apache/camel/component/platform/http/PlatformHttpEndpointUriFactory.java +++ b/components/camel-platform-http/src/generated/java/org/apache/camel/component/platform/http/PlatformHttpEndpointUriFactory.java @@ -21,9 +21,10 @@ public class PlatformHttpEndpointUriFactory extends org.apache.camel.support.com private static final Set SECRET_PROPERTY_NAMES; private static final Set MULTI_VALUE_PREFIXES; static { - Set props = new HashSet<>(13); + Set props = new HashSet<>(15); props.add("bridgeErrorHandler"); props.add("consumes"); + props.add("cookieConfiguration"); props.add("exceptionHandler"); props.add("exchangePattern"); props.add("fileNameExtWhitelist"); @@ -34,6 +35,7 @@ public class PlatformHttpEndpointUriFactory extends org.apache.camel.support.com props.add("path"); props.add("platformHttpEngine"); props.add("produces"); + props.add("useCookieHandler"); props.add("useStreaming"); PROPERTY_NAMES = Collections.unmodifiableSet(props); SECRET_PROPERTY_NAMES = Collections.emptySet(); diff --git a/components/camel-platform-http/src/generated/resources/org/apache/camel/component/platform/http/platform-http.json b/components/camel-platform-http/src/generated/resources/org/apache/camel/component/platform/http/platform-http.json index e856c6a695cb8..76bf6bb9a707d 100644 --- a/components/camel-platform-http/src/generated/resources/org/apache/camel/component/platform/http/platform-http.json +++ b/components/camel-platform-http/src/generated/resources/org/apache/camel/component/platform/http/platform-http.json @@ -30,16 +30,18 @@ "properties": { "path": { "index": 0, "kind": "path", "displayName": "Path", "group": "consumer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The path under which this endpoint serves the HTTP requests, for proxy use 'proxy'" }, "consumes": { "index": 1, "kind": "parameter", "displayName": "Consumes", "group": "consumer", "label": "consumer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The content type this endpoint accepts as an input, such as application\/xml or application\/json. null or *\/* mean no restriction." }, - "httpMethodRestrict": { "index": 2, "kind": "parameter", "displayName": "Http Method Restrict", "group": "consumer", "label": "consumer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "A comma separated list of HTTP methods to serve, e.g. GET,POST . If no methods are specified, all methods will be served." }, - "matchOnUriPrefix": { "index": 3, "kind": "parameter", "displayName": "Match On Uri Prefix", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether or not the consumer should try to find a target consumer by matching the URI prefix if no exact match is found." }, - "muteException": { "index": 4, "kind": "parameter", "displayName": "Mute Exception", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "If enabled and an Exchange failed processing on the consumer side the response's body won't contain the exception's stack trace." }, - "produces": { "index": 5, "kind": "parameter", "displayName": "Produces", "group": "consumer", "label": "consumer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The content type this endpoint produces, such as application\/xml or application\/json." }, - "useStreaming": { "index": 6, "kind": "parameter", "displayName": "Use Streaming", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to use streaming for large requests and responses (currently only supported by camel-platform-http-vertx)" }, - "bridgeErrorHandler": { "index": 7, "kind": "parameter", "displayName": "Bridge Error Handler", "group": "consumer (advanced)", "label": "consumer,advanced", "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 likes, will now be processed as a message and handled by the routing Error Handler. Important: This is only possible if the 3rd party component allows Camel to be alerted if an exception was thrown. Some components handle this internally only, and therefore bridgeErrorHandler is not possible. In other situations we may improve the Camel component to hook into the 3rd party component and make this possible for future releases. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored." }, - "exceptionHandler": { "index": 8, "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 default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored." }, - "exchangePattern": { "index": 9, "kind": "parameter", "displayName": "Exchange Pattern", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "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." }, - "fileNameExtWhitelist": { "index": 10, "kind": "parameter", "displayName": "File Name Ext Whitelist", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "A comma or whitespace separated list of file extensions. Uploads having these extensions will be stored locally. Null value or asterisk () will allow all files." }, - "headerFilterStrategy": { "index": 11, "kind": "parameter", "displayName": "Header Filter Strategy", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.spi.HeaderFilterStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom HeaderFilterStrategy to filter headers to and from Camel message." }, - "platformHttpEngine": { "index": 12, "kind": "parameter", "displayName": "Platform Http Engine", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.platform.http.spi.PlatformHttpEngine", "deprecated": false, "autowired": false, "secret": false, "description": "An HTTP Server engine implementation to serve the requests of this endpoint." } + "cookieConfiguration": { "index": 2, "kind": "parameter", "displayName": "Cookie Configuration", "group": "consumer", "label": "consumer", "required": false, "type": "object", "javaType": "org.apache.camel.component.platform.http.cookie.CookieConfiguration", "deprecated": false, "autowired": false, "secret": false, "description": "The properties set on a Cookies when a Cookie is added (currently only supported by camel-platform-http-vertx)" }, + "httpMethodRestrict": { "index": 3, "kind": "parameter", "displayName": "Http Method Restrict", "group": "consumer", "label": "consumer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "A comma separated list of HTTP methods to serve, e.g. GET,POST . If no methods are specified, all methods will be served." }, + "matchOnUriPrefix": { "index": 4, "kind": "parameter", "displayName": "Match On Uri Prefix", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether or not the consumer should try to find a target consumer by matching the URI prefix if no exact match is found." }, + "muteException": { "index": 5, "kind": "parameter", "displayName": "Mute Exception", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "If enabled and an Exchange failed processing on the consumer side the response's body won't contain the exception's stack trace." }, + "produces": { "index": 6, "kind": "parameter", "displayName": "Produces", "group": "consumer", "label": "consumer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The content type this endpoint produces, such as application\/xml or application\/json." }, + "useCookieHandler": { "index": 7, "kind": "parameter", "displayName": "Use Cookie Handler", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to enable the Cookie Handler that allows Cookie addition, expiry, and retrieval (currently only supported by camel-platform-http-vertx)" }, + "useStreaming": { "index": 8, "kind": "parameter", "displayName": "Use Streaming", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to use streaming for large requests and responses (currently only supported by camel-platform-http-vertx)" }, + "bridgeErrorHandler": { "index": 9, "kind": "parameter", "displayName": "Bridge Error Handler", "group": "consumer (advanced)", "label": "consumer,advanced", "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 likes, will now be processed as a message and handled by the routing Error Handler. Important: This is only possible if the 3rd party component allows Camel to be alerted if an exception was thrown. Some components handle this internally only, and therefore bridgeErrorHandler is not possible. In other situations we may improve the Camel component to hook into the 3rd party component and make this possible for future releases. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored." }, + "exceptionHandler": { "index": 10, "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 default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored." }, + "exchangePattern": { "index": 11, "kind": "parameter", "displayName": "Exchange Pattern", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "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." }, + "fileNameExtWhitelist": { "index": 12, "kind": "parameter", "displayName": "File Name Ext Whitelist", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "A comma or whitespace separated list of file extensions. Uploads having these extensions will be stored locally. Null value or asterisk () will allow all files." }, + "headerFilterStrategy": { "index": 13, "kind": "parameter", "displayName": "Header Filter Strategy", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.spi.HeaderFilterStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom HeaderFilterStrategy to filter headers to and from Camel message." }, + "platformHttpEngine": { "index": 14, "kind": "parameter", "displayName": "Platform Http Engine", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.platform.http.spi.PlatformHttpEngine", "deprecated": false, "autowired": false, "secret": false, "description": "An HTTP Server engine implementation to serve the requests of this endpoint." } } } diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/PlatformHttpEndpointBuilderFactory.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/PlatformHttpEndpointBuilderFactory.java index 0a2c2d6e509db..7bf62ec49354f 100644 --- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/PlatformHttpEndpointBuilderFactory.java +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/PlatformHttpEndpointBuilderFactory.java @@ -60,6 +60,40 @@ default PlatformHttpEndpointBuilder consumes(String consumes) { doSetProperty("consumes", consumes); return this; } + /** + * The properties set on a Cookies when a Cookie is added (currently + * only supported by camel-platform-http-vertx). + * + * The option is a: + * <code>org.apache.camel.component.platform.http.cookie.CookieConfiguration</code> type. + * + * Group: consumer + * + * @param cookieConfiguration the value to set + * @return the dsl builder + */ + default PlatformHttpEndpointBuilder cookieConfiguration( + org.apache.camel.component.platform.http.cookie.CookieConfiguration cookieConfiguration) { + doSetProperty("cookieConfiguration", cookieConfiguration); + return this; + } + /** + * The properties set on a Cookies when a Cookie is added (currently + * only supported by camel-platform-http-vertx). + * + * The option will be converted to a + * <code>org.apache.camel.component.platform.http.cookie.CookieConfiguration</code> type. + * + * Group: consumer + * + * @param cookieConfiguration the value to set + * @return the dsl builder + */ + default PlatformHttpEndpointBuilder cookieConfiguration( + String cookieConfiguration) { + doSetProperty("cookieConfiguration", cookieConfiguration); + return this; + } /** * A comma separated list of HTTP methods to serve, e.g. GET,POST . If * no methods are specified, all methods will be served. @@ -159,6 +193,43 @@ default PlatformHttpEndpointBuilder produces(String produces) { doSetProperty("produces", produces); return this; } + /** + * Whether to enable the Cookie Handler that allows Cookie addition, + * expiry, and retrieval (currently only supported by + * camel-platform-http-vertx). + * + * The option is a: <code>boolean</code> type. + * + * Default: false + * Group: consumer + * + * @param useCookieHandler the value to set + * @return the dsl builder + */ + default PlatformHttpEndpointBuilder useCookieHandler( + boolean useCookieHandler) { + doSetProperty("useCookieHandler", useCookieHandler); + return this; + } + /** + * Whether to enable the Cookie Handler that allows Cookie addition, + * expiry, and retrieval (currently only supported by + * camel-platform-http-vertx). + * + * The option will be converted to a <code>boolean</code> + * type. + * + * Default: false + * Group: consumer + * + * @param useCookieHandler the value to set + * @return the dsl builder + */ + default PlatformHttpEndpointBuilder useCookieHandler( + String useCookieHandler) { + doSetProperty("useCookieHandler", useCookieHandler); + return this; + } /** * Whether to use streaming for large requests and responses (currently * only supported by camel-platform-http-vertx). diff --git a/dsl/camel-kotlin-api/src/generated/kotlin/org/apache/camel/kotlin/components/PlatformHttpUriDsl.kt b/dsl/camel-kotlin-api/src/generated/kotlin/org/apache/camel/kotlin/components/PlatformHttpUriDsl.kt index 1769eca254ec1..d47c5a7373edb 100644 --- a/dsl/camel-kotlin-api/src/generated/kotlin/org/apache/camel/kotlin/components/PlatformHttpUriDsl.kt +++ b/dsl/camel-kotlin-api/src/generated/kotlin/org/apache/camel/kotlin/components/PlatformHttpUriDsl.kt @@ -48,6 +48,10 @@ public class PlatformHttpUriDsl( it.property("consumes", consumes) } + public fun cookieConfiguration(cookieConfiguration: String) { + it.property("cookieConfiguration", cookieConfiguration) + } + public fun httpMethodRestrict(httpMethodRestrict: String) { it.property("httpMethodRestrict", httpMethodRestrict) } @@ -72,6 +76,14 @@ public class PlatformHttpUriDsl( it.property("produces", produces) } + public fun useCookieHandler(useCookieHandler: String) { + it.property("useCookieHandler", useCookieHandler) + } + + public fun useCookieHandler(useCookieHandler: Boolean) { + it.property("useCookieHandler", useCookieHandler.toString()) + } + public fun useStreaming(useStreaming: String) { it.property("useStreaming", useStreaming) } From c025fdb0fef8ce7cbfae4536be30e8f9b8be86fb Mon Sep 17 00:00:00 2001 From: Jono Date: Wed, 28 Feb 2024 00:13:37 +1300 Subject: [PATCH 3/5] CAMEL-20019 add @Configurer to CookieConfiguration --- .../catalog/components/platform-http.json | 31 ++-- .../http/vertx/VertxPlatformHttpConsumer.java | 14 +- .../http/PlatformHttpEndpointConfigurer.java | 42 ++++- .../http/PlatformHttpEndpointUriFactory.java | 9 +- .../cookie/CookieConfigurationConfigurer.java | 96 +++++++++++ ...t.platform.http.cookie.CookieConfiguration | 2 + .../platform/http/platform-http.json | 31 ++-- .../http/cookie/CookieConfiguration.java | 108 +++++++++--- .../PlatformHttpEndpointBuilderFactory.java | 155 ++++++++++++++++-- .../kotlin/components/PlatformHttpUriDsl.kt | 37 ++++- 10 files changed, 441 insertions(+), 84 deletions(-) create mode 100644 components/camel-platform-http/src/generated/java/org/apache/camel/component/platform/http/cookie/CookieConfigurationConfigurer.java create mode 100644 components/camel-platform-http/src/generated/resources/META-INF/services/org/apache/camel/configurer/org.apache.camel.component.platform.http.cookie.CookieConfiguration diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/platform-http.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/platform-http.json index 76bf6bb9a707d..0a7847620066c 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/platform-http.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/platform-http.json @@ -30,18 +30,23 @@ "properties": { "path": { "index": 0, "kind": "path", "displayName": "Path", "group": "consumer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The path under which this endpoint serves the HTTP requests, for proxy use 'proxy'" }, "consumes": { "index": 1, "kind": "parameter", "displayName": "Consumes", "group": "consumer", "label": "consumer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The content type this endpoint accepts as an input, such as application\/xml or application\/json. null or *\/* mean no restriction." }, - "cookieConfiguration": { "index": 2, "kind": "parameter", "displayName": "Cookie Configuration", "group": "consumer", "label": "consumer", "required": false, "type": "object", "javaType": "org.apache.camel.component.platform.http.cookie.CookieConfiguration", "deprecated": false, "autowired": false, "secret": false, "description": "The properties set on a Cookies when a Cookie is added (currently only supported by camel-platform-http-vertx)" }, - "httpMethodRestrict": { "index": 3, "kind": "parameter", "displayName": "Http Method Restrict", "group": "consumer", "label": "consumer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "A comma separated list of HTTP methods to serve, e.g. GET,POST . If no methods are specified, all methods will be served." }, - "matchOnUriPrefix": { "index": 4, "kind": "parameter", "displayName": "Match On Uri Prefix", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether or not the consumer should try to find a target consumer by matching the URI prefix if no exact match is found." }, - "muteException": { "index": 5, "kind": "parameter", "displayName": "Mute Exception", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "If enabled and an Exchange failed processing on the consumer side the response's body won't contain the exception's stack trace." }, - "produces": { "index": 6, "kind": "parameter", "displayName": "Produces", "group": "consumer", "label": "consumer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The content type this endpoint produces, such as application\/xml or application\/json." }, - "useCookieHandler": { "index": 7, "kind": "parameter", "displayName": "Use Cookie Handler", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to enable the Cookie Handler that allows Cookie addition, expiry, and retrieval (currently only supported by camel-platform-http-vertx)" }, - "useStreaming": { "index": 8, "kind": "parameter", "displayName": "Use Streaming", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to use streaming for large requests and responses (currently only supported by camel-platform-http-vertx)" }, - "bridgeErrorHandler": { "index": 9, "kind": "parameter", "displayName": "Bridge Error Handler", "group": "consumer (advanced)", "label": "consumer,advanced", "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 likes, will now be processed as a message and handled by the routing Error Handler. Important: This is only possible if the 3rd party component allows Camel to be alerted if an exception was thrown. Some components handle this internally only, and therefore bridgeErrorHandler is not possible. In other situations we may improve the Camel component to hook into the 3rd party component and make this possible for future releases. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored." }, - "exceptionHandler": { "index": 10, "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 default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored." }, - "exchangePattern": { "index": 11, "kind": "parameter", "displayName": "Exchange Pattern", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "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." }, - "fileNameExtWhitelist": { "index": 12, "kind": "parameter", "displayName": "File Name Ext Whitelist", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "A comma or whitespace separated list of file extensions. Uploads having these extensions will be stored locally. Null value or asterisk () will allow all files." }, - "headerFilterStrategy": { "index": 13, "kind": "parameter", "displayName": "Header Filter Strategy", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.spi.HeaderFilterStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom HeaderFilterStrategy to filter headers to and from Camel message." }, - "platformHttpEngine": { "index": 14, "kind": "parameter", "displayName": "Platform Http Engine", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.platform.http.spi.PlatformHttpEngine", "deprecated": false, "autowired": false, "secret": false, "description": "An HTTP Server engine implementation to serve the requests of this endpoint." } + "cookieDomain": { "index": 2, "kind": "parameter", "displayName": "Cookie Domain", "group": "consumer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.platform.http.cookie.CookieConfiguration", "configurationField": "cookieConfiguration", "description": "Sets which server can receive cookies." }, + "cookieHttpOnly": { "index": 3, "kind": "parameter", "displayName": "Cookie Http Only", "group": "consumer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.platform.http.cookie.CookieConfiguration", "configurationField": "cookieConfiguration", "description": "Sets whether to prevent client side scripts from accessing created cookies." }, + "cookieMaxAge": { "index": 4, "kind": "parameter", "displayName": "Cookie Max Age", "group": "consumer", "label": "", "required": false, "type": "integer", "javaType": "java.lang.Long", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.platform.http.cookie.CookieConfiguration", "configurationField": "cookieConfiguration", "description": "Sets the maximum cookie age in seconds." }, + "cookiePath": { "index": 5, "kind": "parameter", "displayName": "Cookie Path", "group": "consumer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "\/", "configurationClass": "org.apache.camel.component.platform.http.cookie.CookieConfiguration", "configurationField": "cookieConfiguration", "description": "Sets the URL path that must exist in the requested URL in order to send the Cookie." }, + "cookieSameSite": { "index": 6, "kind": "parameter", "displayName": "Cookie Same Site", "group": "consumer", "label": "", "required": false, "type": "object", "javaType": "org.apache.camel.component.platform.http.cookie.CookieConfiguration.CookieSameSite", "enum": [ "STRICT", "LAX", "NONE" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "Lax", "configurationClass": "org.apache.camel.component.platform.http.cookie.CookieConfiguration", "configurationField": "cookieConfiguration", "description": "Sets whether to prevent the browser from sending cookies along with cross-site requests." }, + "cookieSecure": { "index": 7, "kind": "parameter", "displayName": "Cookie Secure", "group": "consumer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.platform.http.cookie.CookieConfiguration", "configurationField": "cookieConfiguration", "description": "Sets whether the cookie is only sent to the server with an encrypted request over HTTPS." }, + "httpMethodRestrict": { "index": 8, "kind": "parameter", "displayName": "Http Method Restrict", "group": "consumer", "label": "consumer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "A comma separated list of HTTP methods to serve, e.g. GET,POST . If no methods are specified, all methods will be served." }, + "matchOnUriPrefix": { "index": 9, "kind": "parameter", "displayName": "Match On Uri Prefix", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether or not the consumer should try to find a target consumer by matching the URI prefix if no exact match is found." }, + "muteException": { "index": 10, "kind": "parameter", "displayName": "Mute Exception", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "If enabled and an Exchange failed processing on the consumer side the response's body won't contain the exception's stack trace." }, + "produces": { "index": 11, "kind": "parameter", "displayName": "Produces", "group": "consumer", "label": "consumer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The content type this endpoint produces, such as application\/xml or application\/json." }, + "useCookieHandler": { "index": 12, "kind": "parameter", "displayName": "Use Cookie Handler", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to enable the Cookie Handler that allows Cookie addition, expiry, and retrieval (currently only supported by camel-platform-http-vertx)" }, + "useStreaming": { "index": 13, "kind": "parameter", "displayName": "Use Streaming", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to use streaming for large requests and responses (currently only supported by camel-platform-http-vertx)" }, + "bridgeErrorHandler": { "index": 14, "kind": "parameter", "displayName": "Bridge Error Handler", "group": "consumer (advanced)", "label": "consumer,advanced", "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 likes, will now be processed as a message and handled by the routing Error Handler. Important: This is only possible if the 3rd party component allows Camel to be alerted if an exception was thrown. Some components handle this internally only, and therefore bridgeErrorHandler is not possible. In other situations we may improve the Camel component to hook into the 3rd party component and make this possible for future releases. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored." }, + "exceptionHandler": { "index": 15, "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 default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored." }, + "exchangePattern": { "index": 16, "kind": "parameter", "displayName": "Exchange Pattern", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "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." }, + "fileNameExtWhitelist": { "index": 17, "kind": "parameter", "displayName": "File Name Ext Whitelist", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "A comma or whitespace separated list of file extensions. Uploads having these extensions will be stored locally. Null value or asterisk () will allow all files." }, + "headerFilterStrategy": { "index": 18, "kind": "parameter", "displayName": "Header Filter Strategy", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.spi.HeaderFilterStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom HeaderFilterStrategy to filter headers to and from Camel message." }, + "platformHttpEngine": { "index": 19, "kind": "parameter", "displayName": "Platform Http Engine", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.platform.http.spi.PlatformHttpEngine", "deprecated": false, "autowired": false, "secret": false, "description": "An HTTP Server engine implementation to serve the requests of this endpoint." } } } diff --git a/components/camel-platform-http-vertx/src/main/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpConsumer.java b/components/camel-platform-http-vertx/src/main/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpConsumer.java index 5fb666ef6dbe4..d7033a60af588 100644 --- a/components/camel-platform-http-vertx/src/main/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpConsumer.java +++ b/components/camel-platform-http-vertx/src/main/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpConsumer.java @@ -358,13 +358,13 @@ class VertxCookieHandler implements CookieHandler { @Override public void addCookie(String name, String value) { Cookie cookie = Cookie.cookie(name, value) - .setPath(cookieConfiguration.getPath()) - .setDomain(cookieConfiguration.getDomain()) - .setSecure(cookieConfiguration.isSecure()) - .setHttpOnly(cookieConfiguration.isHttpOnly()) - .setSameSite(getSameSite(cookieConfiguration.getSameSite())); - if (cookieConfiguration.getMaxAge() != null) { - cookie.setMaxAge(cookieConfiguration.getMaxAge()); + .setPath(cookieConfiguration.getCookiePath()) + .setDomain(cookieConfiguration.getCookieDomain()) + .setSecure(cookieConfiguration.isCookieSecure()) + .setHttpOnly(cookieConfiguration.isCookieHttpOnly()) + .setSameSite(getSameSite(cookieConfiguration.getCookieSameSite())); + if (cookieConfiguration.getCookieMaxAge() != null) { + cookie.setMaxAge(cookieConfiguration.getCookieMaxAge()); } routingContext.response().addCookie(cookie); } diff --git a/components/camel-platform-http/src/generated/java/org/apache/camel/component/platform/http/PlatformHttpEndpointConfigurer.java b/components/camel-platform-http/src/generated/java/org/apache/camel/component/platform/http/PlatformHttpEndpointConfigurer.java index df0936460b3d0..fb7c6b4f55f0e 100644 --- a/components/camel-platform-http/src/generated/java/org/apache/camel/component/platform/http/PlatformHttpEndpointConfigurer.java +++ b/components/camel-platform-http/src/generated/java/org/apache/camel/component/platform/http/PlatformHttpEndpointConfigurer.java @@ -24,8 +24,18 @@ public boolean configure(CamelContext camelContext, Object obj, String name, Obj case "bridgeerrorhandler": case "bridgeErrorHandler": target.setBridgeErrorHandler(property(camelContext, boolean.class, value)); return true; case "consumes": target.setConsumes(property(camelContext, java.lang.String.class, value)); return true; - case "cookieconfiguration": - case "cookieConfiguration": target.setCookieConfiguration(property(camelContext, org.apache.camel.component.platform.http.cookie.CookieConfiguration.class, value)); return true; + case "cookiedomain": + case "cookieDomain": target.getCookieConfiguration().setCookieDomain(property(camelContext, java.lang.String.class, value)); return true; + case "cookiehttponly": + case "cookieHttpOnly": target.getCookieConfiguration().setCookieHttpOnly(property(camelContext, boolean.class, value)); return true; + case "cookiemaxage": + case "cookieMaxAge": target.getCookieConfiguration().setCookieMaxAge(property(camelContext, java.lang.Long.class, value)); return true; + case "cookiepath": + case "cookiePath": target.getCookieConfiguration().setCookiePath(property(camelContext, java.lang.String.class, value)); return true; + case "cookiesamesite": + case "cookieSameSite": target.getCookieConfiguration().setCookieSameSite(property(camelContext, org.apache.camel.component.platform.http.cookie.CookieConfiguration.CookieSameSite.class, value)); return true; + case "cookiesecure": + case "cookieSecure": target.getCookieConfiguration().setCookieSecure(property(camelContext, boolean.class, value)); return true; case "exceptionhandler": case "exceptionHandler": target.setExceptionHandler(property(camelContext, org.apache.camel.spi.ExceptionHandler.class, value)); return true; case "exchangepattern": @@ -57,8 +67,18 @@ public Class getOptionType(String name, boolean ignoreCase) { case "bridgeerrorhandler": case "bridgeErrorHandler": return boolean.class; case "consumes": return java.lang.String.class; - case "cookieconfiguration": - case "cookieConfiguration": return org.apache.camel.component.platform.http.cookie.CookieConfiguration.class; + case "cookiedomain": + case "cookieDomain": return java.lang.String.class; + case "cookiehttponly": + case "cookieHttpOnly": return boolean.class; + case "cookiemaxage": + case "cookieMaxAge": return java.lang.Long.class; + case "cookiepath": + case "cookiePath": return java.lang.String.class; + case "cookiesamesite": + case "cookieSameSite": return org.apache.camel.component.platform.http.cookie.CookieConfiguration.CookieSameSite.class; + case "cookiesecure": + case "cookieSecure": return boolean.class; case "exceptionhandler": case "exceptionHandler": return org.apache.camel.spi.ExceptionHandler.class; case "exchangepattern": @@ -91,8 +111,18 @@ public Object getOptionValue(Object obj, String name, boolean ignoreCase) { case "bridgeerrorhandler": case "bridgeErrorHandler": return target.isBridgeErrorHandler(); case "consumes": return target.getConsumes(); - case "cookieconfiguration": - case "cookieConfiguration": return target.getCookieConfiguration(); + case "cookiedomain": + case "cookieDomain": return target.getCookieConfiguration().getCookieDomain(); + case "cookiehttponly": + case "cookieHttpOnly": return target.getCookieConfiguration().isCookieHttpOnly(); + case "cookiemaxage": + case "cookieMaxAge": return target.getCookieConfiguration().getCookieMaxAge(); + case "cookiepath": + case "cookiePath": return target.getCookieConfiguration().getCookiePath(); + case "cookiesamesite": + case "cookieSameSite": return target.getCookieConfiguration().getCookieSameSite(); + case "cookiesecure": + case "cookieSecure": return target.getCookieConfiguration().isCookieSecure(); case "exceptionhandler": case "exceptionHandler": return target.getExceptionHandler(); case "exchangepattern": diff --git a/components/camel-platform-http/src/generated/java/org/apache/camel/component/platform/http/PlatformHttpEndpointUriFactory.java b/components/camel-platform-http/src/generated/java/org/apache/camel/component/platform/http/PlatformHttpEndpointUriFactory.java index abdbb458f4c4f..e90d7621fd848 100644 --- a/components/camel-platform-http/src/generated/java/org/apache/camel/component/platform/http/PlatformHttpEndpointUriFactory.java +++ b/components/camel-platform-http/src/generated/java/org/apache/camel/component/platform/http/PlatformHttpEndpointUriFactory.java @@ -21,10 +21,15 @@ public class PlatformHttpEndpointUriFactory extends org.apache.camel.support.com private static final Set SECRET_PROPERTY_NAMES; private static final Set MULTI_VALUE_PREFIXES; static { - Set props = new HashSet<>(15); + Set props = new HashSet<>(20); props.add("bridgeErrorHandler"); props.add("consumes"); - props.add("cookieConfiguration"); + props.add("cookieDomain"); + props.add("cookieHttpOnly"); + props.add("cookieMaxAge"); + props.add("cookiePath"); + props.add("cookieSameSite"); + props.add("cookieSecure"); props.add("exceptionHandler"); props.add("exchangePattern"); props.add("fileNameExtWhitelist"); diff --git a/components/camel-platform-http/src/generated/java/org/apache/camel/component/platform/http/cookie/CookieConfigurationConfigurer.java b/components/camel-platform-http/src/generated/java/org/apache/camel/component/platform/http/cookie/CookieConfigurationConfigurer.java new file mode 100644 index 0000000000000..e61b29e32dc7a --- /dev/null +++ b/components/camel-platform-http/src/generated/java/org/apache/camel/component/platform/http/cookie/CookieConfigurationConfigurer.java @@ -0,0 +1,96 @@ +/* Generated by camel build tools - do NOT edit this file! */ +package org.apache.camel.component.platform.http.cookie; + +import java.util.Map; + +import org.apache.camel.CamelContext; +import org.apache.camel.spi.ExtendedPropertyConfigurerGetter; +import org.apache.camel.spi.PropertyConfigurerGetter; +import org.apache.camel.spi.ConfigurerStrategy; +import org.apache.camel.spi.GeneratedPropertyConfigurer; +import org.apache.camel.util.CaseInsensitiveMap; +import org.apache.camel.component.platform.http.cookie.CookieConfiguration; + +/** + * Generated by camel build tools - do NOT edit this file! + */ +@SuppressWarnings("unchecked") +public class CookieConfigurationConfigurer extends org.apache.camel.support.component.PropertyConfigurerSupport implements GeneratedPropertyConfigurer, ExtendedPropertyConfigurerGetter { + + private static final Map ALL_OPTIONS; + static { + Map map = new CaseInsensitiveMap(); + map.put("CookieDomain", java.lang.String.class); + map.put("CookieHttpOnly", boolean.class); + map.put("CookieMaxAge", java.lang.Long.class); + map.put("CookiePath", java.lang.String.class); + map.put("CookieSameSite", org.apache.camel.component.platform.http.cookie.CookieConfiguration.CookieSameSite.class); + map.put("CookieSecure", boolean.class); + ALL_OPTIONS = map; + } + + @Override + public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) { + org.apache.camel.component.platform.http.cookie.CookieConfiguration target = (org.apache.camel.component.platform.http.cookie.CookieConfiguration) obj; + switch (ignoreCase ? name.toLowerCase() : name) { + case "cookiedomain": + case "CookieDomain": target.setCookieDomain(property(camelContext, java.lang.String.class, value)); return true; + case "cookiehttponly": + case "CookieHttpOnly": target.setCookieHttpOnly(property(camelContext, boolean.class, value)); return true; + case "cookiemaxage": + case "CookieMaxAge": target.setCookieMaxAge(property(camelContext, java.lang.Long.class, value)); return true; + case "cookiepath": + case "CookiePath": target.setCookiePath(property(camelContext, java.lang.String.class, value)); return true; + case "cookiesamesite": + case "CookieSameSite": target.setCookieSameSite(property(camelContext, org.apache.camel.component.platform.http.cookie.CookieConfiguration.CookieSameSite.class, value)); return true; + case "cookiesecure": + case "CookieSecure": target.setCookieSecure(property(camelContext, boolean.class, value)); return true; + default: return false; + } + } + + @Override + public Map getAllOptions(Object target) { + return ALL_OPTIONS; + } + + @Override + public Class getOptionType(String name, boolean ignoreCase) { + switch (ignoreCase ? name.toLowerCase() : name) { + case "cookiedomain": + case "CookieDomain": return java.lang.String.class; + case "cookiehttponly": + case "CookieHttpOnly": return boolean.class; + case "cookiemaxage": + case "CookieMaxAge": return java.lang.Long.class; + case "cookiepath": + case "CookiePath": return java.lang.String.class; + case "cookiesamesite": + case "CookieSameSite": return org.apache.camel.component.platform.http.cookie.CookieConfiguration.CookieSameSite.class; + case "cookiesecure": + case "CookieSecure": return boolean.class; + default: return null; + } + } + + @Override + public Object getOptionValue(Object obj, String name, boolean ignoreCase) { + org.apache.camel.component.platform.http.cookie.CookieConfiguration target = (org.apache.camel.component.platform.http.cookie.CookieConfiguration) obj; + switch (ignoreCase ? name.toLowerCase() : name) { + case "cookiedomain": + case "CookieDomain": return target.getCookieDomain(); + case "cookiehttponly": + case "CookieHttpOnly": return target.isCookieHttpOnly(); + case "cookiemaxage": + case "CookieMaxAge": return target.getCookieMaxAge(); + case "cookiepath": + case "CookiePath": return target.getCookiePath(); + case "cookiesamesite": + case "CookieSameSite": return target.getCookieSameSite(); + case "cookiesecure": + case "CookieSecure": return target.isCookieSecure(); + default: return null; + } + } +} + diff --git a/components/camel-platform-http/src/generated/resources/META-INF/services/org/apache/camel/configurer/org.apache.camel.component.platform.http.cookie.CookieConfiguration b/components/camel-platform-http/src/generated/resources/META-INF/services/org/apache/camel/configurer/org.apache.camel.component.platform.http.cookie.CookieConfiguration new file mode 100644 index 0000000000000..e4fa7c52aeec5 --- /dev/null +++ b/components/camel-platform-http/src/generated/resources/META-INF/services/org/apache/camel/configurer/org.apache.camel.component.platform.http.cookie.CookieConfiguration @@ -0,0 +1,2 @@ +# Generated by camel build tools - do NOT edit this file! +class=org.apache.camel.component.platform.http.cookie.CookieConfigurationConfigurer diff --git a/components/camel-platform-http/src/generated/resources/org/apache/camel/component/platform/http/platform-http.json b/components/camel-platform-http/src/generated/resources/org/apache/camel/component/platform/http/platform-http.json index 76bf6bb9a707d..0a7847620066c 100644 --- a/components/camel-platform-http/src/generated/resources/org/apache/camel/component/platform/http/platform-http.json +++ b/components/camel-platform-http/src/generated/resources/org/apache/camel/component/platform/http/platform-http.json @@ -30,18 +30,23 @@ "properties": { "path": { "index": 0, "kind": "path", "displayName": "Path", "group": "consumer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The path under which this endpoint serves the HTTP requests, for proxy use 'proxy'" }, "consumes": { "index": 1, "kind": "parameter", "displayName": "Consumes", "group": "consumer", "label": "consumer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The content type this endpoint accepts as an input, such as application\/xml or application\/json. null or *\/* mean no restriction." }, - "cookieConfiguration": { "index": 2, "kind": "parameter", "displayName": "Cookie Configuration", "group": "consumer", "label": "consumer", "required": false, "type": "object", "javaType": "org.apache.camel.component.platform.http.cookie.CookieConfiguration", "deprecated": false, "autowired": false, "secret": false, "description": "The properties set on a Cookies when a Cookie is added (currently only supported by camel-platform-http-vertx)" }, - "httpMethodRestrict": { "index": 3, "kind": "parameter", "displayName": "Http Method Restrict", "group": "consumer", "label": "consumer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "A comma separated list of HTTP methods to serve, e.g. GET,POST . If no methods are specified, all methods will be served." }, - "matchOnUriPrefix": { "index": 4, "kind": "parameter", "displayName": "Match On Uri Prefix", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether or not the consumer should try to find a target consumer by matching the URI prefix if no exact match is found." }, - "muteException": { "index": 5, "kind": "parameter", "displayName": "Mute Exception", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "If enabled and an Exchange failed processing on the consumer side the response's body won't contain the exception's stack trace." }, - "produces": { "index": 6, "kind": "parameter", "displayName": "Produces", "group": "consumer", "label": "consumer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The content type this endpoint produces, such as application\/xml or application\/json." }, - "useCookieHandler": { "index": 7, "kind": "parameter", "displayName": "Use Cookie Handler", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to enable the Cookie Handler that allows Cookie addition, expiry, and retrieval (currently only supported by camel-platform-http-vertx)" }, - "useStreaming": { "index": 8, "kind": "parameter", "displayName": "Use Streaming", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to use streaming for large requests and responses (currently only supported by camel-platform-http-vertx)" }, - "bridgeErrorHandler": { "index": 9, "kind": "parameter", "displayName": "Bridge Error Handler", "group": "consumer (advanced)", "label": "consumer,advanced", "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 likes, will now be processed as a message and handled by the routing Error Handler. Important: This is only possible if the 3rd party component allows Camel to be alerted if an exception was thrown. Some components handle this internally only, and therefore bridgeErrorHandler is not possible. In other situations we may improve the Camel component to hook into the 3rd party component and make this possible for future releases. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored." }, - "exceptionHandler": { "index": 10, "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 default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored." }, - "exchangePattern": { "index": 11, "kind": "parameter", "displayName": "Exchange Pattern", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "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." }, - "fileNameExtWhitelist": { "index": 12, "kind": "parameter", "displayName": "File Name Ext Whitelist", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "A comma or whitespace separated list of file extensions. Uploads having these extensions will be stored locally. Null value or asterisk () will allow all files." }, - "headerFilterStrategy": { "index": 13, "kind": "parameter", "displayName": "Header Filter Strategy", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.spi.HeaderFilterStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom HeaderFilterStrategy to filter headers to and from Camel message." }, - "platformHttpEngine": { "index": 14, "kind": "parameter", "displayName": "Platform Http Engine", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.platform.http.spi.PlatformHttpEngine", "deprecated": false, "autowired": false, "secret": false, "description": "An HTTP Server engine implementation to serve the requests of this endpoint." } + "cookieDomain": { "index": 2, "kind": "parameter", "displayName": "Cookie Domain", "group": "consumer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.platform.http.cookie.CookieConfiguration", "configurationField": "cookieConfiguration", "description": "Sets which server can receive cookies." }, + "cookieHttpOnly": { "index": 3, "kind": "parameter", "displayName": "Cookie Http Only", "group": "consumer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.platform.http.cookie.CookieConfiguration", "configurationField": "cookieConfiguration", "description": "Sets whether to prevent client side scripts from accessing created cookies." }, + "cookieMaxAge": { "index": 4, "kind": "parameter", "displayName": "Cookie Max Age", "group": "consumer", "label": "", "required": false, "type": "integer", "javaType": "java.lang.Long", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.platform.http.cookie.CookieConfiguration", "configurationField": "cookieConfiguration", "description": "Sets the maximum cookie age in seconds." }, + "cookiePath": { "index": 5, "kind": "parameter", "displayName": "Cookie Path", "group": "consumer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "\/", "configurationClass": "org.apache.camel.component.platform.http.cookie.CookieConfiguration", "configurationField": "cookieConfiguration", "description": "Sets the URL path that must exist in the requested URL in order to send the Cookie." }, + "cookieSameSite": { "index": 6, "kind": "parameter", "displayName": "Cookie Same Site", "group": "consumer", "label": "", "required": false, "type": "object", "javaType": "org.apache.camel.component.platform.http.cookie.CookieConfiguration.CookieSameSite", "enum": [ "STRICT", "LAX", "NONE" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "Lax", "configurationClass": "org.apache.camel.component.platform.http.cookie.CookieConfiguration", "configurationField": "cookieConfiguration", "description": "Sets whether to prevent the browser from sending cookies along with cross-site requests." }, + "cookieSecure": { "index": 7, "kind": "parameter", "displayName": "Cookie Secure", "group": "consumer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.platform.http.cookie.CookieConfiguration", "configurationField": "cookieConfiguration", "description": "Sets whether the cookie is only sent to the server with an encrypted request over HTTPS." }, + "httpMethodRestrict": { "index": 8, "kind": "parameter", "displayName": "Http Method Restrict", "group": "consumer", "label": "consumer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "A comma separated list of HTTP methods to serve, e.g. GET,POST . If no methods are specified, all methods will be served." }, + "matchOnUriPrefix": { "index": 9, "kind": "parameter", "displayName": "Match On Uri Prefix", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether or not the consumer should try to find a target consumer by matching the URI prefix if no exact match is found." }, + "muteException": { "index": 10, "kind": "parameter", "displayName": "Mute Exception", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "If enabled and an Exchange failed processing on the consumer side the response's body won't contain the exception's stack trace." }, + "produces": { "index": 11, "kind": "parameter", "displayName": "Produces", "group": "consumer", "label": "consumer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The content type this endpoint produces, such as application\/xml or application\/json." }, + "useCookieHandler": { "index": 12, "kind": "parameter", "displayName": "Use Cookie Handler", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to enable the Cookie Handler that allows Cookie addition, expiry, and retrieval (currently only supported by camel-platform-http-vertx)" }, + "useStreaming": { "index": 13, "kind": "parameter", "displayName": "Use Streaming", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to use streaming for large requests and responses (currently only supported by camel-platform-http-vertx)" }, + "bridgeErrorHandler": { "index": 14, "kind": "parameter", "displayName": "Bridge Error Handler", "group": "consumer (advanced)", "label": "consumer,advanced", "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 likes, will now be processed as a message and handled by the routing Error Handler. Important: This is only possible if the 3rd party component allows Camel to be alerted if an exception was thrown. Some components handle this internally only, and therefore bridgeErrorHandler is not possible. In other situations we may improve the Camel component to hook into the 3rd party component and make this possible for future releases. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored." }, + "exceptionHandler": { "index": 15, "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 default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored." }, + "exchangePattern": { "index": 16, "kind": "parameter", "displayName": "Exchange Pattern", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "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." }, + "fileNameExtWhitelist": { "index": 17, "kind": "parameter", "displayName": "File Name Ext Whitelist", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "A comma or whitespace separated list of file extensions. Uploads having these extensions will be stored locally. Null value or asterisk () will allow all files." }, + "headerFilterStrategy": { "index": 18, "kind": "parameter", "displayName": "Header Filter Strategy", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.spi.HeaderFilterStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom HeaderFilterStrategy to filter headers to and from Camel message." }, + "platformHttpEngine": { "index": 19, "kind": "parameter", "displayName": "Platform Http Engine", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.platform.http.spi.PlatformHttpEngine", "deprecated": false, "autowired": false, "secret": false, "description": "An HTTP Server engine implementation to serve the requests of this endpoint." } } } diff --git a/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/cookie/CookieConfiguration.java b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/cookie/CookieConfiguration.java index 690a5b345fc83..4a267d9f43a26 100644 --- a/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/cookie/CookieConfiguration.java +++ b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/cookie/CookieConfiguration.java @@ -16,57 +16,111 @@ */ package org.apache.camel.component.platform.http.cookie; +import org.apache.camel.spi.Configurer; +import org.apache.camel.spi.UriParam; +import org.apache.camel.spi.UriParams; + /** * Attributes that are set when creating Cookies. */ +@UriParams +@Configurer(extended = true) public class CookieConfiguration { public static final String DEFAULT_PATH = "/"; public static final boolean DEFAULT_SECURE_FLAG = false; public static final boolean DEFAULT_HTTP_ONLY_FLAG = false; public static final CookieSameSite DEFAULT_SAME_SITE = CookieSameSite.LAX; - private String path = DEFAULT_PATH; - private String domain; - private Long maxAge; - private boolean secure = DEFAULT_SECURE_FLAG; - private boolean httpOnly = DEFAULT_HTTP_ONLY_FLAG; - private CookieSameSite sameSite = DEFAULT_SAME_SITE; + @UriParam(defaultValue = "/") + private String cookiePath = DEFAULT_PATH; + @UriParam + private String cookieDomain; + @UriParam + private Long cookieMaxAge; + @UriParam(defaultValue = "false") + private boolean cookieSecure = DEFAULT_SECURE_FLAG; + @UriParam(defaultValue = "false") + private boolean cookieHttpOnly = DEFAULT_HTTP_ONLY_FLAG; + @UriParam(defaultValue = "Lax") + private CookieSameSite cookieSameSite = DEFAULT_SAME_SITE; public CookieConfiguration() { } - public CookieConfiguration(String path, String domain, Long maxAge, - boolean secure, boolean httpOnly, CookieSameSite sameSite) { - this.path = path; - this.domain = domain; - this.maxAge = maxAge; - this.secure = secure; - this.httpOnly = httpOnly; - this.sameSite = sameSite; + public CookieConfiguration(String cookiePath, String cookieDomain, Long cookieMaxAge, + boolean cookieSecure, boolean cookieHttpOnly, CookieSameSite cookieSameSite) { + this.cookiePath = cookiePath; + this.cookieDomain = cookieDomain; + this.cookieMaxAge = cookieMaxAge; + this.cookieSecure = cookieSecure; + this.cookieHttpOnly = cookieHttpOnly; + this.cookieSameSite = cookieSameSite; } - public String getPath() { - return path; + /** + * Sets the URL path that must exist in the requested URL in order to send the Cookie. + */ + public void setCookiePath(String cookiePath) { + this.cookiePath = cookiePath; } - public String getDomain() { - return domain; + public String getCookiePath() { + return cookiePath; } - public Long getMaxAge() { - return maxAge; + /** + * Sets which server can receive cookies. + */ + public void setCookieDomain(String cookieDomain) { + this.cookieDomain = cookieDomain; } - public boolean isSecure() { - return secure; + public String getCookieDomain() { + return cookieDomain; } - public boolean isHttpOnly() { - return httpOnly; + /** + * Sets the maximum cookie age in seconds. + */ + public void setCookieMaxAge(Long cookieMaxAge) { + this.cookieMaxAge = cookieMaxAge; + } + + public Long getCookieMaxAge() { + return cookieMaxAge; + } + + /** + * Sets whether the cookie is only sent to the server with an encrypted request over HTTPS. + */ + public void setCookieSecure(boolean cookieSecure) { + this.cookieSecure = cookieSecure; + } + + public boolean isCookieSecure() { + return cookieSecure; + } + + /** + * Sets whether to prevent client side scripts from accessing created cookies. + */ + public void setCookieHttpOnly(boolean cookieHttpOnly) { + this.cookieHttpOnly = cookieHttpOnly; + } + + public boolean isCookieHttpOnly() { + return cookieHttpOnly; + } + + /** + * Sets whether to prevent the browser from sending cookies along with cross-site requests. + */ + public void setCookieSameSite(CookieSameSite cookieSameSite) { + this.cookieSameSite = cookieSameSite; } - public CookieSameSite getSameSite() { - return sameSite; + public CookieSameSite getCookieSameSite() { + return cookieSameSite; } public static class Builder { @@ -100,7 +154,7 @@ public Builder setDomain(String domain) { /** * Sets the maximum cookie age in seconds. */ - public Builder setMaxAge(long maxAge) { + public Builder setMaxAge(Long maxAge) { this.maxAge = maxAge; return this; } diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/PlatformHttpEndpointBuilderFactory.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/PlatformHttpEndpointBuilderFactory.java index 7bf62ec49354f..9d1d899ff4458 100644 --- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/PlatformHttpEndpointBuilderFactory.java +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/PlatformHttpEndpointBuilderFactory.java @@ -61,37 +61,164 @@ default PlatformHttpEndpointBuilder consumes(String consumes) { return this; } /** - * The properties set on a Cookies when a Cookie is added (currently - * only supported by camel-platform-http-vertx). + * Sets which server can receive cookies. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: consumer + * + * @param cookieDomain the value to set + * @return the dsl builder + */ + default PlatformHttpEndpointBuilder cookieDomain(String cookieDomain) { + doSetProperty("cookieDomain", cookieDomain); + return this; + } + /** + * Sets whether to prevent client side scripts from accessing created + * cookies. + * + * The option is a: <code>boolean</code> type. + * + * Default: false + * Group: consumer + * + * @param cookieHttpOnly the value to set + * @return the dsl builder + */ + default PlatformHttpEndpointBuilder cookieHttpOnly( + boolean cookieHttpOnly) { + doSetProperty("cookieHttpOnly", cookieHttpOnly); + return this; + } + /** + * Sets whether to prevent client side scripts from accessing created + * cookies. + * + * The option will be converted to a <code>boolean</code> + * type. + * + * Default: false + * Group: consumer + * + * @param cookieHttpOnly the value to set + * @return the dsl builder + */ + default PlatformHttpEndpointBuilder cookieHttpOnly(String cookieHttpOnly) { + doSetProperty("cookieHttpOnly", cookieHttpOnly); + return this; + } + /** + * Sets the maximum cookie age in seconds. + * + * The option is a: <code>java.lang.Long</code> type. + * + * Group: consumer + * + * @param cookieMaxAge the value to set + * @return the dsl builder + */ + default PlatformHttpEndpointBuilder cookieMaxAge(Long cookieMaxAge) { + doSetProperty("cookieMaxAge", cookieMaxAge); + return this; + } + /** + * Sets the maximum cookie age in seconds. + * + * The option will be converted to a + * <code>java.lang.Long</code> type. + * + * Group: consumer + * + * @param cookieMaxAge the value to set + * @return the dsl builder + */ + default PlatformHttpEndpointBuilder cookieMaxAge(String cookieMaxAge) { + doSetProperty("cookieMaxAge", cookieMaxAge); + return this; + } + /** + * Sets the URL path that must exist in the requested URL in order to + * send the Cookie. + * + * The option is a: <code>java.lang.String</code> type. + * + * Default: / + * Group: consumer + * + * @param cookiePath the value to set + * @return the dsl builder + */ + default PlatformHttpEndpointBuilder cookiePath(String cookiePath) { + doSetProperty("cookiePath", cookiePath); + return this; + } + /** + * Sets whether to prevent the browser from sending cookies along with + * cross-site requests. * * The option is a: - * <code>org.apache.camel.component.platform.http.cookie.CookieConfiguration</code> type. + * <code>org.apache.camel.component.platform.http.cookie.CookieConfiguration.CookieSameSite</code> type. * + * Default: Lax * Group: consumer * - * @param cookieConfiguration the value to set + * @param cookieSameSite the value to set * @return the dsl builder */ - default PlatformHttpEndpointBuilder cookieConfiguration( - org.apache.camel.component.platform.http.cookie.CookieConfiguration cookieConfiguration) { - doSetProperty("cookieConfiguration", cookieConfiguration); + default PlatformHttpEndpointBuilder cookieSameSite( + org.apache.camel.component.platform.http.cookie.CookieConfiguration.CookieSameSite cookieSameSite) { + doSetProperty("cookieSameSite", cookieSameSite); return this; } /** - * The properties set on a Cookies when a Cookie is added (currently - * only supported by camel-platform-http-vertx). + * Sets whether to prevent the browser from sending cookies along with + * cross-site requests. * * The option will be converted to a - * <code>org.apache.camel.component.platform.http.cookie.CookieConfiguration</code> type. + * <code>org.apache.camel.component.platform.http.cookie.CookieConfiguration.CookieSameSite</code> type. + * + * Default: Lax + * Group: consumer * + * @param cookieSameSite the value to set + * @return the dsl builder + */ + default PlatformHttpEndpointBuilder cookieSameSite(String cookieSameSite) { + doSetProperty("cookieSameSite", cookieSameSite); + return this; + } + /** + * Sets whether the cookie is only sent to the server with an encrypted + * request over HTTPS. + * + * The option is a: <code>boolean</code> type. + * + * Default: false + * Group: consumer + * + * @param cookieSecure the value to set + * @return the dsl builder + */ + default PlatformHttpEndpointBuilder cookieSecure(boolean cookieSecure) { + doSetProperty("cookieSecure", cookieSecure); + return this; + } + /** + * Sets whether the cookie is only sent to the server with an encrypted + * request over HTTPS. + * + * The option will be converted to a <code>boolean</code> + * type. + * + * Default: false * Group: consumer * - * @param cookieConfiguration the value to set + * @param cookieSecure the value to set * @return the dsl builder */ - default PlatformHttpEndpointBuilder cookieConfiguration( - String cookieConfiguration) { - doSetProperty("cookieConfiguration", cookieConfiguration); + default PlatformHttpEndpointBuilder cookieSecure(String cookieSecure) { + doSetProperty("cookieSecure", cookieSecure); return this; } /** diff --git a/dsl/camel-kotlin-api/src/generated/kotlin/org/apache/camel/kotlin/components/PlatformHttpUriDsl.kt b/dsl/camel-kotlin-api/src/generated/kotlin/org/apache/camel/kotlin/components/PlatformHttpUriDsl.kt index d47c5a7373edb..926e48ed54d56 100644 --- a/dsl/camel-kotlin-api/src/generated/kotlin/org/apache/camel/kotlin/components/PlatformHttpUriDsl.kt +++ b/dsl/camel-kotlin-api/src/generated/kotlin/org/apache/camel/kotlin/components/PlatformHttpUriDsl.kt @@ -17,6 +17,7 @@ package org.apache.camel.kotlin.components import kotlin.Boolean +import kotlin.Int import kotlin.String import kotlin.Unit import org.apache.camel.kotlin.CamelDslMarker @@ -48,8 +49,40 @@ public class PlatformHttpUriDsl( it.property("consumes", consumes) } - public fun cookieConfiguration(cookieConfiguration: String) { - it.property("cookieConfiguration", cookieConfiguration) + public fun cookieDomain(cookieDomain: String) { + it.property("cookieDomain", cookieDomain) + } + + public fun cookieHttpOnly(cookieHttpOnly: String) { + it.property("cookieHttpOnly", cookieHttpOnly) + } + + public fun cookieHttpOnly(cookieHttpOnly: Boolean) { + it.property("cookieHttpOnly", cookieHttpOnly.toString()) + } + + public fun cookieMaxAge(cookieMaxAge: String) { + it.property("cookieMaxAge", cookieMaxAge) + } + + public fun cookieMaxAge(cookieMaxAge: Int) { + it.property("cookieMaxAge", cookieMaxAge.toString()) + } + + public fun cookiePath(cookiePath: String) { + it.property("cookiePath", cookiePath) + } + + public fun cookieSameSite(cookieSameSite: String) { + it.property("cookieSameSite", cookieSameSite) + } + + public fun cookieSecure(cookieSecure: String) { + it.property("cookieSecure", cookieSecure) + } + + public fun cookieSecure(cookieSecure: Boolean) { + it.property("cookieSecure", cookieSecure.toString()) } public fun httpMethodRestrict(httpMethodRestrict: String) { From 73660357d33243612951d0c4bcb00417539e63a8 Mon Sep 17 00:00:00 2001 From: Jono Date: Wed, 28 Feb 2024 00:16:57 +1300 Subject: [PATCH 4/5] CAMEL-20019 couple of minor doc and test case updates. --- .../platform/http/vertx/VertxPlatformHttpCookieTest.java | 4 ++-- .../camel/component/platform/http/PlatformHttpEndpoint.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpCookieTest.java b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpCookieTest.java index 6a0d054c0011c..b042fed5094ff 100644 --- a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpCookieTest.java +++ b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpCookieTest.java @@ -79,7 +79,7 @@ public void testAddCookieCustomConfiguration() throws Exception { .setHttpOnly(true) .setSecure(true) .setMaxAge(cookieMaxAge) - .setSameSite(CookieConfiguration.CookieSameSite.LAX) + .setSameSite(CookieConfiguration.CookieSameSite.STRICT) .build()); try { @@ -108,7 +108,7 @@ public void configure() { .secured(true) .httpOnly(true) .maxAge(cookieMaxAge) - .sameSite("Lax")) + .sameSite("Strict")) .body(equalTo("add-custom")); } finally { context.stop(); diff --git a/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpEndpoint.java b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpEndpoint.java index 4cd2a32793a83..94360f23ffb94 100644 --- a/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpEndpoint.java +++ b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpEndpoint.java @@ -74,8 +74,8 @@ public class PlatformHttpEndpoint extends DefaultEndpoint implements AsyncEndpoi description = "Whether to use streaming for large requests and responses (currently only supported by camel-platform-http-vertx)") private boolean useStreaming; - @UriParam(label = "consumer", description = "The properties set on a Cookies when a Cookie is added (currently" - + " only supported by camel-platform-http-vertx)") + @UriParam(label = "consumer", description = "The properties set on a Cookies when a Cookie is added via the" + + " Cookie Handler (currently only supported by camel-platform-http-vertx)") private CookieConfiguration cookieConfiguration = new CookieConfiguration(); @UriParam(label = "consumer", From 765b12fc0fc84ae8e87c88ad36f114bbe0dced5a Mon Sep 17 00:00:00 2001 From: Jono Date: Wed, 28 Feb 2024 00:17:55 +1300 Subject: [PATCH 5/5] CAMEL-20019 add note to upgrade guide --- .../modules/ROOT/pages/camel-4x-upgrade-guide-4_5.adoc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_5.adoc b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_5.adoc index d63ab7d76bdbd..956f714d155ef 100644 --- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_5.adoc +++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_5.adoc @@ -26,3 +26,7 @@ After: ---- String uri = exchange.getProperty(Exchange.INTERCEPTED_ENDPOINT, String.class); ---- + +=== camel-platform-http-vertx + +Added a Cookie Handler allowing the addition, retrieval and expiry of Cookies. \ No newline at end of file