Ejemplo n.º 1
0
        public static Dictionary <int, AclInfo> LoadAcls(ISecurityDataProvider dataProvider, IDictionary <int, SecurityEntity> entities)
        {
            var acls = new Dictionary <int, AclInfo>();

            foreach (var storedAce in dataProvider.LoadAllAces())
            {
                AclInfo acl;
                if (!acls.TryGetValue(storedAce.EntityId, out acl))
                {
                    acl = new AclInfo(storedAce.EntityId);
                    acls.Add(acl.EntityId, acl);
                }
                acl.Entries.Add(new AceInfo {
                    IdentityId = storedAce.IdentityId, LocalOnly = storedAce.LocalOnly, AllowBits = storedAce.AllowBits, DenyBits = storedAce.DenyBits
                });
            }

            return(acls);
        }
Ejemplo n.º 2
0
        private static void SavePermissions(ISecurityDataProvider db, string tempFolderPath)
        {
            using (var writer = new StreamWriter(Path.Combine(tempFolderPath, "permissions.txt"), false, Encoding.UTF8))
            {
                var breaks = db.LoadSecurityEntities()
                             .Where(e => !e.IsInherited)
                             .Select(e => e.Id)
                             .ToArray();

                var aces = db.LoadAllAces()
                           .OrderBy(a => a.EntityId)
                           .ThenBy(e => e.IdentityId);

                foreach (var ace in aces)
                {
                    writer.WriteLine("            \"{0}{1}\",",
                                     breaks.Contains(ace.EntityId) ? "-" : "+",
                                     ace.ToString().Replace("(", "").Replace(")", ""));
                }
            }
        }
Ejemplo n.º 3
0
        public Dictionary <int, AclInfo> LoadAcls()
        {
            if (!IsDatabaseReadyAsync(CancellationToken.None).GetAwaiter().GetResult())
            {
                return(new Dictionary <int, AclInfo>());
            }

            var acls = new Dictionary <int, AclInfo>();

            foreach (var storedAce in _dataProvider.LoadAllAces())
            {
                if (!acls.TryGetValue(storedAce.EntityId, out var acl))
                {
                    acl = new AclInfo(storedAce.EntityId);
                    acls.Add(acl.EntityId, acl);
                }
                acl.Entries.Add(new AceInfo {
                    EntryType = storedAce.EntryType, IdentityId = storedAce.IdentityId, LocalOnly = storedAce.LocalOnly, AllowBits = storedAce.AllowBits, DenyBits = storedAce.DenyBits
                });
            }

            return(acls);
        }