private void Configure(SuplexProvider p, DateTime?listSourceLastWriteTime = null) { Connection = p.Connection; Users = p.Users; Groups = p.Groups; ListSourcePath = p.ListSourcePath; ListSourceLastWriteTime = listSourceLastWriteTime ?? p.ListSourceLastWriteTime; }
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 <SuplexProvider>(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); SuplexProvider p = YamlHelpers.Deserialize <SuplexProvider>(s); Configure(p, lastWriteTime); SuplexProvider listSource = YamlHelpers.DeserializeFile <SuplexProvider>(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; } } if (HasConnection && Connection.WantsInitialize) { Connection.Initialize(); _cache[hash] = this; } } }