EncryptedData encryptedData = encryptElement(xmlObject, encryptionKey, encryptionAlgorithmURI,
encryptContentMode);
Document ownerDocument = encryptedData.getDOM().getOwnerDocument();
if (encParams.getKeyInfoGenerator() != null) {
KeyInfoGenerator generator = encParams.getKeyInfoGenerator();
log.debug("Dynamically generating KeyInfo from Credential for EncryptedData using generator: {}",
generator.getClass().getName());
try {
encryptedData.setKeyInfo(generator.generate(encParams.getEncryptionCredential()));
} catch (SecurityException e) {
log.error("Error during EncryptedData KeyInfo generation", e);
throw new EncryptionException("Error during EncryptedData KeyInfo generation", e);
}
}