private void entryContextMenu_Opened(object sender, EventArgs e) { if (!this.Settings.Enabled) { return; } PwEntry[] selectedEntries = this.pluginHost.MainWindow.GetSelectedEntries(); if (selectedEntries != null && selectedEntries.Length == 1) { this.menuItems = new DisposableList <ToolStripItem>(); HostPwEntry hostPwEntry = new HostPwEntry(selectedEntries[0], this.pluginHost.Database, this.fieldsMapper); var changePasswordMenuItem = this.createChangePasswordMenuItem(hostPwEntry); if (hostPwEntry.HasConnectionMethods) { menuItems.AddRange(this.createMenuItems(hostPwEntry)); if (this.Settings.CompatibleMode) { this.menuItems.Insert(0, new ToolStripSeparator()); } else { this.menuItems.Add(new ToolStripSeparator()); } if (this.Settings.AddChangePasswordMenuItem) { if (this.Settings.CompatibleMode) { this.menuItems.Insert(0, changePasswordMenuItem); this.menuItems.Insert(0, new ToolStripSeparator()); } else { this.menuItems.Add(changePasswordMenuItem); this.menuItems.Add(new ToolStripSeparator()); } } if (this.Settings.CompatibleMode) { foreach (var item in this.menuItems) { this.pluginHost.MainWindow.EntryContextMenu.Items.Add(item); } } else { for (int i = this.menuItems.Count - 1; i >= 0; i--) { this.pluginHost.MainWindow.EntryContextMenu.Items.Insert(0, this.menuItems[i]); } } } } }
private async Task <CertificateAuthority> CreateDefaultTrustedCertificateAuthorityAsync() { var testServer = await GetTestServerAsync(); var rootCa = await GetRootCertificateAuthority(); var intermediateCa = rootCa.CreateIntermediateCertificateAuthority(); _responders.AddRange(testServer.RegisterResponders(intermediateCa)); return(intermediateCa); }
public void Dispose_ListWithManyItems_ShouldDisposeAllItems( IEnumerable<IDisposable> items) { //Setup var sut = new DisposableList<IDisposable>(); sut.AddRange(items); //Exercise sut.Dispose(); //Verify sut.Should().NotBeEmpty(); sut.ForEach(item => Mock.Get(item).Verify(x => x.Dispose())); }
public void Dispose_ListWithManyItems_ShouldDisposeAllItems( IEnumerable <IDisposable> items) { //Setup var sut = new DisposableList <IDisposable>(); sut.AddRange(items); //Exercise sut.Dispose(); //Verify sut.Should().NotBeEmpty(); sut.ForEach(item => Mock.Get(item).Verify(x => x.Dispose())); }
public static DisposableList <IDisposable> RegisterRespondersForEntireChain( this ISigningTestServer testServer, CertificateAuthority ca, bool addCa = true, bool addOcsp = true) { var responders = new DisposableList <IDisposable>(); var currentCa = ca; while (currentCa != null) { responders.AddRange(testServer.RegisterResponders(currentCa, addCa, addOcsp)); currentCa = currentCa.Parent; } return(responders); }
private void BuildAuthZContext() { _resource_manager = string.IsNullOrWhiteSpace(Server) ? AuthZResourceManager.Create(GetType().Name, AuthZResourceManagerInitializeFlags.NoAudit | AuthZResourceManagerInitializeFlags.NoCentralAccessPolicies, null) : AuthZResourceManager.Create(Server, null, AuthZResourceManagerRemoteServiceType.Default); var sids = new HashSet <Sid>(); if (UserSid != null) { foreach (var sid in UserSid) { sids.Add(sid); } } if (UserName != null) { foreach (var name in UserName) { sids.Add(NtSecurity.LookupAccountName(name)); } } if (sids.Count == 0) { sids.Add(NtToken.CurrentUser.Sid); } if (_resource_manager.Remote || UseLocalGroup) { _context.AddRange(sids.Select(s => _resource_manager.CreateContext(s, AuthZContextInitializeSidFlags.None))); } else { foreach (var sid in sids) { if (!NtSecurity.IsDomainSid(sid) || NtSecurity.IsLocalDomainSid(sid)) { _context.AddResource(_resource_manager.CreateContext(sid, AuthZContextInitializeSidFlags.None)); continue; } WriteProgress($"Building security context for {sid.Name}"); var context = _context.AddResource(_resource_manager.CreateContext(sid, AuthZContextInitializeSidFlags.SkipTokenGroups)); context.AddSids(_cached_user_groups.GetOrAdd(Tuple.Create(Domain, sid), _ => GetUserDomainSids(Domain, sid))); } } foreach (var context in Context) { if (sids.Add(context.User.Sid)) { var next_ctx = _context.AddResource(_resource_manager.CreateContext(context.User.Sid, AuthZContextInitializeSidFlags.SkipTokenGroups)); foreach (var group in context.Groups) { next_ctx.AddSid(group.Sid); } } } _token_info = _context.Select(c => new TokenInformation(c)).ToList(); }