Exemple #1
0
 public virtual PermitEnum PermitUser(ExternalUser user)
 {
     if (IsUser(user))
     {
         return(_access == AccessEnum.Allow?PermitEnum.Allow:PermitEnum.Deny);
     }
     else
     {
         return(PermitEnum.NotFound);
     }
 }
        /// <summary>
        /// Checks if the specified user has permission
        /// </summary>
        /// <param name="subsystem"></param>
        /// <param name="pid"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public virtual bool IsUserAllowed(string subsystem, string pid, ExternalUser user)
        {
            Permission permission = FindPermission(subsystem, pid);

            if (permission != null)
            {
                return(permission.IsExternalUserPermitted(user));
            }

            return(false);
        }
Exemple #3
0
        /// <summary>
        /// Returns if the specified external user has permition
        /// </summary>
        /// <param name="user">The user to examine</param>
        /// <returns>
        /// True if the user has permission, false otherwise
        /// </returns>
        public bool IsExternalUserPermitted(ExternalUser user)
        {
            foreach (PermissionEntry entry in _permissionEntries)
            {
                PermissionEntry.PermitEnum permit = entry.PermitUser(user);

                if (permit != PermissionEntry.PermitEnum.NotFound)
                {
                    return(permit == PermissionEntry.PermitEnum.Allow? true: false);
                }
            }

            return(false);
        }
Exemple #4
0
 protected override bool IsUser(ExternalUser user)
 {
     return(_id.Equals(ID_ALL) || _id.Equals(ID_EXTERNAL));
 }
Exemple #5
0
 protected override bool IsUser(ExternalUser user)
 {
     return(_externalGroupId.Equals(user.Group.Id));
 }
Exemple #6
0
 protected override bool IsUser(ExternalUser user)
 {
     return(_externalUserId.Equals(user.UId));
 }
Exemple #7
0
 protected virtual bool IsUser(ExternalUser user)
 {
     return(false);
 }
Exemple #8
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns>
        /// A <see cref="System.Boolean"/>
        /// </returns>
        public void TestDotNetCfgAccessControlList()
        {
            Console.WriteLine("Make sure that the test configuration file is in place!");
            AccessControlList acl = new DotNetCfgAccessControlList();
            User user1 = acl.FindUserById("1");
            User user1_1 = acl.FindUserById("1_1");
            User user2 = acl.FindUserById("2");
            User user3 = acl.FindUserById("3");

            ExternalUser externalUser1 = new ExternalUser("ex_1", "ex_gid_1");
            ExternalUser externalUser2 = new ExternalUser("ex_2", "ex_gid_2");
            ExternalUser externalUser3 = new ExternalUser("ex_3", "ex_gid_3");

            if(acl.IsUserAllowed("test", "user_1_only", user1) != true)
                throw new Exception("pid=user_1_only user 1 does not have access");
            if(acl.IsUserAllowed("test", "user_1_only", user2) != false)
                throw new Exception("pid=user_1_only user 2 has also access");

            if(acl.IsUserAllowed("test", "group_2_and_user_1", user2) != true)
                throw new Exception("pid=group_2_and_user_1 user2 has no access");
            if(acl.IsUserAllowed("test", "group_2_and_user_1", user1) != true)
                throw new Exception("pid=group_2_and_user_1 user1 has no access");
            if(acl.IsUserAllowed("test", "group_2_and_user_1", user3) != false)
                throw new Exception("pid=group_2_and_user_1 user3 has access");

            if(acl.IsUserAllowed("test", "allow_group_1_deny_user_1", user1_1) != true)
                throw new Exception("pid=allow_group_1_deny_user_1 user1_1 has no access");
            if(acl.IsUserAllowed("test", "allow_group_1_deny_user_1", user1) != false)
                throw new Exception("pid=allow_group_1_deny_user_1 user1 has access");
            if(acl.IsUserAllowed("test", "allow_group_1_deny_user_1", user2) != false)
                throw new Exception("pid=allow_group_1_deny_user_1 user2 has access");

            if(acl.IsUserAllowed("test", "all_internal", user1) != true)
                throw new Exception("pid=all_internal user1 has no access");
            if(acl.IsUserAllowed("test", "all_internal", user2) != true)
                throw new Exception("pid=all_internal user2 has no access");
            if(acl.IsUserAllowed("test", "all_internal", user3) != true)
                throw new Exception("pid=all_internal user3 has no access");
            if(acl.IsUserAllowed("test", "all_internal", externalUser1) != false)
                throw new Exception("pid=all_internal externalUser1 has access");

            if(acl.IsUserAllowed("test", "all_external", externalUser1) != true)
                throw new Exception("pid=all_external externalUser1 has no access");
            if(acl.IsUserAllowed("test", "all_external", externalUser2) != true)
                throw new Exception("pid=all_external externalUser2 has no access");
            if(acl.IsUserAllowed("test", "all_external", externalUser3) != true)
                throw new Exception("pid=all_external externalUser3 has no access");
            if(acl.IsUserAllowed("test", "all_external", user1) != false)
                throw new Exception("pid=all_external user1 has access");
        }
Exemple #9
0
        /// <summary>
        /// Checks if the specified user has permission
        /// </summary>
        /// <param name="subsystem"></param>
        /// <param name="pid"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public virtual bool IsUserAllowed(string subsystem, string pid, ExternalUser user)
        {
            Permission permission = FindPermission(subsystem, pid);

            if(permission != null)
                return permission.IsExternalUserPermitted(user);

            return false;
        }
Exemple #10
0
 protected override bool IsUser(ExternalUser user)
 {
     return _externalGroupId.Equals(user.Group.Id);
 }
Exemple #11
0
 protected virtual bool IsUser(ExternalUser user)
 {
     return false;
 }
Exemple #12
0
 public virtual PermitEnum PermitUser(ExternalUser user)
 {
     if(IsUser(user))
         return _access == AccessEnum.Allow?PermitEnum.Allow:PermitEnum.Deny;
     else
         return PermitEnum.NotFound;
 }
Exemple #13
0
        /// <summary>
        /// Returns if the specified external user has permition
        /// </summary>
        /// <param name="user">The user to examine</param>
        /// <returns>
        /// True if the user has permission, false otherwise
        /// </returns>
        public bool IsExternalUserPermitted(ExternalUser user)
        {
            foreach(PermissionEntry entry in _permissionEntries)
            {
                PermissionEntry.PermitEnum permit = entry.PermitUser(user);

                if(permit != PermissionEntry.PermitEnum.NotFound)
                    return permit == PermissionEntry.PermitEnum.Allow? true: false;
            }

            return false;
        }
Exemple #14
0
 protected override bool IsUser(ExternalUser user)
 {
     return _id.Equals(ID_ALL) || _id.Equals(ID_EXTERNAL);
 }
Exemple #15
0
 protected override bool IsUser(ExternalUser user)
 {
     return _externalUserId.Equals(user.UId);
 }