async Task ProcessRequest(HttpRequestMessage request) { if (request.Content == null) { return; } string jsonContentRequest = await request.Content.ReadAsStringAsync(); if (string.IsNullOrWhiteSpace(jsonContentRequest)) { return; } string encryptedMessage = _secureMessageHelper.EncryptJson(jsonContentRequest); IEncrypteableEntity encryptedEntity = new EntidadEncrypted { messageEncrypted = encryptedMessage }; string serializedObject = JsonConvert.SerializeObject(encryptedEntity, JsonSerializerOptionsConfiguration.ReturnJsonSerializerSettings()); request.Content = new StringContent(serializedObject, Encoding.UTF8, "application/json"); }
async Task ProcessResponse(HttpResponseMessage response) { if (!response.IsSuccessStatusCode || response.Content == null) { return; } string jsonContentResponse = await response.Content.ReadAsStringAsync(); if (string.IsNullOrWhiteSpace(jsonContentResponse)) { return; } IEncrypteableEntity entityEncrypted = await Task.Run(() => JsonConvert.DeserializeObject <EntidadEncrypted>(jsonContentResponse, JsonSerializerOptionsConfiguration.ReturnJsonSerializerSettings())); string decryptMessage = _secureMessageHelper.DecryptJson(entityEncrypted.messageEncrypted); response.Content = new StringContent(decryptMessage, Encoding.UTF8, "application/json"); }