*/
private EncryptedElementType encrypt(XMLObject xmlObject, QName encElementName) throws EncryptionException {
checkParams(encParams, kekParamsList);
EncryptedElementType encElement =
(EncryptedElementType) builderFactory.getBuilder(encElementName).buildObject(encElementName);
// Marshall the containing element, we will need its Document context to pass
// to the key encryption method
checkAndMarshall(encElement);
Document ownerDocument = encElement.getDOM().getOwnerDocument();
String encryptionAlgorithmURI = encParams.getAlgorithm();
Key encryptionKey = SecurityHelper.extractEncryptionKey(encParams.getEncryptionCredential());
if (encryptionKey == null) {
encryptionKey = generateEncryptionKey(encryptionAlgorithmURI);