public class SignatureAction implements Action {
public void execute(WSHandler handler, int actionToDo, Document doc, RequestData reqData)
throws WSSecurityException {
CallbackHandler callbackHandler =
handler.getPasswordCallbackHandler(reqData);
WSPasswordCallback passwordCallback =
handler.getPasswordCB(reqData.getSignatureUser(), actionToDo, callbackHandler, reqData);
WSSecSignature wsSign = new WSSecSignature(reqData.getWssConfig());
if (reqData.getSigKeyId() != 0) {
wsSign.setKeyIdentifierType(reqData.getSigKeyId());
}
if (reqData.getSigAlgorithm() != null) {
wsSign.setSignatureAlgorithm(reqData.getSigAlgorithm());
}
if (reqData.getSigDigestAlgorithm() != null) {
wsSign.setDigestAlgo(reqData.getSigDigestAlgorithm());
}
wsSign.setUserInfo(reqData.getSignatureUser(), passwordCallback.getPassword());
wsSign.setUseSingleCertificate(reqData.isUseSingleCert());
if (reqData.getSignatureParts().size() > 0) {
wsSign.setParts(reqData.getSignatureParts());
}
if (passwordCallback.getKey() != null) {
wsSign.setSecretKey(passwordCallback.getKey());
}
try {
wsSign.prepare(doc, reqData.getSigCrypto(), reqData.getSecHeader());