微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Ws Spring boot:在安全标头中添加 saml 断言

如何解决Ws Spring boot:在安全标头中添加 saml 断言

这是我的代码

@requiredArgsConstructor
public class IncidenciesSAMLHeaderRequestCallback implements WebServiceMessageCallback {

    private final SAMLTicketProvider samlTicketProvider;
    private final VisorApiProperties visorApiProperties;

    @Override
    public void doWithMessage(WebServiceMessage message) throws IOException,TransformerException {
        String samlAssertion = this.samlTicketProvider.getToken();

        SoapMessage soapMessage = (SoapMessage)message;
        SoapHeader header = soapMessage.getSoapHeader();
        StringSource headerSource = new StringSource(samlAssertion);

        Transformer transformer = TransformerFactory.newInstance().newTransformer();
        transformer.transform(headerSource,header.getResult());
    }

我期待我的 saml 断言包含在标题中。它正在生成

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
  <SOAP-ENV:Header>
    <saml2:Assertion xmlns:saml2="...">...</saml2:Assertion>
  </SOAP-ENV:Header>
<SOAP-ENV:Envelope>

我需要将我的 saml 断言插入到 <wsse:Security>...</wsse:Security> 中。

我的意思是,我需要:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
  <SOAP-ENV:Header>
    <wsse:Security xmlns:wsse="...">
      <saml2:Assertion xmlns:saml2="...">...</saml2:Assertion>
    </wsse:Security>
  </SOAP-ENV:Header>
<SOAP-ENV:Envelope>

有什么想法吗?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。