public async Task <IActionResult> Edit(Guid?id) { if (id == null) { return(NotFound()); } var authorization = await _context.Authorization.Include(m => m.GbvCase).AsNoTracking() .SingleOrDefaultAsync(m => m.GbvCase.GbvCaseId == id && m.GbvCase.UserName.Equals(User.Identity.Name)); if (authorization == null) { return(NotFound()); } var sub = _context.AuthorizationSub.SingleOrDefault(m => m.AuthorizationId == authorization.AuthorizationId); if (sub != null) { authorization.AgencyTypeId = sub.AgencyTypeId; authorization.AgencyName = sub.AgencyName; authorization.Comment = sub.Comment; ViewData["agency"] = new SelectList(_context.AgencyType.ToList(), "AgencyTypeId", "AgencyType1", sub.AgencyTypeId.GetValueOrDefault()); } else { ViewData["agency"] = new SelectList(_context.AgencyType.ToList(), "AgencyTypeId", "AgencyType1"); } authorization.GbvCase.PatientName = _crypto.Decrypt(authorization.GbvCase.PatientName); authorization.GbvCase.PatientFatherName = _crypto.Decrypt(authorization.GbvCase.PatientFatherName); ViewBag.details = authorization.GbvCase; return(View(authorization)); }
public ActionResult <User> Validate(string id) { var sId = _cipherService.Decrypt(id); if (string.IsNullOrEmpty(sId) || !int.TryParse(sId, out int userId)) { return(BadRequest(new { message = "Invalid validation id" })); } var user = unitOfWork.UserRepository.GetByID(userId); if (user == null) { return(BadRequest(new { message = "User not found" })); } //login user user.Sessions = new List <UserSession>(); user.token = GenerateToken(user); user.validated = true; user.Sessions.Add(new UserSession { date = DateTime.Now, token = user.token, user_id = user.id, ip = _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.ToString() }); unitOfWork.Save(); user.password = null; return(user); }
public Task <Process> Launch(LaunchOptions options) { _logger.LogInformation($"Launching app: '{options.FilePath}' using credentials for: '{options.Domain}'"); StartUpInfo startupInfo = new StartUpInfo(); startupInfo.cb = Marshal.SizeOf(startupInfo); startupInfo.lpTitle = null; startupInfo.dwFlags = (int)StartUpInfoFlags.UseCountChars; startupInfo.dwYCountChars = 50; var workingDirectory = !string.IsNullOrWhiteSpace(options.WorkingDirectory) ? options.WorkingDirectory : Path.GetDirectoryName(options.FilePath); var password = _cipherService.Decrypt(options.Password); var process = RunAs.StartProcess( userName: options.UserName, domain: options.Domain, password: password, logonFlags: RunAs.LogonFlags.NetworkCredentialsOnly, applicationName: null, commandLine: options.FilePath, creationFlags: RunAs.CreationFlags.NewConsole, environment: IntPtr.Zero, currentDirectory: workingDirectory, startupInfo: ref startupInfo, processInfo: out _ ); return(Task.FromResult(process)); }
/// <summary> /// Retrieves decrypted PushBullet settings by UserId /// </summary> /// <param name="userId">ApplicationUser UserId</param> /// <returns></returns> /// <exception cref="System.NullReferenceException">User must be associated with the PushBullet service.</exception> public async Task <PushBulletSettings> RetrieveDecryptedPushBulletSettingsByUserId(string userId) { var pushBulletService = await GetPushBulletServiceByUserId(userId); if (pushBulletService == null) { throw new NullReferenceException($"There is no PushBullet service associated with {userId}"); } var pushBulletSettings = JsonConvert.DeserializeObject <PushBulletSettings>(pushBulletService.ApplicationSettings); pushBulletSettings.ApiKey = _cipherService.Decrypt(pushBulletSettings.ApiKey); pushBulletSettings.EncryptionKey = _cipherService.Decrypt(pushBulletSettings.EncryptionKey); return(pushBulletSettings); }
// GET: intake/Edit/5 public async Task <IActionResult> Edit(Guid?id) { if (id == null) { return(NotFound()); } var intakeInfo = await _context.IntakeInfo.Include(m => m.GbvCase).SingleOrDefaultAsync(m => m.GbvCaseId == id && m.GbvCase.UserName.Equals(User.Identity.Name)); if (intakeInfo == null) { return(NotFound()); } intakeInfo.GbvCase.PatientName = _crypto.Decrypt(intakeInfo.GbvCase.PatientName); intakeInfo.GbvCase.PatientFatherName = _crypto.Decrypt(intakeInfo.GbvCase.PatientFatherName); ViewBag.details = intakeInfo.GbvCase; return(View(intakeInfo)); }
public async Task <IActionResult> Edit(Guid?id) { if (id == null) { return(NotFound()); } var registration = await _context.Registration.Include(m => m.GbvCase).SingleOrDefaultAsync(m => m.GbvCaseId == id && m.GbvCase.UserName.Equals(User.Identity.Name)); if (registration == null) { return(NotFound()); } registration.GbvCase.PatientName = _crypto.Decrypt(registration.GbvCase.PatientName); registration.GbvCase.PatientFatherName = _crypto.Decrypt(registration.GbvCase.PatientFatherName); ViewBag.details = registration.GbvCase; return(View(registration)); }
// GET: Consents/Edit/5 public async Task <IActionResult> Edit(Guid?id) { if (id == null) { return(NotFound()); } var consent = await _context.Consent.Include(m => m.GbvCase).AsNoTracking().SingleOrDefaultAsync(m => m.GbvCaseId == id && m.GbvCase.UserName.Equals(User.Identity.Name)); if (consent == null) { return(NotFound()); } consent.GbvCase.PatientName = _crypto.Decrypt(consent.GbvCase.PatientName); consent.GbvCase.PatientFatherName = _crypto.Decrypt(consent.GbvCase.PatientFatherName); ViewBag.details = consent.GbvCase; return(View(consent)); }
public async Task <IActionResult> Index() { var data = await _context.GbvCase.Include(g => g.Hospital).Where(m => m.UserName.Equals(User.Identity.Name)).AsNoTracking().ToListAsync(); foreach (var item in data) { item.PatientFatherName = _crypto.Decrypt(item.PatientFatherName); item.PatientName = _crypto.Decrypt(item.PatientName); } return(View(data)); }
public Models.User Authentication(Models.User User) { var dbUser = _ffsaDbContext.Users .SingleOrDefault(user => user.Email == User.Email && _cipherService.Decrypt(user.Password) == User.Password); return(dbUser == null ? new Models.User() : new Models.User() { Id = dbUser.Id, FirstName = dbUser.FirstName, LastName = dbUser.LastName, Email = dbUser.Email }); }
private static async Task <string> DecryptResponseContent(HttpResponseMessage response, ICipherService aesService) { if (response.Content == null) { return(string.Empty); } var responseContentStr = await response.Content.ReadAsStringAsync(); if (string.IsNullOrWhiteSpace(responseContentStr)) { return(string.Empty); } return(aesService.Decrypt(responseContentStr)); }
public string GetCookie(string key) { if (HttpContext.Current.Request.Cookies[key] != null && !String.IsNullOrEmpty(HttpContext.Current.Request.Cookies[key].Value)) { try { return(_cipherService.Decrypt <DESCryptoServiceProvider>( HttpContext.Current.Request.Cookies[key].Value, _appKey, _appSalt)); } catch (FormatException) { return(null); } } return(null); }
public async Task <KeyValuePair <bool, string> > GetBySlugAsync(string slug, string key) { var paste = await _context.Pastes.FirstOrDefaultAsync(p => p.Slug == slug); try { var decryptedText = _cipherService.Decrypt(paste.EncryptedText, key); _context.Pastes.Remove(paste); await _context.SaveChangesAsync(); return(new KeyValuePair <bool, string>(true, decryptedText)); } catch { return(new KeyValuePair <bool, string>(false, string.Empty)); } }
public T GetMessage <T>(ICipherService cipherService) { if (string.IsNullOrEmpty(ContentTypeName)) { throw new MessageDecryptionException(MessageDecryptionErrorReason.NoContentTypeName); } if (string.IsNullOrEmpty(Body)) { throw new MessageDecryptionException(MessageDecryptionErrorReason.EmptyBody); } // decrypt var decryptedBody = cipherService.Decrypt(Body); try { Type messageType = Type.GetType(ContentTypeName); dynamic jobj = JsonConvert.DeserializeObject(decryptedBody, messageType); return(jobj); } catch (Exception e) { throw new MessageDecryptionException(MessageDecryptionErrorReason.WrongContentType); } }
public Models.User Authentication(Entities.User user) { var dbUser = _FocusDbContext.Users.SingleOrDefault(u => u.Name == user.Name && _cipherService.Decrypt(u.Password) == user.Password); return(dbUser == null ? new Models.User() : new Models.User() { Id = dbUser.Id, Name = dbUser.Name, Email = dbUser.Email, Avatar = dbUser.Avatar, IsAdmin = dbUser.IsAdmin }); }
public AdminStore(AppSettings settings, ICipherService cipherService) { AppSettings = settings; _adminAccount = new Account(cipherService.Decrypt(AppSettings.AdminKey)); }