//Encrypt
XMLCipher cipher = XMLCipher.getInstance(algorithms.get("aes-128").xmlSecName);
cipher.init(XMLCipher.ENCRYPT_MODE, secretKey);
//Encrypted Key
EncryptedKey ekey = XMLEncryptionUtil.encryptKey(document, secretKey, publicKey, keySize);
//Encrypted Data
String encryptionAlgorithm = XMLEncryptionUtil.getXMLEncryptionURL(secretKey.getAlgorithm(), keySize);
//Encrypt the Document
cipher = XMLCipher.getInstance(encryptionAlgorithm);
cipher.init(XMLCipher.ENCRYPT_MODE, secretKey);