如何使用 Wss4jSecurityInterceptor 将 SAML 断言添加到 Spring 中的 SOAP 安全性 header
How to add a SAML assertion to a SOAP security header in Spring using Wss4jSecurityInterceptor
我需要在 SOAP 安全 header 中将 SAML 断言作为令牌传递。我正在使用 Spring-WS 作为框架。
我要创建的 XML 如下所示:
我需要在 SOAP 安全性中将 SAML 断言作为令牌传递 header。
我要创建的 XML 如下所示。可以看出,XML 包含带有 wsse:Security
块的断言。
有没有办法用 Wss4jSecurityInterceptor
class 做到这一点?
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<Assertion MinorVersion="1" MajorVersion="1" Issuer="http://www.bea.com/saml"
IssueInstant="2005-11-10T11:27:36.233Z" AssertionID="HRMC-SM172.26.5.143.1106860829320"
xmlns="urn:oasis:names:tc:SAML:1.0:assertion">
<Conditions NotOnOrAfter="2005-11-10T15:27:36.233Z" NotBefore="2005-11-10T11:22:36.233Z"/>
<AuthenticationStatement AuthenticationMethod="urn:oasis:names:tc:SAML:1.0:am:unspecified"
AuthenticationInstant="2005-11-10T11:27:36.233Z">
<Subject>
<NameIdentifier Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">ANYAGENT
</NameIdentifier>
<SubjectConfirmation>
<ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:sender-vouches</ConfirmationMethod>
</SubjectConfirmation>
</Subject>
</AuthenticationStatement>
</Assertion>
</wsse:Security>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<m:DPSretrieve xmlns:m="https://tpvs.hmrc.gov.uk/dps">
<m:version>1</m:version>
<m:vendorID>your 4 digit vendorID</m:vendorID>
<m:service>PAYE</m:service>
<m:entityType>EmpRef</m:entityType>
<m:entity>as advised by SDS Team</m:entity>
<m:dataType>P6</m:dataType>
<m:got>0</m:got>
<m:nItems>0</m:nItems>
</m:DPSretrieve>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
我最终通过这个答案修复了它,效果很好:
我需要在 SOAP 安全 header 中将 SAML 断言作为令牌传递。我正在使用 Spring-WS 作为框架。
我要创建的 XML 如下所示:
我需要在 SOAP 安全性中将 SAML 断言作为令牌传递 header。
我要创建的 XML 如下所示。可以看出,XML 包含带有 wsse:Security
块的断言。
有没有办法用 Wss4jSecurityInterceptor
class 做到这一点?
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<Assertion MinorVersion="1" MajorVersion="1" Issuer="http://www.bea.com/saml"
IssueInstant="2005-11-10T11:27:36.233Z" AssertionID="HRMC-SM172.26.5.143.1106860829320"
xmlns="urn:oasis:names:tc:SAML:1.0:assertion">
<Conditions NotOnOrAfter="2005-11-10T15:27:36.233Z" NotBefore="2005-11-10T11:22:36.233Z"/>
<AuthenticationStatement AuthenticationMethod="urn:oasis:names:tc:SAML:1.0:am:unspecified"
AuthenticationInstant="2005-11-10T11:27:36.233Z">
<Subject>
<NameIdentifier Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">ANYAGENT
</NameIdentifier>
<SubjectConfirmation>
<ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:sender-vouches</ConfirmationMethod>
</SubjectConfirmation>
</Subject>
</AuthenticationStatement>
</Assertion>
</wsse:Security>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<m:DPSretrieve xmlns:m="https://tpvs.hmrc.gov.uk/dps">
<m:version>1</m:version>
<m:vendorID>your 4 digit vendorID</m:vendorID>
<m:service>PAYE</m:service>
<m:entityType>EmpRef</m:entityType>
<m:entity>as advised by SDS Team</m:entity>
<m:dataType>P6</m:dataType>
<m:got>0</m:got>
<m:nItems>0</m:nItems>
</m:DPSretrieve>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
我最终通过这个答案修复了它,效果很好: