Camel HTTPS Jetty配置

时间:2016-04-20 15:08:05

标签: java rest ssl https apache-camel

我正在尝试使用SSL创建Jetty配置。这是我的配置:

@Bean(name = "jetty")
    public JettyHttpComponent jetty(CamelContext camelContext){
        JettyHttpComponent jettyComponent = camelContext.getComponent("jetty", JettyHttpComponent.class);
        jettyComponent.setSslContextParameters(sslContextParameters());
        return jettyComponent;
    }

  @Bean(name = "sslContextParameters")
    public SSLContextParameters sslContextParameters(){
        KeyStoreParameters ksp = new KeyStoreParameters();
        ksp.setResource(KEYSTORE);
        ksp.setPassword(KEYSTORE_PASSWORD);

        KeyManagersParameters kmp = new KeyManagersParameters();
        kmp.setKeyPassword(KEYSTORE_PASSWORD);
        kmp.setKeyStore(ksp);

        TrustManagersParameters tmp = new TrustManagersParameters();
        tmp.setKeyStore(ksp);

        SSLContextParameters sslContextParameters = new SSLContextParameters();
        sslContextParameters.setKeyManagers(kmp);
        sslContextParameters.setTrustManagers(tmp);

        return sslContextParameters;
    }

如果我加载此配置,我会得到例外说明:

Caused by: java.lang.ClassCastException: org.apache.camel.util.spring.SSLContextParametersFactoryBean$$EnhancerBySpringCGLIB$$57d06d22 cannot be cast to org.apache.camel.util.jsse.SSLContextParameters
at com.xxx.config.DevConfiguration$$EnhancerBySpringCGLIB$$1bb53ad4.sslContextParameters(<generated>)
at com.xxx.config.DevConfiguration.jetty(DevConfiguration.java:45)
at com.xxx.config.DevConfiguration$$EnhancerBySpringCGLIB$$1bb53ad4.CGLIB$jetty$0(<generated>)
at com.xxx.config.DevConfiguration$$EnhancerBySpringCGLIB$$1bb53ad4$$FastClassBySpringCGLIB$$a8257ab2.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:355)
at com.xxxx.config.DevConfiguration$$EnhancerBySpringCGLIB$$1bb53ad4.jetty(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
... 62 more

这看起来像是一个bug,因为类JettyHttpComponent有一个setter setSslContextParameters(SSLContextParameters sslContextParameters)参数的类型为org.apache.camel.util.jsse.SSLContextParameters,当我们打包并运行它时,它需要一个{{1}类型的参数}

如果你能指出我某个方向,请告诉我。

0 个答案:

没有答案