gpt4 book ai didi

java - 如何通过 WSS4J 使用 Eclipse 生成的代理( Axis 1.4)对 SOAP 请求进行数字签名?

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:33:52 25 4
gpt4 key购买 nike

有人为我提供了网络服务的 WSDL。我现在需要对该请求进行数字签名。以前的开发人员利用 Eclipse 特性来生成代理类。将 WSDL 添加到项目中,然后右键单击它,单击“Web 服务”,然后单击“生成客户端”。

在我们被要求对请求进行数字签名之前,这一切都很好。我做了一些挖掘,看起来 Axis 1.4 不允许您签署请求。您可以使用 WSS4J 来做到这一点。我在 WSS4j 1.5 中加入了我的项目。

我不知道如何对请求进行数字签名。这是我现有的使用代理类的代码:

XiSecureWSServiceLocator service = new XiSecureWSServiceLocator();
service.setXiSecureWSServicePortEndpointAddress(paymetricPortAddress);
XiSecureWSPortType proxy = service.getXiSecureWSServicePort();
((Stub) proxy).setTimeout(paymetricTimeOutinMillisec);

SDecrypt_InputType sdi = new SDecrypt_InputType();
sdi.setStrToken(ccNumber);
sdi.setStrUserID(user);

SDecrypt_OutputType sdo = null;
sdo = proxy.pm_SingleDecrypt(sdi);

我想做的是类似 this article 的事情.这是他们使用的函数:

public Message signSOAPEnvelope(SOAPEnvelope
unsignedEnvelope) throws Exception
{
WSSignEnvelope signer = new WSSignEnvelope();
String alias = "16c73ab6-b892-458f-abf5-2f875f74882e";
String password = "security";
signer.setUserInfo(alias, password);
Document doc = unsignedEnvelope.getAsDocument();
Document signedDoc = signer.build(doc, crypto);
// Convert the signed document into a SOAP message.
Message signedSOAPMsg =
(org.apache.axis.Message)AxisUtil.toSOAPMessage(signedDoc);
return signedSOAPMsg;
}

当创建 Soap Envelope 的所有代码都隐藏在生成的代理类中时,我如何才能对 Soap Envelope 进行签名?

最佳答案

This JavaRanch Thread解释了使用 Axis 处理程序通过 WSS4J 实现安全和加密。

看起来你必须做一些事情:

  1. 配置/写一个wsdd
  2. 使用指向您的 wsdd 文件的 EngineConfiguration 调用 Web 服务
  3. 写一个密码回调类
  4. 编写一个 crypto.properties 文件
  5. 确保 crypto.properties 文件和包含证书的 keystore 位于应用程序的类路径中。

支持 JavaRanch 论坛上的 John Farrel 解决所有这些问题。

总而言之,有点痛苦。如果有一种方法可以从 Axis 代理类获取底层 SOAP 消息本身,那可能是一种更快的方法,但我对 Axis 1 没有太多经验。

顺便问一下,来自/r/java 的你好!

关于java - 如何通过 WSS4J 使用 Eclipse 生成的代理( Axis 1.4)对 SOAP 请求进行数字签名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10504686/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com