/// <summary> /// loads the file and hydrates the cipher pair. expects a json serialized value /// </summary> private void Load() { var secureData = this.LockedFile.Read(); var data = SecureStringUtil.ToInsecureString(secureData); this.Pair = JsonSerializer.DeserializeFromString <SymmetricCipherPair>(data); Condition.Requires(this.Pair).IsNotNull(); }
public void UTF8DecodeTest() { for (uint c = char.MinValue; c <= char.MaxValue; c++) { SecureString secureString = new SecureString(); byte[] utf8Encoding = Encoding.UTF8.GetBytes(new char[] { (char)c }); string dotNetDecodedString = Encoding.UTF8.GetString(utf8Encoding); SecureStringUtil.CopyUTF8ToSecureString(utf8Encoding, secureString); Assert.AreEqual(SecureStringToString(secureString), dotNetDecodedString); } }
public MailService(IConfiguration configuration) { var confSec = configuration.GetSection("MailService"); address = confSec.GetValue <string>("Address"); port = confSec.GetValue <int>("Port", 587); credential = new NetworkCredential() { UserName = confSec.GetValue <string>("Username"), SecurePassword = SecureStringUtil.FromString(confSec.GetValue <string>("Password")), }; }
private static void _onPasswordChanged(DependencyObject sender, DependencyPropertyChangedEventArgs dpcea) { BindPasswordBehaviour behaviour = sender as BindPasswordBehaviour; if (behaviour == null) { return; } if (behaviour.AssociatedObject != null && SecureStringUtil.Read((SecureString)dpcea.NewValue) != behaviour.AssociatedObject.Password) { behaviour.AssociatedObject.Password = SecureStringUtil.Read((SecureString)dpcea.NewValue); } }
private void _unlockLoginIfNeeded() { if (_login != null && _login.Length > 0 && _securePassword != null && SecureStringUtil.Read(_securePassword).Length > 0 && !_loginCommand.CanExecute(null)) { _loginCommand.ChangeCanExecute(); } else if (( _login == null || _login.Length == 0 || _securePassword == null || SecureStringUtil.Read(_securePassword).Length == 0 ) && _loginCommand.CanExecute(null) ) { _loginCommand.ChangeCanExecute(); } }
private async Task _loginCmd(object ignore) { try { Logger.Log($"Connexion de l'utilisateur {_login}"); User user = await UserRepository.FindByLoginAsync(_login); if (user == null) { Logger.Log($"Utilisateur {_login} inconnu"); LoginResult = "Utilisateur inconnu"; ResultReady = true; return; } bool passwordMatch = user.Password.Equals(HashManager.SHA256(SecureStringUtil.Read(_securePassword)), StringComparison.InvariantCultureIgnoreCase); bool hasRights = (user.Rights & UserRights.Booking) == UserRights.Booking; _logUserIfAppropriate(user, passwordMatch, hasRights); } catch (Exception ex) { Logger.Log(ex); } }
public CprLookupServicePortTypeClient(string endpointUrl, string certPath, string certPassword) : base(CprLookupServicePortTypeClient.GetBindingForEndpoint(), CprLookupServicePortTypeClient.GetEndpointAddress(endpointUrl)) { this.ClientCredentials.ClientCertificate.Certificate = new X509Certificate2(fileName: certPath, password: SecureStringUtil.ConvertToSecureString(certPassword)); // Disable revocation checking this.ClientCredentials.ServiceCertificate.Authentication.RevocationMode = X509RevocationMode.NoCheck; ConfigureEndpoint(this.Endpoint, this.ClientCredentials); }