带有UsernameToken和SecurityContextToken的SOAP安全标头 - CXF

时间:2017-03-23 14:38:59

标签: java cxf ws-security wss4j

使用CXF并需要以下安全标头,包括UsernameToken(无密码)和SecurityContextToken:

        <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
        <wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="123">
            <wsse:Username>USER</wsse:Username>
        </wsse:UsernameToken>
        <wsc:SecurityContextToken xmlns:wsc="http://schemas.xmlsoap.org/ws/2005/02/sc">
            <wsc:Identifier>TOKEN</wsc:Identifier>
        </wsc:SecurityContextToken>
    </wsse:Security>

尝试使用操作WSHandlerConstants.USERNAME_TOKEN_NO_PASSWORD并将其放在WSS4JOutInterceptor中,但CXF抛出异常&#34;定义了未知操作:UsernameTokenNoPassword&#34;。

如何将这两个元素放入标题?

1 个答案:

答案 0 :(得分:1)

错误是由https://issues.apache.org/jira/browse/WSS-604引起的(我刚刚修复过)。