CVE-2016-8749
Description
Apache Camel's Jackson and JacksonXML unmarshalling operation are vulnerable to Remote Code Execution attacks.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
org.apache.camel:camel-jacksonMaven | < 2.16.5 | 2.16.5 |
org.apache.camel:camel-jacksonMaven | >= 2.17.0, < 2.17.5 | 2.17.5 |
org.apache.camel:camel-jacksonMaven | >= 2.18.0, < 2.18.2 | 2.18.2 |
Affected products
1- Apache Software Foundation/Apache Camelv5Range: 2.16.0 to 2.16.4
Patches
128c862aa11e31CAMEL-10604 - Camel-JacksonXML: Add an option to allow the UnmarshallType header use
6 files changed · +106 −2
camel-core/src/main/java/org/apache/camel/model/dataformat/JacksonXMLDataFormat.java+18 −0 modified@@ -68,6 +68,8 @@ public class JacksonXMLDataFormat extends DataFormatDefinition { private String enableFeatures; @XmlAttribute private String disableFeatures; + @XmlAttribute + private Boolean allowUnmarshallType; public JacksonXMLDataFormat() { super("jacksonxml"); @@ -256,6 +258,19 @@ public String getDisableFeatures() { public void setDisableFeatures(String disableFeatures) { this.disableFeatures = disableFeatures; } + + public Boolean getAllowUnmarshallType() { + return allowUnmarshallType; + } + + /** + * If enabled then Jackson is allowed to attempt to use the CamelJacksonUnmarshalType header during the unmarshalling. + * <p/> + * This should only be enabled when desired to be used. + */ + public void setAllowUnmarshallType(Boolean allowUnmarshallType) { + this.allowUnmarshallType = allowUnmarshallType; + } @Override public String getDataFormatName() { @@ -326,6 +341,9 @@ protected void configureDataFormat(DataFormat dataFormat, CamelContext camelCont if (disableFeatures != null) { setProperty(camelContext, dataFormat, "disableFeatures", disableFeatures); } + if (allowUnmarshallType != null) { + setProperty(camelContext, dataFormat, "allowUnmarshallType", allowUnmarshallType); + } } }
components/camel-jacksonxml/src/main/docs/jacksonxml-dataformat.adoc+2 −1 modified@@ -36,7 +36,7 @@ JacksonXML Options // dataformat options: START -The JacksonXML dataformat supports 13 options which are listed below. +The JacksonXML dataformat supports 14 options which are listed below. @@ -57,6 +57,7 @@ The JacksonXML dataformat supports 13 options which are listed below. | moduleRefs | | String | To use custom Jackson modules referred from the Camel registry. Multiple modules can be separated by comma. | enableFeatures | | String | Set of features to enable on the Jackson com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that matches a enum from com.fasterxml.jackson.databind.SerializationFeature com.fasterxml.jackson.databind.DeserializationFeature or com.fasterxml.jackson.databind.MapperFeature Multiple features can be separated by comma | disableFeatures | | String | Set of features to disable on the Jackson com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that matches a enum from com.fasterxml.jackson.databind.SerializationFeature com.fasterxml.jackson.databind.DeserializationFeature or com.fasterxml.jackson.databind.MapperFeature Multiple features can be separated by comma +| allowUnmarshallType | false | Boolean | If enabled then Jackson is allowed to attempt to use the CamelJacksonUnmarshalType header during the unmarshalling. This should only be enabled when desired to be used. |======================================================================= {% endraw %} // dataformat options: END
components/camel-jacksonxml/src/main/java/org/apache/camel/component/jacksonxml/JacksonXMLDataFormat.java+18 −1 modified@@ -68,6 +68,7 @@ public class JacksonXMLDataFormat extends ServiceSupport implements DataFormat, private String enableFeatures; private String disableFeatures; private boolean enableJacksonTypeConverter; + private boolean allowUnmarshallType; /** * Use the default Jackson {@link XmlMapper} and {@link Map} @@ -158,7 +159,10 @@ public Object unmarshal(Exchange exchange, InputStream stream) throws Exception // is there a header with the unmarshal type? Class<?> clazz = unmarshalType; - String type = exchange.getIn().getHeader(JacksonXMLConstants.UNMARSHAL_TYPE, String.class); + String type = null; + if (allowUnmarshallType) { + type = exchange.getIn().getHeader(JacksonXMLConstants.UNMARSHAL_TYPE, String.class); + } if (type == null && isAllowJmsType()) { type = exchange.getIn().getHeader("JMSType", String.class); } @@ -326,6 +330,19 @@ public boolean isEnableJacksonTypeConverter() { public void setEnableJacksonTypeConverter(boolean enableJacksonTypeConverter) { this.enableJacksonTypeConverter = enableJacksonTypeConverter; } + + public boolean isAllowUnmarshallType() { + return allowUnmarshallType; + } + + /** + * If enabled then Jackson is allowed to attempt to use the CamelJacksonUnmarshalType header during the unmarshalling. + * <p/> + * This should only be enabled when desired to be used. + */ + public void setAllowUnmarshallType(boolean allowJacksonUnmarshallType) { + this.allowUnmarshallType = allowJacksonUnmarshallType; + } public String getEnableFeatures() { return enableFeatures;
components/camel-jacksonxml/src/test/java/org/apache/camel/component/jacksonxml/JacksonMarshalUnmarshalTypeHeaderNotAllowedTest.java+53 −0 added@@ -0,0 +1,53 @@ +/** + * 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.jacksonxml; + +import java.util.LinkedHashMap; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.Test; + +public class JacksonMarshalUnmarshalTypeHeaderNotAllowedTest extends CamelTestSupport { + + @Test + public void testUnmarshalPojo() throws Exception { + MockEndpoint mock = getMockEndpoint("mock:reversePojo"); + mock.expectedMessageCount(1); + + String json = "<pojo name=\"Camel\"/>"; + template.sendBodyAndHeader("direct:backPojo", json, JacksonXMLConstants.UNMARSHAL_TYPE, TestPojo.class.getName()); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + + @Override + public void configure() throws Exception { + JacksonXMLDataFormat format = new JacksonXMLDataFormat(); + + from("direct:backPojo").unmarshal(format).to("mock:reversePojo"); + + } + }; + } + +}
components/camel-jacksonxml/src/test/java/org/apache/camel/component/jacksonxml/JacksonMarshalUnmarshalTypeHeaderTest.java+1 −0 modified@@ -46,6 +46,7 @@ protected RouteBuilder createRouteBuilder() throws Exception { @Override public void configure() throws Exception { JacksonXMLDataFormat format = new JacksonXMLDataFormat(); + format.setAllowUnmarshallType(true); from("direct:backPojo").unmarshal(format).to("mock:reversePojo");
components-starter/camel-jacksonxml-starter/src/main/java/org/apache/camel/component/jacksonxml/springboot/JacksonXMLDataFormatConfiguration.java+14 −0 modified@@ -101,6 +101,12 @@ public class JacksonXMLDataFormatConfiguration { * separated by comma */ private String disableFeatures; + /** + * If enabled then Jackson is allowed to attempt to use the + * CamelJacksonUnmarshalType header during the unmarshalling. This should + * only be enabled when desired to be used. + */ + private Boolean allowUnmarshallType = false; public String getXmlMapper() { return xmlMapper; @@ -205,4 +211,12 @@ public String getDisableFeatures() { public void setDisableFeatures(String disableFeatures) { this.disableFeatures = disableFeatures; } + + public Boolean getAllowUnmarshallType() { + return allowUnmarshallType; + } + + public void setAllowUnmarshallType(Boolean allowUnmarshallType) { + this.allowUnmarshallType = allowUnmarshallType; + } } \ No newline at end of file
881e5099f943CAMEL-10604 - Camel-JacksonXML: Add an option to allow the UnmarshallType header use
6 files changed · +106 −2
camel-core/src/main/java/org/apache/camel/model/dataformat/JacksonXMLDataFormat.java+18 −0 modified@@ -68,6 +68,8 @@ public class JacksonXMLDataFormat extends DataFormatDefinition { private String enableFeatures; @XmlAttribute private String disableFeatures; + @XmlAttribute + private Boolean allowUnmarshallType; public JacksonXMLDataFormat() { super("jacksonxml"); @@ -256,6 +258,19 @@ public String getDisableFeatures() { public void setDisableFeatures(String disableFeatures) { this.disableFeatures = disableFeatures; } + + public Boolean getAllowUnmarshallType() { + return allowUnmarshallType; + } + + /** + * If enabled then Jackson is allowed to attempt to use the CamelJacksonUnmarshalType header during the unmarshalling. + * <p/> + * This should only be enabled when desired to be used. + */ + public void setAllowUnmarshallType(Boolean allowUnmarshallType) { + this.allowUnmarshallType = allowUnmarshallType; + } @Override public String getDataFormatName() { @@ -326,6 +341,9 @@ protected void configureDataFormat(DataFormat dataFormat, CamelContext camelCont if (disableFeatures != null) { setProperty(camelContext, dataFormat, "disableFeatures", disableFeatures); } + if (allowUnmarshallType != null) { + setProperty(camelContext, dataFormat, "allowUnmarshallType", allowUnmarshallType); + } } }
components/camel-jacksonxml/src/main/docs/jacksonxml-dataformat.adoc+2 −1 modified@@ -36,7 +36,7 @@ JacksonXML Options // dataformat options: START -The JacksonXML dataformat supports 13 options which are listed below. +The JacksonXML dataformat supports 14 options which are listed below. @@ -57,6 +57,7 @@ The JacksonXML dataformat supports 13 options which are listed below. | moduleRefs | | String | To use custom Jackson modules referred from the Camel registry. Multiple modules can be separated by comma. | enableFeatures | | String | Set of features to enable on the Jackson com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that matches a enum from com.fasterxml.jackson.databind.SerializationFeature com.fasterxml.jackson.databind.DeserializationFeature or com.fasterxml.jackson.databind.MapperFeature Multiple features can be separated by comma | disableFeatures | | String | Set of features to disable on the Jackson com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that matches a enum from com.fasterxml.jackson.databind.SerializationFeature com.fasterxml.jackson.databind.DeserializationFeature or com.fasterxml.jackson.databind.MapperFeature Multiple features can be separated by comma +| allowUnmarshallType | false | Boolean | If enabled then Jackson is allowed to attempt to use the CamelJacksonUnmarshalType header during the unmarshalling. This should only be enabled when desired to be used. |======================================================================= {% endraw %} // dataformat options: END
components/camel-jacksonxml/src/main/java/org/apache/camel/component/jacksonxml/JacksonXMLDataFormat.java+18 −1 modified@@ -68,6 +68,7 @@ public class JacksonXMLDataFormat extends ServiceSupport implements DataFormat, private String enableFeatures; private String disableFeatures; private boolean enableJacksonTypeConverter; + private boolean allowUnmarshallType; /** * Use the default Jackson {@link XmlMapper} and {@link Map} @@ -158,7 +159,10 @@ public Object unmarshal(Exchange exchange, InputStream stream) throws Exception // is there a header with the unmarshal type? Class<?> clazz = unmarshalType; - String type = exchange.getIn().getHeader(JacksonXMLConstants.UNMARSHAL_TYPE, String.class); + String type = null; + if (allowUnmarshallType) { + type = exchange.getIn().getHeader(JacksonXMLConstants.UNMARSHAL_TYPE, String.class); + } if (type == null && isAllowJmsType()) { type = exchange.getIn().getHeader("JMSType", String.class); } @@ -326,6 +330,19 @@ public boolean isEnableJacksonTypeConverter() { public void setEnableJacksonTypeConverter(boolean enableJacksonTypeConverter) { this.enableJacksonTypeConverter = enableJacksonTypeConverter; } + + public boolean isAllowUnmarshallType() { + return allowUnmarshallType; + } + + /** + * If enabled then Jackson is allowed to attempt to use the CamelJacksonUnmarshalType header during the unmarshalling. + * <p/> + * This should only be enabled when desired to be used. + */ + public void setAllowUnmarshallType(boolean allowJacksonUnmarshallType) { + this.allowUnmarshallType = allowJacksonUnmarshallType; + } public String getEnableFeatures() { return enableFeatures;
components/camel-jacksonxml/src/test/java/org/apache/camel/component/jacksonxml/JacksonMarshalUnmarshalTypeHeaderNotAllowedTest.java+53 −0 added@@ -0,0 +1,53 @@ +/** + * 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.jacksonxml; + +import java.util.LinkedHashMap; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.Test; + +public class JacksonMarshalUnmarshalTypeHeaderNotAllowedTest extends CamelTestSupport { + + @Test + public void testUnmarshalPojo() throws Exception { + MockEndpoint mock = getMockEndpoint("mock:reversePojo"); + mock.expectedMessageCount(1); + + String json = "<pojo name=\"Camel\"/>"; + template.sendBodyAndHeader("direct:backPojo", json, JacksonXMLConstants.UNMARSHAL_TYPE, TestPojo.class.getName()); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + + @Override + public void configure() throws Exception { + JacksonXMLDataFormat format = new JacksonXMLDataFormat(); + + from("direct:backPojo").unmarshal(format).to("mock:reversePojo"); + + } + }; + } + +}
components/camel-jacksonxml/src/test/java/org/apache/camel/component/jacksonxml/JacksonMarshalUnmarshalTypeHeaderTest.java+1 −0 modified@@ -46,6 +46,7 @@ protected RouteBuilder createRouteBuilder() throws Exception { @Override public void configure() throws Exception { JacksonXMLDataFormat format = new JacksonXMLDataFormat(); + format.setAllowUnmarshallType(true); from("direct:backPojo").unmarshal(format).to("mock:reversePojo");
components-starter/camel-jacksonxml-starter/src/main/java/org/apache/camel/component/jacksonxml/springboot/JacksonXMLDataFormatConfiguration.java+14 −0 modified@@ -101,6 +101,12 @@ public class JacksonXMLDataFormatConfiguration { * separated by comma */ private String disableFeatures; + /** + * If enabled then Jackson is allowed to attempt to use the + * CamelJacksonUnmarshalType header during the unmarshalling. This should + * only be enabled when desired to be used. + */ + private Boolean allowUnmarshallType = false; public String getXmlMapper() { return xmlMapper; @@ -205,4 +211,12 @@ public String getDisableFeatures() { public void setDisableFeatures(String disableFeatures) { this.disableFeatures = disableFeatures; } + + public Boolean getAllowUnmarshallType() { + return allowUnmarshallType; + } + + public void setAllowUnmarshallType(Boolean allowUnmarshallType) { + this.allowUnmarshallType = allowUnmarshallType; + } } \ No newline at end of file
5ae9c0dcc484CAMEL-10604 - Camel-JacksonXML: Add an option to allow the UnmarshallType header use
4 files changed · +90 −1
camel-core/src/main/java/org/apache/camel/model/dataformat/JacksonXMLDataFormat.java+18 −0 modified@@ -68,6 +68,8 @@ public class JacksonXMLDataFormat extends DataFormatDefinition { private String enableFeatures; @XmlAttribute private String disableFeatures; + @XmlAttribute + private Boolean allowUnmarshallType; public JacksonXMLDataFormat() { super("jacksonxml"); @@ -256,6 +258,19 @@ public String getDisableFeatures() { public void setDisableFeatures(String disableFeatures) { this.disableFeatures = disableFeatures; } + + public Boolean getAllowUnmarshallType() { + return allowUnmarshallType; + } + + /** + * If enabled then Jackson is allowed to attempt to use the CamelJacksonUnmarshalType header during the unmarshalling. + * <p/> + * This should only be enabled when desired to be used. + */ + public void setAllowUnmarshallType(Boolean allowUnmarshallType) { + this.allowUnmarshallType = allowUnmarshallType; + } @Override public String getDataFormatName() { @@ -326,6 +341,9 @@ protected void configureDataFormat(DataFormat dataFormat, CamelContext camelCont if (disableFeatures != null) { setProperty(camelContext, dataFormat, "disableFeatures", disableFeatures); } + if (allowUnmarshallType != null) { + setProperty(camelContext, dataFormat, "allowUnmarshallType", allowUnmarshallType); + } } }
components/camel-jacksonxml/src/main/java/org/apache/camel/component/jacksonxml/JacksonXMLDataFormat.java+18 −1 modified@@ -68,6 +68,7 @@ public class JacksonXMLDataFormat extends ServiceSupport implements DataFormat, private String enableFeatures; private String disableFeatures; private boolean enableJacksonTypeConverter; + private boolean allowUnmarshallType; /** * Use the default Jackson {@link XmlMapper} and {@link Map} @@ -158,7 +159,10 @@ public Object unmarshal(Exchange exchange, InputStream stream) throws Exception // is there a header with the unmarshal type? Class<?> clazz = unmarshalType; - String type = exchange.getIn().getHeader(JacksonXMLConstants.UNMARSHAL_TYPE, String.class); + String type = null; + if (allowUnmarshallType) { + type = exchange.getIn().getHeader(JacksonXMLConstants.UNMARSHAL_TYPE, String.class); + } if (type == null && isAllowJmsType()) { type = exchange.getIn().getHeader("JMSType", String.class); } @@ -326,6 +330,19 @@ public boolean isEnableJacksonTypeConverter() { public void setEnableJacksonTypeConverter(boolean enableJacksonTypeConverter) { this.enableJacksonTypeConverter = enableJacksonTypeConverter; } + + public boolean isAllowUnmarshallType() { + return allowUnmarshallType; + } + + /** + * If enabled then Jackson is allowed to attempt to use the CamelJacksonUnmarshalType header during the unmarshalling. + * <p/> + * This should only be enabled when desired to be used. + */ + public void setAllowUnmarshallType(boolean allowJacksonUnmarshallType) { + this.allowUnmarshallType = allowJacksonUnmarshallType; + } public String getEnableFeatures() { return enableFeatures;
components/camel-jacksonxml/src/test/java/org/apache/camel/component/jacksonxml/JacksonMarshalUnmarshalTypeHeaderNotAllowedTest.java+53 −0 added@@ -0,0 +1,53 @@ +/** + * 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.jacksonxml; + +import java.util.LinkedHashMap; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.Test; + +public class JacksonMarshalUnmarshalTypeHeaderNotAllowedTest extends CamelTestSupport { + + @Test + public void testUnmarshalPojo() throws Exception { + MockEndpoint mock = getMockEndpoint("mock:reversePojo"); + mock.expectedMessageCount(1); + + String json = "<pojo name=\"Camel\"/>"; + template.sendBodyAndHeader("direct:backPojo", json, JacksonXMLConstants.UNMARSHAL_TYPE, TestPojo.class.getName()); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + + @Override + public void configure() throws Exception { + JacksonXMLDataFormat format = new JacksonXMLDataFormat(); + + from("direct:backPojo").unmarshal(format).to("mock:reversePojo"); + + } + }; + } + +}
components/camel-jacksonxml/src/test/java/org/apache/camel/component/jacksonxml/JacksonMarshalUnmarshalTypeHeaderTest.java+1 −0 modified@@ -46,6 +46,7 @@ protected RouteBuilder createRouteBuilder() throws Exception { @Override public void configure() throws Exception { JacksonXMLDataFormat format = new JacksonXMLDataFormat(); + format.setAllowUnmarshallType(true); from("direct:backPojo").unmarshal(format).to("mock:reversePojo");
ccf149c76bf3CAMEL-10604 - Camel-JacksonXML: Add an option to allow the UnmarshallType header use
4 files changed · +90 −1
camel-core/src/main/java/org/apache/camel/model/dataformat/JacksonXMLDataFormat.java+18 −0 modified@@ -66,6 +66,8 @@ public class JacksonXMLDataFormat extends DataFormatDefinition { private String enableFeatures; @XmlAttribute private String disableFeatures; + @XmlAttribute + private Boolean allowUnmarshallType; public JacksonXMLDataFormat() { super("jacksonxml"); @@ -243,6 +245,19 @@ public String getDisableFeatures() { public void setDisableFeatures(String disableFeatures) { this.disableFeatures = disableFeatures; } + + public Boolean getAllowUnmarshallType() { + return allowUnmarshallType; + } + + /** + * If enabled then Jackson is allowed to attempt to use the CamelJacksonUnmarshalType header during the unmarshalling. + * <p/> + * This should only be enabled when desired to be used. + */ + public void setAllowUnmarshallType(Boolean allowUnmarshallType) { + this.allowUnmarshallType = allowUnmarshallType; + } @Override public String getDataFormatName() { @@ -308,6 +323,9 @@ protected void configureDataFormat(DataFormat dataFormat, CamelContext camelCont if (disableFeatures != null) { setProperty(camelContext, dataFormat, "disableFeatures", disableFeatures); } + if (allowUnmarshallType != null) { + setProperty(camelContext, dataFormat, "allowUnmarshallType", allowUnmarshallType); + } } }
components/camel-jacksonxml/src/main/java/org/apache/camel/component/jacksonxml/JacksonXMLDataFormat.java+18 −1 modified@@ -68,6 +68,7 @@ public class JacksonXMLDataFormat extends ServiceSupport implements DataFormat, private String enableFeatures; private String disableFeatures; private boolean enableJacksonTypeConverter; + private boolean allowUnmarshallType; /** * Use the default Jackson {@link XmlMapper} and {@link Map} @@ -159,7 +160,10 @@ public Object unmarshal(Exchange exchange, InputStream stream) throws Exception // is there a header with the unmarshal type? Class<?> clazz = unmarshalType; - String type = exchange.getIn().getHeader(JacksonXMLConstants.UNMARSHAL_TYPE, String.class); + String type = null; + if (allowUnmarshallType) { + type = exchange.getIn().getHeader(JacksonXMLConstants.UNMARSHAL_TYPE, String.class); + } if (type == null && isAllowJmsType()) { type = exchange.getIn().getHeader("JMSType", String.class); } @@ -323,6 +327,19 @@ public boolean isEnableJacksonTypeConverter() { public void setEnableJacksonTypeConverter(boolean enableJacksonTypeConverter) { this.enableJacksonTypeConverter = enableJacksonTypeConverter; } + + public boolean isAllowUnmarshallType() { + return allowUnmarshallType; + } + + /** + * If enabled then Jackson is allowed to attempt to use the CamelJacksonUnmarshalType header during the unmarshalling. + * <p/> + * This should only be enabled when desired to be used. + */ + public void setAllowUnmarshallType(boolean allowJacksonUnmarshallType) { + this.allowUnmarshallType = allowJacksonUnmarshallType; + } public String getEnableFeatures() { return enableFeatures;
components/camel-jacksonxml/src/test/java/org/apache/camel/component/jacksonxml/JacksonMarshalUnmarshalTypeHeaderNotAllowedTest.java+53 −0 added@@ -0,0 +1,53 @@ +/** + * 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.jacksonxml; + +import java.util.LinkedHashMap; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.Test; + +public class JacksonMarshalUnmarshalTypeHeaderNotAllowedTest extends CamelTestSupport { + + @Test + public void testUnmarshalPojo() throws Exception { + MockEndpoint mock = getMockEndpoint("mock:reversePojo"); + mock.expectedMessageCount(1); + + String json = "<pojo name=\"Camel\"/>"; + template.sendBodyAndHeader("direct:backPojo", json, JacksonXMLConstants.UNMARSHAL_TYPE, TestPojo.class.getName()); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + + @Override + public void configure() throws Exception { + JacksonXMLDataFormat format = new JacksonXMLDataFormat(); + + from("direct:backPojo").unmarshal(format).to("mock:reversePojo"); + + } + }; + } + +}
components/camel-jacksonxml/src/test/java/org/apache/camel/component/jacksonxml/JacksonMarshalUnmarshalTypeHeaderTest.java+1 −0 modified@@ -46,6 +46,7 @@ protected RouteBuilder createRouteBuilder() throws Exception { @Override public void configure() throws Exception { JacksonXMLDataFormat format = new JacksonXMLDataFormat(); + format.setAllowUnmarshallType(true); from("direct:backPojo").unmarshal(format).to("mock:reversePojo");
83fef7108456CAMEL-10567: Camel-Jackson: Add an option to allow the UnmarshallType header use
2 files changed · +7 −7
components/camel-jackson/src/main/java/org/apache/camel/component/jackson/JacksonDataFormat.java+6 −6 modified@@ -68,7 +68,7 @@ public class JacksonDataFormat extends ServiceSupport implements DataFormat, Dat private String enableFeatures; private String disableFeatures; private boolean enableJacksonTypeConverter; - private boolean allowJacksonUnmarshallType; + private boolean allowUnmarshallType; /** * Use the default Jackson {@link ObjectMapper} and {@link Object} @@ -160,7 +160,7 @@ public Object unmarshal(Exchange exchange, InputStream stream) throws Exception // is there a header with the unmarshal type? Class<?> clazz = unmarshalType; String type = null; - if (allowJacksonUnmarshallType) { + if (allowUnmarshallType) { type = exchange.getIn().getHeader(JacksonConstants.UNMARSHAL_TYPE, String.class); } if (type == null && isAllowJmsType()) { @@ -331,17 +331,17 @@ public void setEnableJacksonTypeConverter(boolean enableJacksonTypeConverter) { this.enableJacksonTypeConverter = enableJacksonTypeConverter; } - public boolean isAllowJacksonUnmarshallType() { - return allowJacksonUnmarshallType; + public boolean isAllowUnmarshallType() { + return allowUnmarshallType; } /** * If enabled then Jackson is allowed to attempt to use the CamelJacksonUnmarshalType header during the unmarshalling. * <p/> * This should only be enabled when desired to be used. */ - public void setAllowJacksonUnmarshallType(boolean allowJacksonUnmarshallType) { - this.allowJacksonUnmarshallType = allowJacksonUnmarshallType; + public void setAllowUnmarshallType(boolean allowJacksonUnmarshallType) { + this.allowUnmarshallType = allowJacksonUnmarshallType; } public String getEnableFeatures() {
components/camel-jackson/src/test/java/org/apache/camel/component/jackson/JacksonMarshalUnmarshalTypeHeaderTest.java+1 −1 modified@@ -46,7 +46,7 @@ protected RouteBuilder createRouteBuilder() throws Exception { @Override public void configure() throws Exception { JacksonDataFormat format = new JacksonDataFormat(); - format.setAllowJacksonUnmarshallType(true); + format.setAllowUnmarshallType(true); from("direct:backPojo").unmarshal(format).to("mock:reversePojo");
57d01e2fc892CAMEL-10567: Camel-Jackson: Add an option to allow the UnmarshallType header use
2 files changed · +7 −7
components/camel-jackson/src/main/java/org/apache/camel/component/jackson/JacksonDataFormat.java+6 −6 modified@@ -68,7 +68,7 @@ public class JacksonDataFormat extends ServiceSupport implements DataFormat, Dat private String enableFeatures; private String disableFeatures; private boolean enableJacksonTypeConverter; - private boolean allowJacksonUnmarshallType; + private boolean allowUnmarshallType; /** * Use the default Jackson {@link ObjectMapper} and {@link Map} @@ -161,7 +161,7 @@ public Object unmarshal(Exchange exchange, InputStream stream) throws Exception // is there a header with the unmarshal type? Class<?> clazz = unmarshalType; String type = null; - if (allowJacksonUnmarshallType) { + if (allowUnmarshallType) { type = exchange.getIn().getHeader(JacksonConstants.UNMARSHAL_TYPE, String.class); } if (type == null && isAllowJmsType()) { @@ -328,17 +328,17 @@ public void setEnableJacksonTypeConverter(boolean enableJacksonTypeConverter) { this.enableJacksonTypeConverter = enableJacksonTypeConverter; } - public boolean isAllowJacksonUnmarshallType() { - return allowJacksonUnmarshallType; + public boolean isAllowUnmarshallType() { + return allowUnmarshallType; } /** * If enabled then Jackson is allowed to attempt to use the CamelJacksonUnmarshalType header during the unmarshalling. * <p/> * This should only be enabled when desired to be used. */ - public void setAllowJacksonUnmarshallType(boolean allowJacksonUnmarshallType) { - this.allowJacksonUnmarshallType = allowJacksonUnmarshallType; + public void setAllowUnmarshallType(boolean allowJacksonUnmarshallType) { + this.allowUnmarshallType = allowJacksonUnmarshallType; } public String getEnableFeatures() {
components/camel-jackson/src/test/java/org/apache/camel/component/jackson/JacksonMarshalUnmarshalTypeHeaderTest.java+1 −1 modified@@ -46,7 +46,7 @@ protected RouteBuilder createRouteBuilder() throws Exception { @Override public void configure() throws Exception { JacksonDataFormat format = new JacksonDataFormat(); - format.setAllowJacksonUnmarshallType(true); + format.setAllowUnmarshallType(true); from("direct:backPojo").unmarshal(format).to("mock:reversePojo");
d4102512147eCAMEL-10567: Camel-Jackson: Add an option to allow the UnmarshallType header use
2 files changed · +7 −7
components/camel-jackson/src/main/java/org/apache/camel/component/jackson/JacksonDataFormat.java+6 −6 modified@@ -68,7 +68,7 @@ public class JacksonDataFormat extends ServiceSupport implements DataFormat, Dat private String enableFeatures; private String disableFeatures; private boolean enableJacksonTypeConverter; - private boolean allowJacksonUnmarshallType; + private boolean allowUnmarshallType; /** * Use the default Jackson {@link ObjectMapper} and {@link Map} @@ -160,7 +160,7 @@ public Object unmarshal(Exchange exchange, InputStream stream) throws Exception // is there a header with the unmarshal type? Class<?> clazz = unmarshalType; String type = null; - if (allowJacksonUnmarshallType) { + if (allowUnmarshallType) { type = exchange.getIn().getHeader(JacksonConstants.UNMARSHAL_TYPE, String.class); } if (type == null && isAllowJmsType()) { @@ -331,17 +331,17 @@ public void setEnableJacksonTypeConverter(boolean enableJacksonTypeConverter) { this.enableJacksonTypeConverter = enableJacksonTypeConverter; } - public boolean isAllowJacksonUnmarshallType() { - return allowJacksonUnmarshallType; + public boolean isAllowUnmarshallType() { + return allowUnmarshallType; } /** * If enabled then Jackson is allowed to attempt to use the CamelJacksonUnmarshalType header during the unmarshalling. * <p/> * This should only be enabled when desired to be used. */ - public void setAllowJacksonUnmarshallType(boolean allowJacksonUnmarshallType) { - this.allowJacksonUnmarshallType = allowJacksonUnmarshallType; + public void setAllowUnmarshallType(boolean allowJacksonUnmarshallType) { + this.allowUnmarshallType = allowJacksonUnmarshallType; } public String getEnableFeatures() {
components/camel-jackson/src/test/java/org/apache/camel/component/jackson/JacksonMarshalUnmarshalTypeHeaderTest.java+1 −1 modified@@ -46,7 +46,7 @@ protected RouteBuilder createRouteBuilder() throws Exception { @Override public void configure() throws Exception { JacksonDataFormat format = new JacksonDataFormat(); - format.setAllowJacksonUnmarshallType(true); + format.setAllowUnmarshallType(true); from("direct:backPojo").unmarshal(format).to("mock:reversePojo");
2b0e96117d6fCAMEL-10567: Camel-Jackson: Add an option to allow the UnmarshallType header use
2 files changed · +7 −7
components/camel-jackson/src/main/java/org/apache/camel/component/jackson/JacksonDataFormat.java+6 −6 modified@@ -68,7 +68,7 @@ public class JacksonDataFormat extends ServiceSupport implements DataFormat, Dat private String enableFeatures; private String disableFeatures; private boolean enableJacksonTypeConverter; - private boolean allowJacksonUnmarshallType; + private boolean allowUnmarshallType; /** * Use the default Jackson {@link ObjectMapper} and {@link Object} @@ -160,7 +160,7 @@ public Object unmarshal(Exchange exchange, InputStream stream) throws Exception // is there a header with the unmarshal type? Class<?> clazz = unmarshalType; String type = null; - if (allowJacksonUnmarshallType) { + if (allowUnmarshallType) { type = exchange.getIn().getHeader(JacksonConstants.UNMARSHAL_TYPE, String.class); } if (type == null && isAllowJmsType()) { @@ -331,17 +331,17 @@ public void setEnableJacksonTypeConverter(boolean enableJacksonTypeConverter) { this.enableJacksonTypeConverter = enableJacksonTypeConverter; } - public boolean isAllowJacksonUnmarshallType() { - return allowJacksonUnmarshallType; + public boolean isAllowUnmarshallType() { + return allowUnmarshallType; } /** * If enabled then Jackson is allowed to attempt to use the CamelJacksonUnmarshalType header during the unmarshalling. * <p/> * This should only be enabled when desired to be used. */ - public void setAllowJacksonUnmarshallType(boolean allowJacksonUnmarshallType) { - this.allowJacksonUnmarshallType = allowJacksonUnmarshallType; + public void setAllowUnmarshallType(boolean allowJacksonUnmarshallType) { + this.allowUnmarshallType = allowJacksonUnmarshallType; } public String getEnableFeatures() {
components/camel-jackson/src/test/java/org/apache/camel/component/jackson/JacksonMarshalUnmarshalTypeHeaderTest.java+1 −1 modified@@ -46,7 +46,7 @@ protected RouteBuilder createRouteBuilder() throws Exception { @Override public void configure() throws Exception { JacksonDataFormat format = new JacksonDataFormat(); - format.setAllowJacksonUnmarshallType(true); + format.setAllowUnmarshallType(true); from("direct:backPojo").unmarshal(format).to("mock:reversePojo");
10f552643d7eCAMEL-10567: Camel-Jackson: Add an option to allow the UnmarshallType header use
3 files changed · +73 −1
components/camel-jackson/src/main/java/org/apache/camel/component/jackson/JacksonDataFormat.java+18 −1 modified@@ -68,6 +68,7 @@ public class JacksonDataFormat extends ServiceSupport implements DataFormat, Dat private String enableFeatures; private String disableFeatures; private boolean enableJacksonTypeConverter; + private boolean allowJacksonUnmarshallType; /** * Use the default Jackson {@link ObjectMapper} and {@link Map} @@ -158,7 +159,10 @@ public Object unmarshal(Exchange exchange, InputStream stream) throws Exception // is there a header with the unmarshal type? Class<?> clazz = unmarshalType; - String type = exchange.getIn().getHeader(JacksonConstants.UNMARSHAL_TYPE, String.class); + String type = null; + if (allowJacksonUnmarshallType) { + type = exchange.getIn().getHeader(JacksonConstants.UNMARSHAL_TYPE, String.class); + } if (type == null && isAllowJmsType()) { type = exchange.getIn().getHeader("JMSType", String.class); } @@ -326,6 +330,19 @@ public boolean isEnableJacksonTypeConverter() { public void setEnableJacksonTypeConverter(boolean enableJacksonTypeConverter) { this.enableJacksonTypeConverter = enableJacksonTypeConverter; } + + public boolean isAllowJacksonUnmarshallType() { + return allowJacksonUnmarshallType; + } + + /** + * If enabled then Jackson is allowed to attempt to use the CamelJacksonUnmarshalType header during the unmarshalling. + * <p/> + * This should only be enabled when desired to be used. + */ + public void setAllowJacksonUnmarshallType(boolean allowJacksonUnmarshallType) { + this.allowJacksonUnmarshallType = allowJacksonUnmarshallType; + } public String getEnableFeatures() { return enableFeatures;
components/camel-jackson/src/test/java/org/apache/camel/component/jackson/JacksonMarshalUnmarshalTypeHeaderNotAllowedTest.java+54 −0 added@@ -0,0 +1,54 @@ +/** + * 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.jackson; + +import java.util.LinkedHashMap; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.Test; + +public class JacksonMarshalUnmarshalTypeHeaderNotAllowedTest extends CamelTestSupport { + + @Test + public void testUnmarshalPojo() throws Exception { + MockEndpoint mock = getMockEndpoint("mock:reversePojo"); + mock.expectedMessageCount(1); + mock.message(0).body().isInstanceOf(LinkedHashMap.class); + + String json = "{\"name\":\"Camel\"}"; + template.sendBodyAndHeader("direct:backPojo", json, JacksonConstants.UNMARSHAL_TYPE, TestPojo.class.getName()); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + + @Override + public void configure() throws Exception { + JacksonDataFormat format = new JacksonDataFormat(); + + from("direct:backPojo").unmarshal(format).to("mock:reversePojo"); + + } + }; + } + +}
components/camel-jackson/src/test/java/org/apache/camel/component/jackson/JacksonMarshalUnmarshalTypeHeaderTest.java+1 −0 modified@@ -46,6 +46,7 @@ protected RouteBuilder createRouteBuilder() throws Exception { @Override public void configure() throws Exception { JacksonDataFormat format = new JacksonDataFormat(); + format.setAllowJacksonUnmarshallType(true); from("direct:backPojo").unmarshal(format).to("mock:reversePojo");
7567488f844fCAMEL-10567: Camel-Jackson: Add an option to allow the UnmarshallType header use
3 files changed · +73 −1
components/camel-jackson/src/main/java/org/apache/camel/component/jackson/JacksonDataFormat.java+18 −1 modified@@ -68,6 +68,7 @@ public class JacksonDataFormat extends ServiceSupport implements DataFormat, Dat private String enableFeatures; private String disableFeatures; private boolean enableJacksonTypeConverter; + private boolean allowJacksonUnmarshallType; /** * Use the default Jackson {@link ObjectMapper} and {@link Object} @@ -158,7 +159,10 @@ public Object unmarshal(Exchange exchange, InputStream stream) throws Exception // is there a header with the unmarshal type? Class<?> clazz = unmarshalType; - String type = exchange.getIn().getHeader(JacksonConstants.UNMARSHAL_TYPE, String.class); + String type = null; + if (allowJacksonUnmarshallType) { + type = exchange.getIn().getHeader(JacksonConstants.UNMARSHAL_TYPE, String.class); + } if (type == null && isAllowJmsType()) { type = exchange.getIn().getHeader("JMSType", String.class); } @@ -326,6 +330,19 @@ public boolean isEnableJacksonTypeConverter() { public void setEnableJacksonTypeConverter(boolean enableJacksonTypeConverter) { this.enableJacksonTypeConverter = enableJacksonTypeConverter; } + + public boolean isAllowJacksonUnmarshallType() { + return allowJacksonUnmarshallType; + } + + /** + * If enabled then Jackson is allowed to attempt to use the CamelJacksonUnmarshalType header during the unmarshalling. + * <p/> + * This should only be enabled when desired to be used. + */ + public void setAllowJacksonUnmarshallType(boolean allowJacksonUnmarshallType) { + this.allowJacksonUnmarshallType = allowJacksonUnmarshallType; + } public String getEnableFeatures() { return enableFeatures;
components/camel-jackson/src/test/java/org/apache/camel/component/jackson/JacksonMarshalUnmarshalTypeHeaderNotAllowedTest.java+54 −0 added@@ -0,0 +1,54 @@ +/** + * 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.jackson; + +import java.util.LinkedHashMap; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.Test; + +public class JacksonMarshalUnmarshalTypeHeaderNotAllowedTest extends CamelTestSupport { + + @Test + public void testUnmarshalPojo() throws Exception { + MockEndpoint mock = getMockEndpoint("mock:reversePojo"); + mock.expectedMessageCount(1); + mock.message(0).body().isInstanceOf(LinkedHashMap.class); + + String json = "{\"name\":\"Camel\"}"; + template.sendBodyAndHeader("direct:backPojo", json, JacksonConstants.UNMARSHAL_TYPE, TestPojo.class.getName()); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + + @Override + public void configure() throws Exception { + JacksonDataFormat format = new JacksonDataFormat(); + + from("direct:backPojo").unmarshal(format).to("mock:reversePojo"); + + } + }; + } + +}
components/camel-jackson/src/test/java/org/apache/camel/component/jackson/JacksonMarshalUnmarshalTypeHeaderTest.java+1 −0 modified@@ -46,6 +46,7 @@ protected RouteBuilder createRouteBuilder() throws Exception { @Override public void configure() throws Exception { JacksonDataFormat format = new JacksonDataFormat(); + format.setAllowJacksonUnmarshallType(true); from("direct:backPojo").unmarshal(format).to("mock:reversePojo");
abb45b2c2adaCAMEL-10567: Camel-Jackson: Add an option to allow the UnmarshallType header use
3 files changed · +73 −1
components/camel-jackson/src/main/java/org/apache/camel/component/jackson/JacksonDataFormat.java+18 −1 modified@@ -68,6 +68,7 @@ public class JacksonDataFormat extends ServiceSupport implements DataFormat, Dat private String enableFeatures; private String disableFeatures; private boolean enableJacksonTypeConverter; + private boolean allowJacksonUnmarshallType; /** * Use the default Jackson {@link ObjectMapper} and {@link Object} @@ -158,7 +159,10 @@ public Object unmarshal(Exchange exchange, InputStream stream) throws Exception // is there a header with the unmarshal type? Class<?> clazz = unmarshalType; - String type = exchange.getIn().getHeader(JacksonConstants.UNMARSHAL_TYPE, String.class); + String type = null; + if (allowJacksonUnmarshallType) { + type = exchange.getIn().getHeader(JacksonConstants.UNMARSHAL_TYPE, String.class); + } if (type == null && isAllowJmsType()) { type = exchange.getIn().getHeader("JMSType", String.class); } @@ -326,6 +330,19 @@ public boolean isEnableJacksonTypeConverter() { public void setEnableJacksonTypeConverter(boolean enableJacksonTypeConverter) { this.enableJacksonTypeConverter = enableJacksonTypeConverter; } + + public boolean isAllowJacksonUnmarshallType() { + return allowJacksonUnmarshallType; + } + + /** + * If enabled then Jackson is allowed to attempt to use the CamelJacksonUnmarshalType header during the unmarshalling. + * <p/> + * This should only be enabled when desired to be used. + */ + public void setAllowJacksonUnmarshallType(boolean allowJacksonUnmarshallType) { + this.allowJacksonUnmarshallType = allowJacksonUnmarshallType; + } public String getEnableFeatures() { return enableFeatures;
components/camel-jackson/src/test/java/org/apache/camel/component/jackson/JacksonMarshalUnmarshalTypeHeaderNotAllowedTest.java+54 −0 added@@ -0,0 +1,54 @@ +/** + * 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.jackson; + +import java.util.LinkedHashMap; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.Test; + +public class JacksonMarshalUnmarshalTypeHeaderNotAllowedTest extends CamelTestSupport { + + @Test + public void testUnmarshalPojo() throws Exception { + MockEndpoint mock = getMockEndpoint("mock:reversePojo"); + mock.expectedMessageCount(1); + mock.message(0).body().isInstanceOf(LinkedHashMap.class); + + String json = "{\"name\":\"Camel\"}"; + template.sendBodyAndHeader("direct:backPojo", json, JacksonConstants.UNMARSHAL_TYPE, TestPojo.class.getName()); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + + @Override + public void configure() throws Exception { + JacksonDataFormat format = new JacksonDataFormat(); + + from("direct:backPojo").unmarshal(format).to("mock:reversePojo"); + + } + }; + } + +}
components/camel-jackson/src/test/java/org/apache/camel/component/jackson/JacksonMarshalUnmarshalTypeHeaderTest.java+1 −0 modified@@ -46,6 +46,7 @@ protected RouteBuilder createRouteBuilder() throws Exception { @Override public void configure() throws Exception { JacksonDataFormat format = new JacksonDataFormat(); + format.setAllowJacksonUnmarshallType(true); from("direct:backPojo").unmarshal(format).to("mock:reversePojo");
235036d2396aCAMEL-10567: Camel-Jackson: Add an option to allow the UnmarshallType header use
3 files changed · +73 −1
components/camel-jackson/src/main/java/org/apache/camel/component/jackson/JacksonDataFormat.java+18 −1 modified@@ -68,6 +68,7 @@ public class JacksonDataFormat extends ServiceSupport implements DataFormat, Dat private String enableFeatures; private String disableFeatures; private boolean enableJacksonTypeConverter; + private boolean allowJacksonUnmarshallType; /** * Use the default Jackson {@link ObjectMapper} and {@link Map} @@ -159,7 +160,10 @@ public Object unmarshal(Exchange exchange, InputStream stream) throws Exception // is there a header with the unmarshal type? Class<?> clazz = unmarshalType; - String type = exchange.getIn().getHeader(JacksonConstants.UNMARSHAL_TYPE, String.class); + String type = null; + if (allowJacksonUnmarshallType) { + type = exchange.getIn().getHeader(JacksonConstants.UNMARSHAL_TYPE, String.class); + } if (type == null && isAllowJmsType()) { type = exchange.getIn().getHeader("JMSType", String.class); } @@ -323,6 +327,19 @@ public boolean isEnableJacksonTypeConverter() { public void setEnableJacksonTypeConverter(boolean enableJacksonTypeConverter) { this.enableJacksonTypeConverter = enableJacksonTypeConverter; } + + public boolean isAllowJacksonUnmarshallType() { + return allowJacksonUnmarshallType; + } + + /** + * If enabled then Jackson is allowed to attempt to use the CamelJacksonUnmarshalType header during the unmarshalling. + * <p/> + * This should only be enabled when desired to be used. + */ + public void setAllowJacksonUnmarshallType(boolean allowJacksonUnmarshallType) { + this.allowJacksonUnmarshallType = allowJacksonUnmarshallType; + } public String getEnableFeatures() { return enableFeatures;
components/camel-jackson/src/test/java/org/apache/camel/component/jackson/JacksonMarshalUnmarshalTypeHeaderNotAllowedTest.java+54 −0 added@@ -0,0 +1,54 @@ +/** + * 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.jackson; + +import java.util.LinkedHashMap; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.Test; + +public class JacksonMarshalUnmarshalTypeHeaderNotAllowedTest extends CamelTestSupport { + + @Test + public void testUnmarshalPojo() throws Exception { + MockEndpoint mock = getMockEndpoint("mock:reversePojo"); + mock.expectedMessageCount(1); + mock.message(0).body().isInstanceOf(LinkedHashMap.class); + + String json = "{\"name\":\"Camel\"}"; + template.sendBodyAndHeader("direct:backPojo", json, JacksonConstants.UNMARSHAL_TYPE, TestPojo.class.getName()); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + + @Override + public void configure() throws Exception { + JacksonDataFormat format = new JacksonDataFormat(); + + from("direct:backPojo").unmarshal(format).to("mock:reversePojo"); + + } + }; + } + +}
components/camel-jackson/src/test/java/org/apache/camel/component/jackson/JacksonMarshalUnmarshalTypeHeaderTest.java+1 −0 modified@@ -46,6 +46,7 @@ protected RouteBuilder createRouteBuilder() throws Exception { @Override public void configure() throws Exception { JacksonDataFormat format = new JacksonDataFormat(); + format.setAllowJacksonUnmarshallType(true); from("direct:backPojo").unmarshal(format).to("mock:reversePojo");
Vulnerability mechanics
Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
25- www.github.com/mbechler/marshalsec/blob/master/marshalsec.pdfnvdExploitTechnical DescriptionThird Party AdvisoryWEB
- camel.apache.org/security-advisories.data/CVE-2016-8749.txt.ascnvdVendor AdvisoryWEB
- www.openwall.com/lists/oss-security/2017/05/22/2nvdMailing ListThird Party AdvisoryWEB
- www.securityfocus.com/bid/97179nvdThird Party AdvisoryVDB EntryWEB
- access.redhat.com/errata/RHSA-2017:1832nvdThird Party AdvisoryWEB
- github.com/advisories/GHSA-vvjc-q5vr-52q6ghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2016-8749ghsaADVISORY
- github.com/apache/camel/commit/10f552643d7e4565104d142bbc160db5a30f9f7eghsaWEB
- github.com/apache/camel/commit/235036d2396ae45b6809b72a1983dee33b5ba326ghsaWEB
- github.com/apache/camel/commit/2b0e96117d6f01eba0c18e2ff8df6a438e819721ghsaWEB
- github.com/apache/camel/commit/57d01e2fc8923263df896e9810329ee5b7f9b69eghsaWEB
- github.com/apache/camel/commit/5ae9c0dcc4843347cd01ffb58ce5dd0687755a14ghsaWEB
- github.com/apache/camel/commit/7567488f844f01d72840f7ab6ca18114a11f20d8ghsaWEB
- github.com/apache/camel/commit/83fef7108456eeac1506853d194cd1360851c4feghsaWEB
- github.com/apache/camel/commit/881e5099f94316d4a66ffbff0a3e6915829d49d7ghsaWEB
- github.com/apache/camel/commit/8c862aa11e31d0f804c4a4516a0715e05e3eebcfghsaWEB
- github.com/apache/camel/commit/abb45b2c2ada2bbb34138230540b37d259c1e98dghsaWEB
- github.com/apache/camel/commit/ccf149c76bf37adc5977dc626e141a14e60b5aeeghsaWEB
- github.com/apache/camel/commit/d4102512147eca2af21c3b6ed63a67d852f4e66aghsaWEB
- issues.apache.org/jira/browse/CAMEL-10567ghsaWEB
- issues.apache.org/jira/browse/CAMEL-10604ghsaWEB
- lists.apache.org/thread.html/2318d7f7d87724d8716cd650c21b31cb06e4d34f6d0f5ee42f28fdaf@%3Ccommits.camel.apache.org%3EghsaWEB
- lists.apache.org/thread.html/b4014ea7c5830ca1fc28edd5cafedfe93ad4af2d9e69c961c5def31d@%3Ccommits.camel.apache.org%3EghsaWEB
- lists.apache.org/thread.html/2318d7f7d87724d8716cd650c21b31cb06e4d34f6d0f5ee42f28fdaf%40%3Ccommits.camel.apache.org%3Envd
- lists.apache.org/thread.html/b4014ea7c5830ca1fc28edd5cafedfe93ad4af2d9e69c961c5def31d%40%3Ccommits.camel.apache.org%3Envd
News mentions
0No linked articles in our index yet.