public void Configure(IAuthorizationProviderConfig conifg) { if (conifg != null) { int hash = conifg.Config.GetHashCode(); if (!_cache.ContainsKey(hash) || _cache[hash] == null) { string s = YamlHelpers.Serialize(conifg.Config); _cache[hash] = YamlHelpers.Deserialize <WindowsPrincipalProvider>(s); } Configure(_cache[hash]); //if external source declared, merge contents if (!string.IsNullOrWhiteSpace(ListSourcePath) && File.Exists(ListSourcePath)) { DateTime lastWriteTime = File.GetLastWriteTimeUtc(ListSourcePath); if (!lastWriteTime.Equals(ListSourceLastWriteTime)) { string s = YamlHelpers.Serialize(conifg.Config); WindowsPrincipalProvider p = YamlHelpers.Deserialize <WindowsPrincipalProvider>(s); Configure(p, lastWriteTime); WindowsPrincipalProvider listSource = YamlHelpers.DeserializeFile <WindowsPrincipalProvider>(ListSourcePath); if (listSource.HasUsers) { EnsureUsersGroups(isUsers: true); if (listSource.Users.HasAllowed) { Users.Allowed.AddRange(listSource.Users.Allowed); } if (listSource.Users.HasDenied) { Users.Denied.AddRange(listSource.Users.Denied); } } if (listSource.HasGroups) { EnsureUsersGroups(isUsers: false); if (listSource.Groups.HasAllowed) { Groups.Allowed.AddRange(listSource.Groups.Allowed); } if (listSource.Groups.HasDenied) { Groups.Denied.AddRange(listSource.Groups.Denied); } } _cache[hash] = this; } } } }
private void Configure(WindowsPrincipalProvider p, DateTime?listSourceLastWriteTime = null) { Users = p.Users; Groups = p.Groups; LdapRoot = p.LdapRoot; ListSourcePath = p.ListSourcePath; ListSourceLastWriteTime = listSourceLastWriteTime ?? p.ListSourceLastWriteTime; }