我基于 Wss4jSecurityInterceptor 的 Spring 实现开发了一个 ws(soap)。
配置如下:
... securementActions=时间戳签名加密 ... securementSignatureParts={Element}{...schemas.xmlsoap.org/soap/envelope/}Body;{Element}...www.w3.org/2005/08/addressing}To;{Element}{...www .w3.org/2005/08/addressing}Action;{Element}{...www.w3.org/2005/08/addressing}MessageID;{Element}{...www.w3.org/2005/08 /addressing}RelatesTo;{Element}{...docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd}时间戳
当我在时钟设置为比服务器时钟晚 2 分钟(或更多)时从客户端调用 ws 时,我收到以下消息:
org.apache.ws.security.WSSecurityException: The message has expired (WSSecurityEngine: Invalid timestamp The security semantics of the message has expired)
我使用 SoapUI 来测试 ws。在我得到正文块的响应中,无法在客户端解密。
时钟同步时的响应
<SOAP-ENV:信封 xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" > <SOAP-ENV:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"> ... </SOAP-ENV:Header> <SOAP-ENV:Body wsu:Id="id-148" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0。 xsd"> <SOAP-ENV:故障> <faultcode>SOAP-ENV:Server</faultcode> <faultstring xml:lang="en">错误标签</faultstring> <详细> <submissionFault xmlns="xxxxxx"> <错误 xmlns="xxxxxxx"> <errorCode>这里是错误码</errorCode> <errorDescription>此处的错误描述</errorDescription> <errorDetail>此处有错误详情</errorDetail> </错误> </submissionFault> </详细> </SOAP-ENV:Fault> </SOAP-ENV:Body> </SOAP-ENV:信封>
两个时钟不同步时的响应
<SOAP-ENV:信封 xmlns:SOAP-ENV="..." xmlns:xenc="...#"> <SOAP-ENV:Header xmlns:wsa="..."> ... </SOAP-ENV:Header> <SOAP-ENV:Body wsu:Id="id-157" xmlns:wsu="..."> <xenc:EncryptedData Id="EncDataId-162" Type="..."> <xenc:EncryptionMethod Algorithm="...#aes256-cbc"/> <ds:KeyInfo xmlns:ds="...#"> <wsse:SecurityTokenReference xmlns:wsse="..."> <wsse:Reference URI="#EncKeyId-xxxxxxxxxxxxxhhhhhyyyy"/> </wsse:SecurityTokenReference> </ds:KeyInfo> <xenc:密码数据> <xenc:CipherValue>PMam8TSjmX9gHDE7+/fekt575W+qWFC2xcMAXzAlTPfxoQ3ctBG9bUPUAsnMNQm41G9ya0EZaQtV zRL59IFW0wrowbJXhUHXvW0YPkAbIUSnnmWreQpHwy5oKA5DQWJ+nZTnyMdXq8ukxDPCP5ALlvGD wv685Fs14YmWupzXVBGufcu4XSGFI ... XhUkjHrOlrBL4PHiZ9imt nWLswfcay6friGSfkN2Z0U5oJ3XW034sVCONFBdZVNwia51nNmGTGwsMXJFxXLXCxv/lVP1p3tMq StorR11Otn8d/gcc06q+jBJDu5KXTgI5V6fHyW17jvV924AorYA44BiZ6ym5u4dti8fvCSFfj8shg /4DhGS16ATWFFfZ+QzTxaGEik1+d/+AbMc031wrO60hm7dIMasOegqD0BKUkEgkBbk0totU4TI55 C3BHPmv44QPGpoOSmkGAjYYzfbv9GE6HeaUBVXviJqaA1q0BiIklINMmnry9KU53mi59swqBNKz pF6cNDjKFGDNeRW9JLGNJq8dsnqK8nn7zE/sE2PxFGwJ+3qk40TuE6mjhA==</xenc:CipherValue> </xenc:密码数据> </xenc:加密数据> </SOAP-ENV:Body> </SOAP-ENV:信封>
任何想法?
谢谢