Exemple #1
0
        private static PermissionValue GetValue(uint allowBits, uint denyBits, PermissionType perm)
        {
            var mask = 1u << (perm.Index - 1);

            if ((denyBits & mask) != 0)
            {
                return(PermissionValue.Deny);
            }
            if ((allowBits & mask) != 0)
            {
                return(PermissionValue.Allow);
            }
            return(PermissionValue.NonDefined);
        }
Exemple #2
0
        /// <summary>
        /// Resets the allowed and denied permissions by the passed bitmask.
        /// </summary>
        /// <param name="entityId">The requested entity.</param>
        /// <param name="identityId">The requested identity.</param>
        /// <param name="localOnly">Determines whether the edited entry is inheritable or not.</param>
        /// <param name="permissionMask">Contains one or more permissions to allow or deny.</param>
        /// <returns>A reference to this instance for calling more operations.</returns>
        public new SnAclEditor Reset(int entityId, int identityId, bool localOnly, SenseNet.Security.PermissionBitMask permissionMask)
        {
            var permissionsToReset = new List <SenseNet.Security.PermissionTypeBase>();
            var bits = permissionMask.AllowBits | permissionMask.DenyBits;

            for (var i = 0; i < PermissionType.PermissionCount; i++)
            {
                if ((bits & (1uL << i)) != 0)
                {
                    permissionsToReset.Add(PermissionType.GetByIndex(i));
                }
            }
            ClearPermission(entityId, identityId, localOnly, permissionsToReset.ToArray());
            return(this);
        }
Exemple #3
0
        private static string GetMessage(string msg, string path, int nodeId, PermissionType permissionType, IUser user)
        {
            var sb = new StringBuilder(msg ?? "Access denied.");

            if (path != null)
            {
                sb.Append(" Path: ").Append(path);
            }
            if (nodeId != 0)
            {
                sb.Append(" NodeId: ").Append(nodeId);
            }
            if (permissionType != null)
            {
                sb.Append(" PermissionType: ").Append(permissionType.Name);
            }
            if (user != null)
            {
                sb.Append(" User: "******" UserId: ").Append(user.Id);
            }
            return(sb.ToString());
        }
Exemple #4
0
 private void Initialize(string msg = null, string path = null, int nodeId = 0, PermissionType permissionType = null, IUser user = null)
 {
     this.Data.Add("FormattedMessage", GetMessage(msg, path, nodeId, permissionType, user));
     this.Data.Add("EventId", EventId.Error.SecurityError);
     if (msg != null)
     {
         this.Data.Add("Message", msg);
     }
     if (path != null)
     {
         this.Data.Add("Path", path);
     }
     if (nodeId != 0)
     {
         this.Data.Add("NodeId", nodeId);
     }
     if (permissionType != null)
     {
         this.Data.Add("PermissionType", permissionType.Name);
     }
     if (user != null)
     {
         this.Data.Add("User", user.Username);
     }
 }
Exemple #5
0
 public SenseNetSecurityException(int nodeId, PermissionType permissionType, IUser user, string message)
     : base(ACCESSDENIED)
 {
     Initialize(nodeId: nodeId, permissionType: permissionType, user: user, msg: message);
 }
Exemple #6
0
 public SenseNetSecurityException(int nodeId, PermissionType permissionType, IUser user) : this(nodeId, permissionType, user, null)
 {
 }
Exemple #7
0
 public SenseNetSecurityException(string path, PermissionType permissionType, IUser user, string message)
     : base(ACCESSDENIED)
 {
     Initialize(path: path, permissionType: permissionType, user: user, msg: message);
 }
Exemple #8
0
 public SenseNetSecurityException(string path, PermissionType permissionType, IUser user) : this(path, permissionType, user, null)
 {
 }
Exemple #9
0
 public AclEditor SetPermission(ISecurityMember securityMember, bool propagates, PermissionType permissionType, PermissionValue permissionValue)
 {
     return(SetPermission(securityMember.Id, propagates, permissionType, permissionValue));
 }
Exemple #10
0
 private SnPermission GetSnPerm(SnAccessControlEntry entry, PermissionType permType)
 {
     return(entry.Permissions.Where(p => p.Name == permType.Name).First());
 }
