使用CXF前端以编程方式为RESTful Web服务配置SSL?

时间:2013-01-13 08:48:09

标签: ssl cxf configure

我有一个关于使用javax.xml.ws.Provider以编程方式为CXF前端配置SSL的问题。

基本上我已经实现了一个简单的Restful webservice,比如

@WebServiceProvider()
@ServiceMode(value = Service.Mode.PAYLOAD)
public class RestWebServiceProvider implements Provider<DOMSource> {
    ...
}

并使用

等代码发布
public class RestServer {

    protected RestServer() throws Exception {
        System.out.println("Starting Server");
        Endpoint e = Endpoint.create(HTTPBinding.HTTP_BINDING, new RestWebServiceProvider() );
        String address = "http://localhost:9000/rest/test";
        e.publish(address);

    }

    public static void main(String args[]) throws Exception {
        new RestServer();
        System.out.println("Server ready...");

        Thread.sleep(5 * 60 * 1000);
        System.out.println("Server exiting");
        System.exit(0);
    }

}

与CXF download的samples文件夹中的restful_dispatch示例项目完全相同。

现在我想要实现的是以编程方式配置SSL,而不是使用XML。

为什么呢?因此,可以在运行时从浏览器配置SSL,而无需重新启动Web应用程序。

我做了一些功课,看到示例项目/ jax_rs / basic_https就是这样做的

 static {
    // set the configuration file
    SpringBusFactory factory = new SpringBusFactory();
    Bus bus = factory.createBus("ServerConfig.xml");
    BusFactory.setDefaultBus(bus);
}

在Server类中,ServerConfig.xml定义实际的SSL配置。但这对我的用例来说不够灵活。

我已经对stackoverflow进行了一些挖掘,我发现的最佳链接似乎来自javax.xml.ws.Endpoint with HTTPS

我自己没有尝试过这种方法,但是如果这是你的专家所做的或是否有更好的方法,那就是徘徊。

有没有人之前做过这样的事情并且想分享一些指示?

由于

萨姆

0 个答案:

没有答案
相关问题