使用带有密钥库的 WebServiceTemplate [英] Using WebServiceTemplate with a keystore
问题描述
是否可以使用 Java 密钥库配置 WebServiceTemplate?
Is it possible to configure a WebServiceTemplate with a java keystore?
编辑
我正在寻找一种在 spring 配置中配置密钥库位置的方法
edit
I'm looking for a way to configure the location of the keystore in the spring config
推荐答案
我认为您可以使用 KeyStore.Builder 以编程方式加载基于密钥库:
I think you can programatically load a keystore based using a KeyStore.Builder:
因此,可能有一个具有 webservice 模板或扩展它的类,然后在您的 spring 配置中设置密钥库的文件路径,并使其成为一个初始化 bean(Spring 3 中的 @PostConstruct?),然后加载密钥库.
So maybe have a class that has a webservice template or extends it, then set the file path of the keystore on it in your spring config and make it an inizialing bean (@PostConstruct in Spring 3?) which then loads the keystore.
File f = new File(keyStorePath);
KeyStore.Builder builder = KeyStore.Builder.newInstance("type",provider,file,protection);
KeyStore keystore = builder.getKeyStore();
好的 - 要实际将它与您的 webservicetemplate 一起使用,我认为它必须基于此处记录的密钥库回调:http://static.springsource.org/spring-ws/sites/1.5/reference/html/security.html#d0e4462
Ok - to actually use it with your webservicetemplate i think it must be based around the keystore callback as documented here: http://static.springsource.org/spring-ws/sites/1.5/reference/html/security.html#d0e4462
或者也许通过使用 spring org.springframework.ws.transport.http.HttpsUrlConnectionMessageSender,您可以在其上设置 keystoremanager.然后它可以被你的 webservicetemplate 使用.
Or maybe by using the spring org.springframework.ws.transport.http.HttpsUrlConnectionMessageSender which you can set keystoremanager on. Then that can be used by your webservicetemplate.
有点像这样:
<bean id="template" class="org.springframework.ws.client.core.WebServiceTemplate">
<property name="messageSender">
<bean class="org.springframework.ws.transport.http.HttpsUrlConnectionMessageSender">
<property name=""></property>
</bean>
</property>
</bean>
HTH
这篇关于使用带有密钥库的 WebServiceTemplate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!