cxf merlindevice配置

时间:2014-08-24 14:02:42

标签: java cxf

我需要通过智能卡签署Web服务肥皂消息正文和时间戳。

我使用的是cxf 2.7.12。在cxf丑陋的文档中,他们说" MerlinDevice:基于Merlin,允许使用null InputStream加载密钥库 - 例如在智能卡设备上#34;。但是没有提供示例或文档。

有没有人可以提供merlindevice的配置?

2 个答案:

答案 0 :(得分:1)

请参阅此处获取一些文档:http://ws.apache.org/wss4j/config.html

实际属性文件看起来几乎与用于“Merlin”的标准文件相同,只是提供者将被称为“MerlinDevice”:

https://git-wip-us.apache.org/repos/asf?p=cxf.git;a=blob_plain;f=systests/ws-security-examples/src/test/resources/alice.properties;hb=HEAD

科尔姆。

答案 1 :(得分:1)

以下是我解决问题的方法。

  1. 创建一个类,例如PKCS11Device扩展了Merlin
  2. 将MerlinDevice源复制到其中
  3. 复制Merlin加载方法
  4. 将第一行加载方法更改为

    public KeyStore load(InputStream input, String storepass, String provider, 
    String type) 
    throws CredentialException {
    
    KeyStore ks = null;
    
    SunPKCS11 akisProvider = new SunPKCS11("pkcs.properties");
    Security.addProvider(akisProvider);
    
    try {
        if (provider == null || provider.length() == 0) {
            ks = KeyStore.getInstance(type);
        } else {
            //ks = KeyStore.getInstance(type, provider);
            ks = KeyStore.getInstance("PKCS11",akisProvider);
        }
    

    ...............

  5. 重新包装wss4j.jar

  6. 将新jar替换为cxf lib文件夹中的旧jar。

    -----在你的项目中

  7. 创建特定于卡片的pkcs.properties
  8. 我是

    name = AKIS
    library = C:/windows/system32/akisp11.dll
    disabledMechanisms={ CKM_SHA1_RSA_PKCS }
    
    1. 将您的wss4j.properties文件设为

      org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.PKCS11Device      
      org.apache.ws.security.crypto.merlin.keystore.provider=SunPKCS11
      org.apache.ws.security.crypto.merlin.keystore.type=PKCS11
      org.apache.ws.security.crypto.merlin.keystore.password=xxxxx
      
    2. 它有效!