Ejemplo n.º 1
0
        internal static IEnumerable <PermissionAction> ParseInitialPermissions(SnSecurityContext context, IList <string> permissionData)
        {
            var actions = new Dictionary <int, PermissionAction>();

            foreach (var action in permissionData.Select(x => ParsePermissions(context, x)))
            {
                var entityId = action.Entries[0].EntityId;
                if (!actions.TryGetValue(entityId, out var existingAction))
                {
                    existingAction = new PermissionAction
                    {
                        EntityId = entityId,
                        Entries  = new List <StoredAce>()
                    };
                    var isEntityInherited = context.IsEntityInherited(entityId);
                    if (isEntityInherited && action.Break)
                    {
                        existingAction.Break = true;
                    }
                    if (!isEntityInherited && !action.Break)
                    {
                        existingAction.Unbreak = true;
                    }
                    actions.Add(entityId, existingAction);
                }
                existingAction.Entries.AddRange(action.Entries);
            }
            return(actions.Values);
        }
Ejemplo n.º 2
0
        private static PermissionAction ParsePermissions(SnSecurityContext context, string permissionData)
        {
            // "+E1|Normal|+U1:____++++,Normal|+G1:____++++"
            var a           = permissionData.Split('|');
            var trimmed     = a[0].Trim();
            var isInherited = trimmed[0] == '+';
            var b           = trimmed.Substring(1);
            var entityId    = int.Parse(b);

            return(new PermissionAction()
            {
                Break = !isInherited,
                Entries = ParseEntries(entityId, permissionData.Substring(a[0].Length + 1))
            });
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Returns with a new instance of the SnAclEditor with a SecurityContext as the current context.
 /// </summary>
 public static SnAclEditor Create(SnSecurityContext context)
 {
     return(new SnAclEditor(context));
 }
Ejemplo n.º 4
0
 internal SnAclEditor(SnSecurityContext context) : base(context ?? SecurityHandler.SecurityContext)
 {
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Starts the security subsystem using the passed configuration.
 /// The method prepares and memorizes the main components for
 /// creating SecurityContext instances in a fastest possible way.
 /// The main components are global objects:
 /// ISecurityDataProvider instance, IMessageProvider instance and SecurityCache instance.
 /// </summary>
 public static new void StartTheSystem(SecurityConfiguration configuration)
 {
     SecurityContext.StartTheSystem(configuration);
     _generalContext = new SnSecurityContext(new SystemUser(null));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Returns with a new instance of the SnAclEditor with a SecurityContext as the current context.
 /// </summary>
 public static SnAclEditor Create(SnSecurityContext context, EntryType entryType = EntryType.Normal)
 {
     return(new SnAclEditor(context, entryType));
 }
Ejemplo n.º 7
0
 internal SnAclEditor(SnSecurityContext context, EntryType entryType = EntryType.Normal)
     : base(context ?? Providers.Instance.SecurityHandler.SecurityContext, entryType)
 {
 }
Ejemplo n.º 8
0
 internal SnAclEditor(SnSecurityContext context, EntryType entryType = EntryType.Normal)
     : base(context ?? SecurityHandler.SecurityContext, entryType)
 {
 }