private Element decryptElement(PrivateKey privKey, Element encryptedToken) throws Exception {
Element kiElem = null;
Element encrKeyElem = null;
EncryptedKeyProcessor encrKeyProcessor = null;
SecretKey secretKey = null;
XMLCipher cipher = null;
Document doc = null;
if (log.isDebugEnabled()) {
log.debug("decryptingToken");
}
kiElem = (Element) encryptedToken.getElementsByTagNameNS(WSConstants.SIG_NS, "KeyInfo")
.item(0);
encrKeyElem = (Element) kiElem.getElementsByTagNameNS(WSConstants.ENC_NS,
EncryptionConstants._TAG_ENCRYPTEDKEY).item(0);
encrKeyProcessor = new EncryptedKeyProcessor();
encrKeyProcessor.handleEncryptedKey(encrKeyElem, privKey);
secretKey = WSSecurityUtil.prepareSecretKey(EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES128,
encrKeyProcessor.getDecryptedBytes());
cipher = XMLCipher.getInstance();
cipher.init(XMLCipher.DECRYPT_MODE, secretKey);
doc = cipher.doFinal(encryptedToken.getOwnerDocument(), encryptedToken);