public async Task WriteDecrypted(Task <Stream> encryptedZipStream, string outPath) { using (var fileStream = new FileStream(outPath, FileMode.OpenOrCreate)) { try { await _decryptionService.Decrypt(await encryptedZipStream.ConfigureAwait(false)) .CopyToAsync(fileStream).ConfigureAwait(false); await fileStream.FlushAsync().ConfigureAwait(false); } catch (Exception ex) { throw new FiksIODecryptionException("Unable to decrypt melding. Is your private key correct?", ex); } } }
public async Task <ZipFileContent> SaveFile(byte[] fileContet) { try { string decryptedContent = await Task.Run(() => _decryptionService.Decrypt(fileContet)); ZipFileContent file = await Task.Run(() => _zipRepository.Add(new Models.ZipFileContent { FileContent = decryptedContent, CreatedDate = DateTime.Now })); return(file); } catch (Exception) { return(null); } }
public MediatorResponse <ApprenticeshipApplicationViewModel> View(string applicationCipherText) { applicationCipherText = HttpUtility.UrlDecode(applicationCipherText); applicationCipherText = applicationCipherText?.Replace(' ', '+'); var anomymisedApplicationLink = _decryptionService.Decrypt(applicationCipherText); var applicationSelectionViewModel = new ApplicationSelectionViewModel { ApplicationId = anomymisedApplicationLink.ApplicationId }; var viewModel = _applicationProvider.GetApprenticeshipApplicationViewModel(applicationSelectionViewModel); if (_dateTimeService.UtcNow > anomymisedApplicationLink.ExpirationDateTime) { return(GetMediatorResponse(ApprenticeshipApplicationMediatorCodes.View.LinkExpired, viewModel)); } return(GetMediatorResponse(ApprenticeshipApplicationMediatorCodes.View.Ok, viewModel)); }