使用带有密钥库的 WebServiceTemplate [英] Using WebServiceTemplate with a keystore

查看:73
本文介绍了使用带有密钥库的 WebServiceTemplate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用 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:

http://java.sun.com/j2se/1.5.0/docs/api/java/security/KeyStore.Builder.html#newInstance%28java.lang.String,%20java.security.Provider,%20java.io.File,%20java.security.KeyStore.ProtectionParameter%29

因此,可能有一个具有 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