private ReadOnlyCollection<HgAclEntry> ReadAclSection(HgRc hgRc, string section) { if(hgRc[section] == null) return null; var aclEntries = new List<HgAclEntry>(); foreach(var property in hgRc[section].Properties) { var hgAclEntry = new HgAclEntry(property, ReadAclPrincipals(hgRc[section][property]).ToList()); aclEntries.Add(hgAclEntry); } // foreach return new ReadOnlyCollection<HgAclEntry>(aclEntries); }
private bool Matches(HgPrincipal principal, HgAclEntry entry) { foreach(var aclPrincipal in entry.Principals) { if(aclPrincipal.Name == "*") return true; if(aclPrincipal.Excludes) { if(aclPrincipal.Type == HgAclPrincipalType.User && principal.Name != aclPrincipal.Name) return true; if(aclPrincipal.Type == HgAclPrincipalType.Group && !principal.Groups.Contains(aclPrincipal.Name)) return true; } // if else { if(aclPrincipal.Type == HgAclPrincipalType.User && principal.Name == aclPrincipal.Name) return true; if(aclPrincipal.Type == HgAclPrincipalType.Group && principal.Groups.Contains(aclPrincipal.Name)) return true; } // else } // foreach return false; }