if (bstElem != null) {
addTopDownElement(bstElem);
}
encrKey.appendToHeader(secHeader);
WSSecDKSign dkSig = new WSSecDKSign(wssConfig);
dkSig.setSigCanonicalization(binding.getAlgorithmSuite().getInclusiveC14n());
dkSig.setSignatureAlgorithm(binding.getAlgorithmSuite().getSymmetricSignature());
dkSig.setDerivedKeyLength(binding.getAlgorithmSuite().getSignatureDerivedKeyLength() / 8);
dkSig.setExternalKey(encrKey.getEphemeralKey(), encrKey.getId());
dkSig.prepare(doc, secHeader);
/*
if(binding.isTokenProtection()) {
sigParts.add(new WSEncryptionPart(encrKey.getBSTTokenId()));
}
*/
dkSig.setParts(sigParts);
List<Reference> referenceList = dkSig.addReferencesToSign(sigParts, secHeader);
//Do signature
dkSig.appendDKElementToHeader(secHeader);
dkSig.computeSignature(referenceList, false, null);
return dkSig.getSignatureValue();
} else {
WSSecSignature sig = getSignatureBuilder(wrapper, token, false);
if (sig != null) {
sig.prependBSTElementToHeader(secHeader);