Exemple #1
0
        private bool _disposedValue = false; // To detect redundant calls

        public UxOperation(VaultAlias currentVaultAlias, ToolStripItem statusLabel, ToolStripProgressBar statusProgress, ToolStripItem cancelButton, params ToolStripItem[] controlsToToggle)
        {
            _startTime         = DateTimeOffset.UtcNow;
            _currentVaultAlias = currentVaultAlias;
            _statusLabel       = statusLabel;
            _statusProgress    = statusProgress;
            _cancelButton      = cancelButton;
            _controlsToToggle  = controlsToToggle;

            _cancellationTokenSource = new CancellationTokenSource();

            ToggleControls(false, _controlsToToggle);
            _statusLabel.Text = "Busy";
            ProgressBarVisibility(true);
            if (_cancelButton != null)
            {
                _cancelButton.Click += uxButtonCancel_Click;
            }

            Cursor.Current = Cursors.WaitCursor;
        }
        private static List <SecretKind> LoadSecretKinds(VaultAlias vaultAlias, out List <string> unknownSk)
        {
            SecretKinds       allSecretKinds       = Utils.LoadFromJsonFile <SecretKinds>(Settings.Default.SecretKindsJsonFileLocation);
            List <SecretKind> validatedSecretKinds = new List <SecretKind>(vaultAlias.SecretKinds.Length);

            unknownSk = new List <string>();

            foreach (var secretKind in vaultAlias.SecretKinds)
            {
                SecretKind sk;
                if (allSecretKinds.TryGetValue(secretKind, out sk))
                {
                    validatedSecretKinds.Add(sk);
                }
                else
                {
                    unknownSk.Add(secretKind);
                }
            }

            return(validatedSecretKinds);
        }
        private async void uxListViewVaults_SelectedIndexChanged(object sender, EventArgs e)
        {
            ListViewItemSubscription s = uxListViewSubscriptions.SelectedItems.Count > 0 ? (ListViewItemSubscription)uxListViewSubscriptions.SelectedItems[0] : null;
            ListViewItemVault        v = uxListViewVaults.SelectedItems.Count > 0 ? (ListViewItemVault)uxListViewVaults.SelectedItems[0] : null;

            uxButtonOK.Enabled = false;
            if ((null == s) || (null == v))
            {
                return;
            }
            using (var op = NewUxOperationWithProgress(uxComboBoxAccounts))
            {
                var vault = await _currentKeyVaultMgmtClient.Vaults.GetAsync(v.GroupName, v.Name);

                uxPropertyGridVault.SelectedObject = new PropertyObjectVault(s.Subscription, v.GroupName, vault);
                uxButtonOK.Enabled = true;
                CurrentVaultAlias  = new VaultAlias(v.Name, new string[] { v.Name }, new string[] { "Custom" })
                {
                    DomainHint = _currentAccountItem.DomainHint
                };
            }
        }
Exemple #4
0
        private static List <SecretKind> LoadSecretKinds(VaultAlias vaultAlias, out List <string> unknownSk)
        {
            SecretKinds       allSecretKinds       = Utils.LoadFromJsonFile <SecretKinds>(Settings.Default.SecretKindsJsonFileLocation);
            List <SecretKind> validatedSecretKinds = new List <SecretKind>(allSecretKinds.Count) ?? new List <SecretKind>(vaultAlias.SecretKinds.Length);

            unknownSk = new List <string>();

            // If there are no SecretKinds in the VaultAliases.json for a vault OR if it's a vault Not in VaultAliases, return ALL SecretKinds.
            if (vaultAlias.SecretKinds == null || (vaultAlias.SecretKinds.Length == 1 && (string)vaultAlias.SecretKinds.GetValue(0) == "Custom"))
            {
                foreach (var key in allSecretKinds.Keys)
                {
                    SecretKind sk;
                    allSecretKinds.TryGetValue(key, out sk);
                    validatedSecretKinds.Add(sk);
                }
            }
            // Otherwise, return just the specified SecretKinds
            else
            {
                foreach (var secretKind in vaultAlias.SecretKinds)
                {
                    SecretKind sk;
                    if (allSecretKinds.TryGetValue(secretKind, out sk))
                    {
                        validatedSecretKinds.Add(sk);
                    }
                    else
                    {
                        unknownSk.Add(secretKind);
                    }
                }
            }

            // Sort the Secret Kinds
            List <SecretKind> orderedValidatedSecretKinds = validatedSecretKinds.OrderBy(o => o.Alias).ToList();

            return(orderedValidatedSecretKinds);
        }
 public bool Equals(VaultAlias va) => (Alias == va?.Alias);