Exemple #11
0
        static PermissionType()
        {
            See     = new PermissionType("See", 0);
            Preview = new PermissionType("Preview", 1)
            {
                Allows = new[] { See }
            };
            PreviewWithoutWatermark = new PermissionType("PreviewWithoutWatermark", 2)
            {
                Allows = new[] { Preview }
            };
            PreviewWithoutRedaction = new PermissionType("PreviewWithoutRedaction", 3)
            {
                Allows = new[] { Preview }
            };
            Open = new PermissionType("Open", 4)
            {
                Allows = new[] { PreviewWithoutWatermark, PreviewWithoutRedaction }
            };
            OpenMinor = new PermissionType("OpenMinor", 5)
            {
                Allows = new[] { Open }
            };
            Save = new PermissionType("Save", 6)
            {
                Allows = new[] { OpenMinor }
            };
            Publish = new PermissionType("Publish", 7)
            {
                Allows = new[] { OpenMinor }
            };
            ForceCheckin = new PermissionType("ForceCheckin", 8)
            {
                Allows = new[] { OpenMinor }
            };
            AddNew = new PermissionType("AddNew", 9)
            {
                Allows = new[] { OpenMinor }
            };
            Approve = new PermissionType("Approve", 10)
            {
                Allows = new[] { OpenMinor }
            };
            Delete = new PermissionType("Delete", 11)
            {
                Allows = new[] { OpenMinor }
            };
            RecallOldVersion = new PermissionType("RecallOldVersion", 12)
            {
                Allows = new[] { OpenMinor }
            };
            DeleteOldVersion = new PermissionType("DeleteOldVersion", 13)
            {
                Allows = new[] { OpenMinor }
            };
            SeePermissions = new PermissionType("SeePermissions", 14);
            SetPermissions = new PermissionType("SetPermissions", 15)
            {
                Allows = new[] { SeePermissions }
            };
            RunApplication           = new PermissionType("RunApplication", 16);
            ManageListsAndWorkspaces = new PermissionType("ManageListsAndWorkspaces", 17)
            {
                Allows = new[] { Save, AddNew, DeleteOldVersion }
            };
            TakeOwnership = new PermissionType("TakeOwnership", 18)
            {
                Allows = new[] { See }
            };

            Unused13 = new PermissionType("Unused13", 19);
            Unused12 = new PermissionType("Unused12", 20);
            Unused11 = new PermissionType("Unused11", 21);
            Unused10 = new PermissionType("Unused10", 22);
            Unused09 = new PermissionType("Unused09", 23);
            Unused08 = new PermissionType("Unused08", 24);
            Unused07 = new PermissionType("Unused07", 25);
            Unused06 = new PermissionType("Unused06", 26);
            Unused05 = new PermissionType("Unused05", 27);
            Unused04 = new PermissionType("Unused04", 28);
            Unused03 = new PermissionType("Unused03", 29);
            Unused02 = new PermissionType("Unused02", 30);
            Unused01 = new PermissionType("Unused01", 31);

            Custom01 = new PermissionType("Custom01", 32);
            Custom02 = new PermissionType("Custom02", 33);
            Custom03 = new PermissionType("Custom03", 34);
            Custom04 = new PermissionType("Custom04", 35);
            Custom05 = new PermissionType("Custom05", 36);
            Custom06 = new PermissionType("Custom06", 37);
            Custom07 = new PermissionType("Custom07", 38);
            Custom08 = new PermissionType("Custom08", 39);
            Custom09 = new PermissionType("Custom09", 40);
            Custom10 = new PermissionType("Custom10", 41);
            Custom11 = new PermissionType("Custom11", 42);
            Custom12 = new PermissionType("Custom12", 43);
            Custom13 = new PermissionType("Custom13", 44);
            Custom14 = new PermissionType("Custom14", 45);
            Custom15 = new PermissionType("Custom15", 46);
            Custom16 = new PermissionType("Custom16", 47);
            Custom17 = new PermissionType("Custom17", 48);
            Custom18 = new PermissionType("Custom18", 49);
            Custom19 = new PermissionType("Custom19", 50);
            Custom20 = new PermissionType("Custom20", 51);
            Custom21 = new PermissionType("Custom21", 52);
            Custom22 = new PermissionType("Custom22", 53);
            Custom23 = new PermissionType("Custom23", 54);
            Custom24 = new PermissionType("Custom24", 55);
            Custom25 = new PermissionType("Custom25", 56);
            Custom26 = new PermissionType("Custom26", 57);
            Custom27 = new PermissionType("Custom27", 58);
            Custom28 = new PermissionType("Custom28", 59);
            Custom29 = new PermissionType("Custom29", 60);
            Custom30 = new PermissionType("Custom30", 61);
            Custom31 = new PermissionType("Custom31", 62);
            Custom32 = new PermissionType("Custom32", 63);

            _permissionTypes = new PermissionType[] {
                See, Preview, PreviewWithoutWatermark, PreviewWithoutRedaction, Open, OpenMinor, Save, Publish, ForceCheckin, AddNew, Approve, Delete,
                RecallOldVersion, DeleteOldVersion, SeePermissions, SetPermissions, RunApplication, ManageListsAndWorkspaces,
                TakeOwnership, Unused13, Unused12, Unused11, Unused10, Unused09, Unused08, Unused07, Unused06, Unused05, Unused04, Unused03, Unused02, Unused01,
                Custom01, Custom02, Custom03, Custom04, Custom05, Custom06, Custom07, Custom08, Custom09, Custom10, Custom11, Custom12, Custom13, Custom14, Custom15, Custom16,
                Custom17, Custom18, Custom19, Custom20, Custom21, Custom22, Custom23, Custom24, Custom25, Custom26, Custom27, Custom28, Custom29, Custom30, Custom31, Custom32
            };

            _builtinPermissionTypes = new PermissionType[] {
                See, Preview, PreviewWithoutWatermark, PreviewWithoutRedaction, Open, OpenMinor, Save, Publish, ForceCheckin, AddNew, Approve, Delete,
                RecallOldVersion, DeleteOldVersion, SeePermissions, SetPermissions, RunApplication, ManageListsAndWorkspaces, TakeOwnership
            };
        }
Exemple #12
0
 public SenseNetSecurityException(int nodeId, PermissionType permissionType, IUser user, string message)
     : base(GetMessage(message, null, nodeId, permissionType, user))
 {
 }
Exemple #13
0
 public SenseNetSecurityException(int nodeId, PermissionType permissionType)
     : base(GetMessage(null, null, nodeId, permissionType, null))
 {
 }
Exemple #14
0
 public SenseNetSecurityException(string path, PermissionType permissionType, IUser user, string message)
     : base(GetMessage(message, path, 0, permissionType, user))
 {
 }
Exemple #15
0
 public SenseNetSecurityException(string path, PermissionType permissionType)
     : base(GetMessage(null, path, 0, permissionType, null))
 {
 }