if (alsoIncludeToken) {
CryptoType cryptoType = new CryptoType(CryptoType.TYPE.ALIAS);
cryptoType.setAlias(user);
X509Certificate[] certs = crypto.getX509Certificates(cryptoType);
BinarySecurity bstToken = null;
if (!sig.isUseSingleCertificate()) {
bstToken = new PKIPathSecurity(saaj.getSOAPPart());
((PKIPathSecurity) bstToken).setX509Certificates(certs, crypto);
} else {
bstToken = new X509Security(saaj.getSOAPPart());
((X509Security) bstToken).setX509Certificate(certs[0]);
}
bstToken.setID(wssConfig.getIdAllocator().createSecureId("X509-", certs[0]));
WSSecurityUtil.prependChildElement(
secHeader.getSecurityHeader(), bstToken.getElement()
);
bstElement = bstToken.getElement();
}
return sig;
}