* SecurityTokenReference.getTokenElement to fail.
*/
@org.junit.Test
public void testAssertionBelowSTR() throws Exception {
Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
WSSecHeader secHeader = new WSSecHeader();
secHeader.insertSecurityHeader(doc);
SAMLIssuer saml = SAMLIssuerFactory.getInstance("saml_sv.properties");
AssertionWrapper assertion = saml.newAssertion();
Crypto crypto = CryptoFactory.getInstance("crypto.properties");
WSSecSignatureSAML wsSign = new WSSecSignatureSAML();
wsSign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
Document samlDoc =
wsSign.build(doc, null, assertion, crypto,
"16c73ab6-b892-458f-abf5-2f875f74882e", "security", secHeader
);
WSSecEncrypt builder = new WSSecEncrypt();
builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e");
builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
Document encryptedDoc = builder.build(samlDoc, crypto, secHeader);
//
// Remove the assertion its place in the security header and then append it
//
org.w3c.dom.Element secHeaderElement = secHeader.getSecurityHeader();
org.w3c.dom.Node assertionNode =
secHeaderElement.getElementsByTagNameNS(WSConstants.SAML_NS, "Assertion").item(0);
secHeaderElement.removeChild(assertionNode);
secHeaderElement.appendChild(assertionNode);