signature.setCanonicalizationAlgorithm(canonicalizationAlgorithm);
if (includeKeyInfoInSignature) {
logger.debug("Building KeyInfo");
KeyInfoGeneratorManager keyInfoGeneratorManager = Configuration.getGlobalSecurityConfiguration().getKeyInfoGeneratorManager().getDefaultManager();
KeyInfoGeneratorFactory keyInfoGeneratorFactory = keyInfoGeneratorManager.getFactory(credential);
KeyInfo keyInfo = null;
try {
keyInfo = keyInfoGeneratorFactory.newInstance().generate(credential);
} catch (SecurityException e) {
throw new RuntimeException(e);
}
signature.setKeyInfo(keyInfo);
}