VYPR
Critical severity9.8NVD Advisory· Published Mar 28, 2017· Updated May 13, 2026

CVE-2016-8749

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.

PackageAffected versionsPatched versions
org.apache.camel:camel-jacksonMaven
< 2.16.52.16.5
org.apache.camel:camel-jacksonMaven
>= 2.17.0, < 2.17.52.17.5
org.apache.camel:camel-jacksonMaven
>= 2.18.0, < 2.18.22.18.2

Affected products

1
  • Apache Software Foundation/Apache Camelv5
    Range: 2.16.0 to 2.16.4

Patches

12
8c862aa11e31

CAMEL-10604 - Camel-JacksonXML: Add an option to allow the UnmarshallType header use

https://github.com/apache/camelAndrea CosentinoDec 15, 2016via ghsa
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
    
881e5099f943

CAMEL-10604 - Camel-JacksonXML: Add an option to allow the UnmarshallType header use

https://github.com/apache/camelAndrea CosentinoDec 15, 2016via ghsa
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
    
5ae9c0dcc484

CAMEL-10604 - Camel-JacksonXML: Add an option to allow the UnmarshallType header use

https://github.com/apache/camelAndrea CosentinoDec 15, 2016via ghsa
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");
     
    
ccf149c76bf3

CAMEL-10604 - Camel-JacksonXML: Add an option to allow the UnmarshallType header use

https://github.com/apache/camelAndrea CosentinoDec 15, 2016via ghsa
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");
     
    
83fef7108456

CAMEL-10567: Camel-Jackson: Add an option to allow the UnmarshallType header use

https://github.com/apache/camelAndrea CosentinoDec 8, 2016via ghsa
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");
     
    
57d01e2fc892

CAMEL-10567: Camel-Jackson: Add an option to allow the UnmarshallType header use

https://github.com/apache/camelAndrea CosentinoDec 8, 2016via ghsa
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");
     
    
d4102512147e

CAMEL-10567: Camel-Jackson: Add an option to allow the UnmarshallType header use

https://github.com/apache/camelAndrea CosentinoDec 8, 2016via ghsa
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");
     
    
2b0e96117d6f

CAMEL-10567: Camel-Jackson: Add an option to allow the UnmarshallType header use

https://github.com/apache/camelAndrea CosentinoDec 8, 2016via ghsa
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");
     
    
10f552643d7e

CAMEL-10567: Camel-Jackson: Add an option to allow the UnmarshallType header use

https://github.com/apache/camelAndrea CosentinoDec 7, 2016via ghsa
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");
     
    
7567488f844f

CAMEL-10567: Camel-Jackson: Add an option to allow the UnmarshallType header use

https://github.com/apache/camelAndrea CosentinoDec 7, 2016via ghsa
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");
     
    
abb45b2c2ada

CAMEL-10567: Camel-Jackson: Add an option to allow the UnmarshallType header use

https://github.com/apache/camelAndrea CosentinoDec 7, 2016via ghsa
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");
     
    
235036d2396a

CAMEL-10567: Camel-Jackson: Add an option to allow the UnmarshallType header use

https://github.com/apache/camelAndrea CosentinoDec 7, 2016via ghsa
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

News mentions

0

No linked articles in our index yet.