public KeyVaultKeyRepository(KeyVaultConfiguration keyVaultConfiguration) { this.keyVaultConfiguration = keyVaultConfiguration; // TODO : Move this into a common provider as it is used in multiple places this.keyVaultClient = new KeyVaultClient(this.HandleKeyVaultAuthenticationCallback); }
public async Task <bool> InsertOrUpdate(KeyVaultConfiguration keyVaultConfiguration) { var writeToFile = JsonConvert.SerializeObject(keyVaultConfiguration); var filePath = Path.Combine( ConfigurationPath, keyVaultConfiguration.VaultName, string.Format(ConfigurationFileFormat, keyVaultConfiguration.VaultName)); var directoryPath = Path.Combine(ConfigurationPath, keyVaultConfiguration.VaultName); if (!Directory.Exists(directoryPath)) { Directory.CreateDirectory(directoryPath); } using (var file = File.Create(filePath)) { using (var streamWriter = new StreamWriter(file)) { await streamWriter.WriteAsync(writeToFile); await streamWriter.FlushAsync(); this.allConfigurations.Remove(keyVaultConfiguration); this.allConfigurations.Add(keyVaultConfiguration); return(true); } } }
public bool Delete(KeyVaultConfiguration keyVaultConfiguration) { var configurarionDirectory = Path.Combine(ConfigurationPath, keyVaultConfiguration.VaultName); Directory.Delete(configurarionDirectory, true); this.allConfigurations.Remove(keyVaultConfiguration); return true; }
public async Task<bool> InsertOrUpdate(KeyVaultConfiguration keyVaultConfiguration) { var writeToFile = JsonConvert.SerializeObject(keyVaultConfiguration); var filePath = Path.Combine( ConfigurationPath, keyVaultConfiguration.VaultName, string.Format(ConfigurationFileFormat, keyVaultConfiguration.VaultName)); var directoryPath = Path.Combine(ConfigurationPath, keyVaultConfiguration.VaultName); if (!Directory.Exists(directoryPath)) { Directory.CreateDirectory(directoryPath); } using (var file = File.Create(filePath)) { using (var streamWriter = new StreamWriter(file)) { await streamWriter.WriteAsync(writeToFile); await streamWriter.FlushAsync(); this.allConfigurations.Remove(keyVaultConfiguration); this.allConfigurations.Add(keyVaultConfiguration); return true; } } }
public AddKeyVaultAccountViewModel(IKeyVaultConfigurationRepository keyVaultConfigurationRepository, KeyVaultConfiguration keyVaultConfiguration) { this.keyVaultConfigurationRepository = keyVaultConfigurationRepository; this.vaultUrlMatcher = new Regex(KeyVaultUrlFormat, RegexOptions.Compiled); this.AddKeyVaultAccountCommand = new RelayCommand(this.AddKeyVaultAccount, this.CanAddKeyVaultCommand); this.Initialize(keyVaultConfiguration); }
public bool Delete(KeyVaultConfiguration keyVaultConfiguration) { var configurarionDirectory = Path.Combine(ConfigurationPath, keyVaultConfiguration.VaultName); Directory.Delete(configurarionDirectory, true); this.allConfigurations.Remove(keyVaultConfiguration); return(true); }
public KeyVaultAccountViewModel(KeyVaultConfiguration keyVaultConfiguration, IKeyRepository keyRepository) { if (keyVaultConfiguration == null) { throw new ArgumentNullException("keyVaultConfiguration"); } this.keyVaultConfiguration = keyVaultConfiguration; this.keyRepository = keyRepository; this.ManageVaultKeysViewModel = new ManageVaultKeysViewModel(keyVaultConfiguration.VaultName, keyRepository, new KeyVaultKeyRepository(keyVaultConfiguration)); this.ManageLocalKeysViewModel = new ManageLocalKeysViewModel(keyVaultConfiguration.VaultName, keyRepository); this.ManageLocalKeysViewModel.KeysModified += this.HandleKeysModified; this.ManageVaultKeysViewModel.KeysModified += this.HandleKeysModified; this.KeyCryptographicOperationsViewModel = new KeyCryptographicOperationsViewModel(new KeyOperations(keyVaultConfiguration)); }
public async Task UpdateExistingConfigurationTest() { this.Initialize(); var keyVaultConfiguration = new KeyVaultConfiguration() { ADApplicationClientId = "1", ADApplicationSecret = "Secret", VaultName = "test", AzureKeyVaultUrl = @"https://test.vault.azure.net/" }; IKeyVaultConfigurationRepository repository = new KeyVaultConfigurationRepository(); var isInserted = await repository.InsertOrUpdate(keyVaultConfiguration); Assert.IsTrue(isInserted); Assert.IsTrue(repository.All.Count() == 1); keyVaultConfiguration.ADApplicationSecret = "Updated Secret"; await repository.InsertOrUpdate(keyVaultConfiguration); IKeyVaultConfigurationRepository newRepository = new KeyVaultConfigurationRepository(); Assert.IsTrue(newRepository.All.Count() == 1); Assert.IsTrue(newRepository.All.First().ADApplicationSecret == "Updated Secret"); }
public KeyVaultConfigurationChangedEventArgs(KeyVaultConfiguration keyVaultConfiguration) { this.KeyVaultConfiguration = keyVaultConfiguration; }
public KeyOperations(KeyVaultConfiguration keyVaultConfiguration) { this.keyVaultConfiguration = keyVaultConfiguration; this.keyVaultClient = new KeyVaultClient(this.HandleKeyVaultAuthenticationCallback); }
private void OnDeleteKeyVaultConfiguration() { this.keyVaultConfigurationRepository.Delete(this.selectedKeyVaultConfiguration); this.RaisePropertyChanged(() => this.KeyVaultConfigurations); this.SelectedKeyVaultConfiguration = null; this.RaiseConfigurationChangedEvent(); }
private void Initialize(KeyVaultConfiguration keyVaultConfiguration) { this.keyVaultConfiguration = keyVaultConfiguration; this.KeyVaultUrl = keyVaultConfiguration.AzureKeyVaultUrl; this.ADApplicationId = keyVaultConfiguration.ADApplicationClientId; this.ADApplicationSecret = keyVaultConfiguration.ADApplicationSecret; this.SetupValidationRules(); }