This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new e554a7967d6 CAMEL-21351: AcceptAllHeaderFilterStrategy
e554a7967d6 is described below
commit e554a7967d608433071bd1208cbc0ba3874b1c41
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Oct 16 09:08:29 2024 +0200
CAMEL-21351: AcceptAllHeaderFilterStrategy
---
.../org/apache/camel/catalog/beans.properties | 1 +
.../beans/AcceptAllHeaderFilterStrategy.json | 15 +++++++
.../impl/AcceptAllHeaderFilterStrategyTest.java | 46 ++++++++++++++++++++
.../AcceptAllHeaderFilterStrategyConfigurer.java | 37 ++++++++++++++++
.../services/org/apache/camel/bean.properties | 2 +-
.../camel/bean/AcceptAllHeaderFilterStrategy.json | 15 +++++++
...che.camel.support.AcceptAllHeaderFilterStrategy | 2 +
.../support/AcceptAllHeaderFilterStrategy.java | 50 ++++++++++++++++++++++
8 files changed, 167 insertions(+), 1 deletion(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/beans.properties
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/beans.properties
index 9426062c8f0..6eb267be21e 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/beans.properties
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/beans.properties
@@ -1,3 +1,4 @@
+AcceptAllHeaderFilterStrategy
CaffeineAggregationRepository
CaffeineIdempotentRepository
CassandraAggregationRepository
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/beans/AcceptAllHeaderFilterStrategy.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/beans/AcceptAllHeaderFilterStrategy.json
new file mode 100644
index 00000000000..5197d7fd75a
--- /dev/null
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/beans/AcceptAllHeaderFilterStrategy.json
@@ -0,0 +1,15 @@
+{
+ "bean": {
+ "kind": "bean",
+ "name": "AcceptAllHeaderFilterStrategy",
+ "javaType": "org.apache.camel.support.AcceptAllHeaderFilterStrategy",
+ "interfaceType": "org.apache.camel.spi.HeaderFilterStrategy",
+ "title": "Accept All Header Filter Strategy",
+ "description": "This strategy is used for accepting all headers.The
intention is for use with development and troubleshooting where you want Camel
to keep all headers\n * when sending and receiving using components that uses
HeaderFilterStrategy",
+ "deprecated": false,
+ "groupId": "org.apache.camel",
+ "artifactId": "camel-support",
+ "version": "4.9.0-SNAPSHOT"
+ }
+}
+
diff --git
a/core/camel-core/src/test/java/org/apache/camel/impl/AcceptAllHeaderFilterStrategyTest.java
b/core/camel-core/src/test/java/org/apache/camel/impl/AcceptAllHeaderFilterStrategyTest.java
new file mode 100644
index 00000000000..0a85f0c755d
--- /dev/null
+++
b/core/camel-core/src/test/java/org/apache/camel/impl/AcceptAllHeaderFilterStrategyTest.java
@@ -0,0 +1,46 @@
+/*
+ * 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.impl;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.spi.HeaderFilterStrategy;
+import org.apache.camel.support.AcceptAllHeaderFilterStrategy;
+import org.apache.camel.support.DefaultExchange;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+
+public class AcceptAllHeaderFilterStrategyTest extends ContextTestSupport {
+
+ @Test
+ public void testAcceptAll() {
+ HeaderFilterStrategy comp = new AcceptAllHeaderFilterStrategy();
+
+ Exchange exchange = new DefaultExchange(context);
+ exchange.getIn().setHeader("bar", 123);
+ exchange.getIn().setHeader("foo", "cheese");
+ exchange.getIn().setHeader("CamelVersion", "3.7");
+ exchange.getIn().setHeader("org.apache.camel.component.jetty.session",
"true");
+
+ assertFalse(comp.applyFilterToExternalHeaders("bar", 123, exchange));
+ assertFalse(comp.applyFilterToExternalHeaders("foo", "cheese",
exchange));
+ assertFalse(comp.applyFilterToExternalHeaders("CamelVersion", "3.7",
exchange));
+
assertFalse(comp.applyFilterToExternalHeaders("org.apache.camel.component.jetty.session",
"true", exchange));
+ }
+
+}
diff --git
a/core/camel-support/src/generated/java/org/apache/camel/support/AcceptAllHeaderFilterStrategyConfigurer.java
b/core/camel-support/src/generated/java/org/apache/camel/support/AcceptAllHeaderFilterStrategyConfigurer.java
new file mode 100644
index 00000000000..9dee484ab6a
--- /dev/null
+++
b/core/camel-support/src/generated/java/org/apache/camel/support/AcceptAllHeaderFilterStrategyConfigurer.java
@@ -0,0 +1,37 @@
+/* Generated by camel build tools - do NOT edit this file! */
+package org.apache.camel.support;
+
+import javax.annotation.processing.Generated;
+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.support.AcceptAllHeaderFilterStrategy;
+
+/**
+ * Generated by camel build tools - do NOT edit this file!
+ */
+@Generated("org.apache.camel.maven.packaging.GenerateConfigurerMojo")
+@SuppressWarnings("unchecked")
+public class AcceptAllHeaderFilterStrategyConfigurer extends
org.apache.camel.support.component.PropertyConfigurerSupport implements
GeneratedPropertyConfigurer, PropertyConfigurerGetter {
+
+ @Override
+ public boolean configure(CamelContext camelContext, Object obj, String
name, Object value, boolean ignoreCase) {
+ return false;
+ }
+
+ @Override
+ public Class<?> getOptionType(String name, boolean ignoreCase) {
+ return null;
+ }
+
+ @Override
+ public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
+ return null;
+ }
+}
+
diff --git
a/core/camel-support/src/generated/resources/META-INF/services/org/apache/camel/bean.properties
b/core/camel-support/src/generated/resources/META-INF/services/org/apache/camel/bean.properties
index 4818dfdb493..8e334eba85d 100644
---
a/core/camel-support/src/generated/resources/META-INF/services/org/apache/camel/bean.properties
+++
b/core/camel-support/src/generated/resources/META-INF/services/org/apache/camel/bean.properties
@@ -1,5 +1,5 @@
# Generated by camel build tools - do NOT edit this file!
-bean=DefaultHeaderFilterStrategy FileIdempotentRepository
MemoryIdempotentRepository ThrottlingExceptionRoutePolicy
ThrottlingInflightRoutePolicy
+bean=AcceptAllHeaderFilterStrategy DefaultHeaderFilterStrategy
FileIdempotentRepository MemoryIdempotentRepository
ThrottlingExceptionRoutePolicy ThrottlingInflightRoutePolicy
groupId=org.apache.camel
artifactId=camel-support
version=4.9.0-SNAPSHOT
diff --git
a/core/camel-support/src/generated/resources/META-INF/services/org/apache/camel/bean/AcceptAllHeaderFilterStrategy.json
b/core/camel-support/src/generated/resources/META-INF/services/org/apache/camel/bean/AcceptAllHeaderFilterStrategy.json
new file mode 100644
index 00000000000..5197d7fd75a
--- /dev/null
+++
b/core/camel-support/src/generated/resources/META-INF/services/org/apache/camel/bean/AcceptAllHeaderFilterStrategy.json
@@ -0,0 +1,15 @@
+{
+ "bean": {
+ "kind": "bean",
+ "name": "AcceptAllHeaderFilterStrategy",
+ "javaType": "org.apache.camel.support.AcceptAllHeaderFilterStrategy",
+ "interfaceType": "org.apache.camel.spi.HeaderFilterStrategy",
+ "title": "Accept All Header Filter Strategy",
+ "description": "This strategy is used for accepting all headers.The
intention is for use with development and troubleshooting where you want Camel
to keep all headers\n * when sending and receiving using components that uses
HeaderFilterStrategy",
+ "deprecated": false,
+ "groupId": "org.apache.camel",
+ "artifactId": "camel-support",
+ "version": "4.9.0-SNAPSHOT"
+ }
+}
+
diff --git
a/core/camel-support/src/generated/resources/META-INF/services/org/apache/camel/configurer/org.apache.camel.support.AcceptAllHeaderFilterStrategy
b/core/camel-support/src/generated/resources/META-INF/services/org/apache/camel/configurer/org.apache.camel.support.AcceptAllHeaderFilterStrategy
new file mode 100644
index 00000000000..e9f669cf24a
--- /dev/null
+++
b/core/camel-support/src/generated/resources/META-INF/services/org/apache/camel/configurer/org.apache.camel.support.AcceptAllHeaderFilterStrategy
@@ -0,0 +1,2 @@
+# Generated by camel build tools - do NOT edit this file!
+class=org.apache.camel.support.AcceptAllHeaderFilterStrategyConfigurer
diff --git
a/core/camel-support/src/main/java/org/apache/camel/support/AcceptAllHeaderFilterStrategy.java
b/core/camel-support/src/main/java/org/apache/camel/support/AcceptAllHeaderFilterStrategy.java
new file mode 100644
index 00000000000..2a319743edb
--- /dev/null
+++
b/core/camel-support/src/main/java/org/apache/camel/support/AcceptAllHeaderFilterStrategy.java
@@ -0,0 +1,50 @@
+/*
+ * 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.support;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.spi.Configurer;
+import org.apache.camel.spi.HeaderFilterStrategy;
+import org.apache.camel.spi.Metadata;
+
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Set;
+import java.util.regex.Pattern;
+
+/**
+ * This strategy is used for accepting all headers.
+ * The intention is for use with development and troubleshooting where you
want Camel to keep all headers
+ * when sending and receiving using components that uses {@link
HeaderFilterStrategy}.
+ */
+@Metadata(label = "bean",
+ description = "This strategy is used for accepting all headers.The
intention is for use with development and troubleshooting where you want Camel
to keep all headers\n" +
+ " * when sending and receiving using components that
uses HeaderFilterStrategy",
+ annotations = {
"interfaceName=org.apache.camel.spi.HeaderFilterStrategy" })
+@Configurer(metadataOnly = true)
+public class AcceptAllHeaderFilterStrategy implements HeaderFilterStrategy {
+
+ @Override
+ public boolean applyFilterToCamelHeaders(String headerName, Object
headerValue, Exchange exchange) {
+ return false; // return false to accept header
+ }
+
+ @Override
+ public boolean applyFilterToExternalHeaders(String headerName, Object
headerValue, Exchange exchange) {
+ return false; // return false to accept header
+ }
+}