protected String encodeAndEncrypt(MethodCallMessage secureRequest, SecretKey sessionKey) throws Exception {
byte[] content = mapper.writeValueAsBytes(secureRequest);
LOGGER.info("encrypting: " + new String(content));
byte[] encryptedContent = CipherUtils.encrypt(content, sessionKey);
EncryptedMessage encryptedMessage = new EncryptedMessage();
encryptedMessage.setEncryptedContent(encryptedContent);
byte[] encryptedKey = CipherUtils.encrypt(sessionKey.getEncoded(), serverPublicKey);
encryptedMessage.setEncryptedKey(encryptedKey);
return mapper.writeValueAsString(encryptedMessage);
}