Beispiel #1
0
        public SecurityGrid(DotNetNuke.Entities.Portals.PortalSettings ps, bool isReadOnly, string imgPath, PermissionInfo sec, int permId)
		{
			PortalSettings = ps;
			ReadOnly = isReadOnly;
			ImagePath = imgPath;
			Security = sec;
			PermissionsId = permId;
		}
 public ModulePermissionInfo(PermissionInfo permission)
     : this()
 {
     this.ModuleDefID = permission.ModuleDefID;
     this.PermissionCode = permission.PermissionCode;
     this.PermissionID = permission.PermissionID;
     this.PermissionKey = permission.PermissionKey;
     this.PermissionName = permission.PermissionName;
 }
 /// <summary>
 /// 递归加载所有权限
 /// </summary>
 /// <param name="rootPermission"></param>
 /// <param name="permission"></param>
 private void AddPermissions(PermissionInfo rootPermission, Permission permission)
 {
     var permissions = PermissionInfos.Where(p => p.ParentName == rootPermission.Name);
     foreach (PermissionInfo permissionInfo in permissions)
     {
         var childernPermission = permission.CreateChildPermission(permissionInfo.Name,
               new FixedLocalizableString(permissionInfo.DisplayName), permissionInfo.IsGrantedByDefault);
         AddPermissions(permissionInfo, childernPermission);
     }
 }
 public void AddPermission(string principal, PermissionInfo permission)
 {
     if (HasPrincipal(principal))
     {
         if (!permissions.Keys.Contains(this[principal]))
             permissions.Add(this[principal], new PermissionInfoCollection());
         permissions[this[principal]].Add(permission);
     }
     else
         throw new ArgumentException("you must add " + principal + " user!");
 }
Beispiel #5
0
        public void CreatePermission(PermissionInfo permissionInfo)
        {
            if (permissionInfo == null)
            {
                throw new ArgumentNullException("permissionInfo");
            }

            Put(string.Format("permissions/{0}/{1}",
                              SanitiseVhostName(permissionInfo.GetVirtualHostName()),
                              permissionInfo.GetUserName()),
                permissionInfo);
        }
Beispiel #6
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// The ReadManifest method reads the manifest file for the Module compoent.
        /// </summary>
        /// -----------------------------------------------------------------------------
        public override void ReadManifest(XPathNavigator manifestNav)
        {
            // Load the Desktop Module from the manifest
            this._desktopModule = CBO.DeserializeObject <DesktopModuleInfo>(new StringReader(manifestNav.InnerXml));

            // Allow a <component type="Module"> (i.e. a DesktopModule) to have its own friendlyname / description.
            // This allows multiple DesktopModules in one Package, allowing large MVC packages which share one assembly
            // but have many functions.
            if (this._desktopModule.FriendlyName == null || this._desktopModule.FriendlyName.Trim().Length == 0)
            {
                this._desktopModule.FriendlyName = this.Package.FriendlyName;
            }

            if (this._desktopModule.Description == null || this._desktopModule.Description.Trim().Length == 0)
            {
                this._desktopModule.Description = this.Package.Description;
            }

            this._desktopModule.Version            = Globals.FormatVersion(this.Package.Version, "00", 4, ".");
            this._desktopModule.CompatibleVersions = Null.NullString;
            this._desktopModule.Dependencies       = Null.NullString;
            this._desktopModule.Permissions        = Null.NullString;
            if (string.IsNullOrEmpty(this._desktopModule.BusinessControllerClass))
            {
                this._desktopModule.SupportedFeatures = 0;
            }

            this._eventMessage = this.ReadEventMessageNode(manifestNav);

            // Load permissions (to add)
            foreach (XPathNavigator moduleDefinitionNav in manifestNav.Select("desktopModule/moduleDefinitions/moduleDefinition"))
            {
                string friendlyName = Util.ReadElement(moduleDefinitionNav, "friendlyName");
                foreach (XPathNavigator permissionNav in moduleDefinitionNav.Select("permissions/permission"))
                {
                    var permission = new PermissionInfo();
                    permission.PermissionCode = Util.ReadAttribute(permissionNav, "code");
                    permission.PermissionKey  = Util.ReadAttribute(permissionNav, "key");
                    permission.PermissionName = Util.ReadAttribute(permissionNav, "name");
                    ModuleDefinitionInfo moduleDefinition = this._desktopModule.ModuleDefinitions[friendlyName];
                    if (moduleDefinition != null)
                    {
                        moduleDefinition.Permissions.Add(permission.PermissionKey, permission);
                    }
                }
            }

            if (this.Log.Valid)
            {
                this.Log.AddInfo(Util.MODULE_ReadSuccess);
            }
        }
Beispiel #7
0
 private void LinkPermissionInfos(AccessControlServiceContext context, GroupPermission groupPermission, ref List <PermissionInfo> ret)
 {
     try
     {
         if (!groupPermission.IsGranted)
         {
             return;
         }
         var                 gp               = groupPermission;
         PermissionInfo      p                = null;
         PermissionInfo      childP           = null;
         Func <long, string> gpPermissionName = (long id) => (from permission in context.Permissions where permission.PermissionId == id select permission.PermissionName).FirstOrDefault();
         while (gp != null)
         {
             if (p != null)
             {
                 childP = p;
             }
             var permissionName = gpPermissionName(gp.PermissionId);
             p = ret.Any(pi => pi.Name == permissionName) ?
                 ret.First(pi => pi.Name == permissionName) :
                 new PermissionInfo {
                 Name = permissionName, ParentPermission = null
             };
             if (childP != null)
             {
                 childP.ParentPermission = p;
             }
             if (!ret.Any(pi => pi.Name == p.Name))
             {
                 ret.Add(p);
             }
             var parentPermission = (from pp in context.Permissions.Include(x => x.ParentPermission)
                                     where pp.PermissionId == gp.PermissionId
                                     select pp.ParentPermission).SingleOrDefault();
             if (parentPermission != null)
             {
                 gp = (from gg in context.GroupPermissions
                       where gg.PermissionId == parentPermission.PermissionId &&
                       gg.GroupIdentification == gp.GroupIdentification
                       select gg).SingleOrDefault();
             }
             else
             {
                 gp = null;
             }
         }
     }
     catch (Exception e)
     {
     }
 }
        public override void ReadManifest(XPathNavigator manifestNav)
        {
            DesktopModule = CBO.DeserializeObject <DesktopModuleInfo>(new StringReader(manifestNav.InnerXml));
            DesktopModule.FriendlyName = Package.FriendlyName;
            DesktopModule.Description  = Package.Description;
            DesktopModule.Version      = Globals.FormatVersion(Package.Version);
            //DesktopModule.IsPremium = false;
            //DesktopModule.IsAdmin = false;
            DesktopModule.CompatibleVersions = Null.NullString;
            DesktopModule.Dependencies       = Null.NullString;
            DesktopModule.Permissions        = Null.NullString;
            if (string.IsNullOrEmpty(DesktopModule.BusinessControllerClass))
            {
                DesktopModule.SupportedFeatures = 0;
            }
            XPathNavigator eventMessageNav = manifestNav.SelectSingleNode("eventMessage");

            if (eventMessageNav != null)
            {
                EventMessage                  = new EventQueue.EventMessage();
                EventMessage.Priority         = MessagePriority.High;
                EventMessage.ExpirationDate   = DateTime.Now.AddYears(-1);
                EventMessage.SentDate         = System.DateTime.Now;
                EventMessage.Body             = "";
                EventMessage.ProcessorType    = Util.ReadElement(eventMessageNav, "processorType", Log, Util.EVENTMESSAGE_TypeMissing);
                EventMessage.ProcessorCommand = Util.ReadElement(eventMessageNav, "processorCommand", Log, Util.EVENTMESSAGE_CommandMissing);
                foreach (XPathNavigator attributeNav in eventMessageNav.Select("attributes/*"))
                {
                    EventMessage.Attributes.Add(attributeNav.Name, attributeNav.Value);
                }
            }
            foreach (XPathNavigator moduleDefinitionNav in manifestNav.Select("desktopModule/moduleDefinitions/moduleDefinition"))
            {
                string friendlyName = Util.ReadElement(moduleDefinitionNav, "friendlyName");
                foreach (XPathNavigator permissionNav in moduleDefinitionNav.Select("permissions/permission"))
                {
                    PermissionInfo permission = new PermissionInfo();
                    permission.PermissionCode = Util.ReadAttribute(permissionNav, "code");
                    permission.PermissionKey  = Util.ReadAttribute(permissionNav, "key");
                    permission.PermissionName = Util.ReadAttribute(permissionNav, "name");
                    ModuleDefinitionInfo moduleDefinition = DesktopModule.ModuleDefinitions[friendlyName];
                    if (moduleDefinition != null)
                    {
                        moduleDefinition.Permissions.Add(permission.PermissionKey, permission);
                    }
                }
            }
            if (Log.Valid)
            {
                Log.AddInfo(Util.MODULE_ReadSuccess);
            }
        }
Beispiel #9
0
        public PermissionSaveResponse Execute(PermissionSaveRequest request)
        {
            PermissionSaveResponse permissionSaveResponse = new PermissionSaveResponse();

            if (request.PermissionId > 0)
            {
                PermissionInfo permission = ServiceHelper.LoadService <IUserService>().GetPermission(request.PermissionId);
                permission.PermissionName = request.PermissonName;
                permission.Remark         = request.Remark;
                ServiceHelper.LoadService <IUserService>().Update(permission);
            }
            return(permissionSaveResponse);
        }
Beispiel #10
0
        private static void AddTabPermission(TabInfo tab, PermissionInfo permission, int roleId, bool allowed)
        {
            var tpi = new TabPermissionInfo
            {
                PermissionID   = permission.PermissionID,
                PermissionKey  = permission.PermissionKey,
                PermissionName = permission.PermissionName,
                AllowAccess    = allowed,
                RoleID         = roleId
            };

            tab.TabPermissions.Add(tpi);
        }
 public override bool Contains(PermissionInfo permission)
 {
     if (permission == null)
         return false;
     switch(LogicPoint)
     {
         case LogicPoint.AND:
         default:
             return left.Contains(permission) && right.Contains(permission);
         case LogicPoint.OR:
             return left.Contains(permission) || right.Contains(permission);
     }
 }
        /// <summary>
        /// Convert PermissionInfo to Permission.
        /// </summary>
        /// <param name="permissionInfo">Permission info</param>
        /// <returns>Permission</returns>
        public static Permission ToPermission(this PermissionInfo permissionInfo)
        {
            if (permissionInfo is null)
            {
                return(null);
            }

            return(new Permission()
            {
                PermissionId = permissionInfo.PermissionId,
                Name = permissionInfo.Name
            });
        }
Beispiel #13
0
        public void UpdataPermission(List <PermissionInfo> list)
        {
            PermissionInfo p = new PermissionInfo();

            for (var i = 0; i < list.Count; i++)
            {
                p = _permissionRepo.GetSingle(u => u.MenuId == list[i].MenuId && u.RoleId == list[i].RoleId);
                //_permissionRepo.Update(list[i]);
                list[i].Id = p.Id;
            }

            _permissionRepo.UpdateRange(list);
        }
Beispiel #14
0
        public IList <PermissionInfo> GetAllPermissions()
        {
            List <PermissionInfo> lst = new List <PermissionInfo>();
            DataTable             tb  = getAllPermissions();

            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    PermissionInfo info = new PermissionInfo();

                    info.PermissionId   = int.Parse(row[0].ToString());
                    info.PermissionName = row[1].ToString();
                    info.PermissionCode = row[2].ToString();
                    info.Remark         = row[3].ToString();
                    info.DisplayOrder   = int.Parse(row[4].ToString());
                    if (string.IsNullOrEmpty(row[5].ToString()))
                    {
                        info.ParentId = null;
                    }
                    else
                    {
                        info.ParentId = int.Parse(row[5].ToString());
                    }
                    info.Depth = int.Parse(row[6].ToString());

                    lst.Add(info);
                }

                foreach (PermissionInfo info in lst)
                {
                    if (info.ParentId != null)
                    {
                        info.Parent = lst.Where(m => m.PermissionId == info.ParentId).First();
                    }
                }

                foreach (PermissionInfo info1 in lst)
                {
                    foreach (PermissionInfo info2 in lst)
                    {
                        if (info1.PermissionId == info2.ParentId)
                        {
                            info1.Children.Add(info2);
                        }
                    }
                }
            }

            return(lst);
        }
Beispiel #15
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Gets the Enabled status of the permission
        /// </summary>
        /// <param name="objPerm">The permission being loaded</param>
        /// <param name="role">The role</param>
        /// <param name="column">The column of the Grid</param>
        /// -----------------------------------------------------------------------------
        protected override bool GetEnabled(PermissionInfo objPerm, RoleInfo role, int column)
        {
            bool enabled;

            if (InheritViewPermissionsFromTab && column == _ViewColumnIndex)
            {
                enabled = false;
            }
            else
            {
                enabled = !IsImplicitRole(role.PortalID, role.RoleID);
            }
            return(enabled);
        }
Beispiel #16
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Gets the Enabled status of the permission
        /// </summary>
        /// <param name="objPerm">The permission being loaded</param>
        /// <param name="user">The user</param>
        /// <param name="column">The column of the Grid</param>
        /// -----------------------------------------------------------------------------
        protected override bool GetEnabled(PermissionInfo objPerm, UserInfo user, int column)
        {
            bool enabled;

            if (InheritViewPermissionsFromTab && column == _ViewColumnIndex)
            {
                enabled = false;
            }
            else
            {
                enabled = true;
            }
            return(enabled);
        }
Beispiel #17
0
        protected override void AddPermission(PermissionInfo permission, int roleId, string roleName, int userId, string displayName, bool allowAccess)
        {
            var objPermission = new TabPermissionInfo(permission);
            objPermission.TabID = TabID;
            objPermission.RoleID = roleId;
            objPermission.RoleName = roleName;
            objPermission.AllowAccess = allowAccess;
            objPermission.UserID = userId;
            objPermission.DisplayName = displayName;
            _TabPermissions.Add(objPermission, true);

            //Clear Permission List
            _PermissionsList = null;
        }
 public override bool Contains(PermissionInfo permission)
 {
     DefaultPermissionInfo tp = permission as DefaultPermissionInfo;
     if (tp == null)
         return false;
     if (!CompareName(tp))
     {
         return false;
     }
     else
     {
         return CompareAction(tp);
     }
 }
Beispiel #19
0
        private string Edit(HttpContext context)
        {
            //#region 权限处理
            //if (!DataLoadTool.CheckCurrUserPms(PermissionKey.Pms_Permission_EditPermission))
            //{
            //    return "无权编辑权限";
            //}
            //#endregion
            string         jsonData = context.Request["JsonData"];
            PermissionInfo model    = ZentCloud.Common.JSONHelper.JsonToModel <PermissionInfo>(jsonData);
            bool           result   = bllPer.Update(model);

            return(result.ToString().ToLower());
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Gets the Enabled status of the permission
        /// </summary>
        /// <param name="objPerm">The permission being loaded</param>
        /// <param name="role">The role</param>
        /// <param name="column">The column of the Grid</param>
        /// <history>
        ///     [cnurse]    01/13/2006  Created
        /// </history>
        /// -----------------------------------------------------------------------------
        protected override bool GetEnabled(PermissionInfo objPerm, RoleInfo role, int column)
        {
            bool enabled;

            if (InheritViewPermissionsFromTab && column == _ViewColumnIndex)
            {
                enabled = false;
            }
            else
            {
                enabled = role.RoleID != AdministratorRoleId;
            }
            return(enabled);
        }
        public static bool IsPermissionInManifest(Context context, string permission)
        {
            PermissionInfo pi = null;

            try { pi = context.PackageManager.GetPermissionInfo(permission, PackageInfoFlags.Permissions); }
            catch { }

            if (pi == null)
            {
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// Updates a Permission
        /// </summary>
        /// <param name="permission">The permission being updated</param>
        /// <param name="displayName">The user's displayname</param>
        /// <param name="userId">The user's id</param>
        /// <param name="stateKey">The permission state</param>
        protected virtual void UpdatePermission(PermissionInfo permission, string displayName, int userId, string stateKey)
        {
            RemovePermission(permission.PermissionID, int.Parse(Globals.glbRoleNothing), userId);
            switch (stateKey)
            {
            case PermissionTypeGrant:
                AddPermission(permission, int.Parse(Globals.glbRoleNothing), Null.NullString, userId, displayName, true);
                break;

            case PermissionTypeDeny:
                AddPermission(permission, int.Parse(Globals.glbRoleNothing), Null.NullString, userId, displayName, false);
                break;
            }
        }
        /// <summary>
        /// Updates a Permission
        /// </summary>
        /// <param name="permission">The permission being updated</param>
        /// <param name="roleId">Role Id.</param>
        /// <param name="roleName">The name of the role</param>
        /// <param name="stateKey">The permission state</param>
        protected virtual void UpdatePermission(PermissionInfo permission, int roleId, string roleName, string stateKey)
        {
            RemovePermission(permission.PermissionID, roleId, Null.NullInteger);
            switch (stateKey)
            {
            case PermissionTypeGrant:
                AddPermission(permission, roleId, roleName, Null.NullInteger, Null.NullString, true);
                break;

            case PermissionTypeDeny:
                AddPermission(permission, roleId, roleName, Null.NullInteger, Null.NullString, false);
                break;
            }
        }
Beispiel #24
0
        //页面关闭
        private void Ws_Yj_FormClosing(object sender, FormClosingEventArgs e)
        {
            //判断是否有原件管理的权限
            bool permission = PermissionInfo.checkPermission(BZ_Input.TopClassID, PermissionType.原件管理);

            if (permission)
            {
                UI.Input.BZ_Input.tsbtnCKDZAJ.Enabled = false;
                UI.Input.BZ_Input.tsmiCKDZAJ.Enabled  = false;
                UI.Input.BZ_Input.tsbtnSCDZAJ.Enabled = false;
                UI.Input.BZ_Input.tsmiSCDZAJ.Enabled  = false;
            }
            UI.Input.BZ_Input.tsbtnDATZ.Enabled   = false;
            UI.Input.BZ_Input.tsbtnDHTZ.Enabled   = false;
            UI.Input.BZ_Input.tsmiDATZ.Enabled    = false;
            UI.Input.BZ_Input.tsmiDHTZ.Enabled    = false;
            UI.Input.BZ_Input.tsbtnChange.Enabled = true;

            #region 释放委托
            //释放工具栏按钮的委托
            UI.Input.BZ_Input.tsbtnNewRow.Click    -= new EventHandler(btnInputYj_Click);
            UI.Input.BZ_Input.tsbtnDeleteRow.Click -= new EventHandler(tsdelete_Click);
            UI.Input.BZ_Input.tsbtnSX.Click        -= new EventHandler(tssx_Click);
            UI.Input.BZ_Input.tsbtnQXSX.Click      -= new EventHandler(tsqxsx_Click);
            UI.Input.BZ_Input.tsbtnCKDZAJ.Click    -= new EventHandler(tsckdzaj_Click);
            UI.Input.BZ_Input.tsbtnSCDZAJ.Click    -= new EventHandler(tsbtnscdzaj_Click);

            UI.Input.BZ_Input.tsbtnDATZ.Click -= new EventHandler(tsbtnDATZ_Click);
            UI.Input.BZ_Input.tsbtnDHTZ.Click -= new EventHandler(tsbtnDHTZ_Click);

            //释放菜单栏按钮的委托
            UI.Input.BZ_Input.tsmiDelete.Click -= new EventHandler(tsdelete_Click);
            UI.Input.BZ_Input.tsmiSX.Click     -= new EventHandler(tssx_Click);
            UI.Input.BZ_Input.tsmiQXSX.Click   -= new EventHandler(tsqxsx_Click);

            UI.Input.BZ_Input.tsmiCKDZAJ.Click -= new EventHandler(tsckdzaj_Click);
            UI.Input.BZ_Input.tsmiSCDZAJ.Click -= new EventHandler(tsbtnscdzaj_Click);

            UI.Input.BZ_Input.tsmiCopy.Click  -= new EventHandler(tsmiCopy_Click);
            UI.Input.BZ_Input.tsmiCut.Click   -= new EventHandler(tsmiCut_Click);
            UI.Input.BZ_Input.tsmiPaste.Click -= new EventHandler(tsmiPaste_Click);

            UI.Input.BZ_Input.tsmiDATZ.Click -= new EventHandler(tsbtnDATZ_Click);
            UI.Input.BZ_Input.tsmiDHTZ.Click -= new EventHandler(tsbtnDHTZ_Click);
            UI.Input.BZ_Input.tsmiFind.Click -= new EventHandler(tsm查找_Click);

            dgv导航.closeYesNewRowsEventHandler();
            #endregion
        }
Beispiel #25
0
        public override void OnAuthorization(AuthorizationContext filterContext)
        {
            //获取当前的Controller & Action信息
            string ControllerName = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName;
            string ActionName     = filterContext.ActionDescriptor.ActionName;

            if (filterContext.HttpContext.Request.Cookies["SessionId"] != null)
            {
                string _SessionId       = filterContext.HttpContext.Request.Cookies["SessionId"].Value;
                string _UserProfileJson = RedisHelper.ItemGet <string>(_SessionId);
                if (_UserProfileJson != null)
                {
                    //获取用户账号实体
                    _UserProfile = JsonConvert.DeserializeObject <UserProfile>(_UserProfileJson);
                    //角色ID
                    string RoleId = _UserProfile.RoleId;

                    //获取当前Controller & Action的权限ID
                    PermissionInfo _permissionInfo = _IPermissionInfoBLL.Get(ControllerName + "Controller", ActionName);

                    if (_permissionInfo != null)
                    {
                        //权限ID
                        string permissionInfoId = _permissionInfo.Id;

                        //是否包含权限
                        bool isAuthorize = _IRolePermissionBLL.GetModels(
                            x => x.RoleId == RoleId && x.PermissionId == permissionInfoId &&
                            x.Delflag == EnumType.DelflagType.正常 &&
                            x.UsedType == EnumType.UsedType.启用, true, x => x.Delflag == EnumType.DelflagType.正常, "RolePermission").Count() > 0;

                        if (!isAuthorize)
                        {
                            //未授权则跳转到未授权403页面
                            filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Template", action = "Template_403", returnUrl = filterContext.HttpContext.Request.Url, returnMessage = "您无权查看." }));
                            return;
                        }
                    }
                }
                else
                {
                    filterContext.HttpContext.Response.Redirect("/Account/Login?session=false");
                }
            }
            else
            {
                filterContext.HttpContext.Response.Redirect("/Account/Login?session=false");
            }
        }
        /// <summary>
        /// Gets the Enabled status of the permission
        /// </summary>
        /// <param name="objPerm">The permission being loaded</param>
        /// <param name="role">The role</param>
        /// <param name="column">The column of the Grid</param>
        protected override bool GetEnabled( PermissionInfo objPerm, RoleInfo role, int column )
        {
            bool enabled;

            if( role.RoleID == AdministratorRoleId )
            {
                enabled = false;
            }
            else
            {
                enabled = true;
            }

            return enabled;
        }
Beispiel #27
0
        /// <summary>
        /// Gets the Enabled status of the permission
        /// </summary>
        /// <param name="objPerm">The permission being loaded</param>
        /// <param name="role">The role</param>
        /// <param name="column">The column of the Grid</param>
        protected override bool GetEnabled(PermissionInfo objPerm, RoleInfo role, int column)
        {
            bool enabled;

            if (role.RoleID == AdministratorRoleId)
            {
                enabled = false;
            }
            else
            {
                enabled = true;
            }

            return(enabled);
        }
        /// <inheritdoc/>
        protected override void AddPermission(PermissionInfo permission, int roleId, string roleName, int userId, string displayName, bool allowAccess)
        {
            var objPermission = new DesktopModulePermissionInfo(permission);

            objPermission.PortalDesktopModuleID = this.PortalDesktopModuleID;
            objPermission.RoleID      = roleId;
            objPermission.RoleName    = roleName;
            objPermission.AllowAccess = allowAccess;
            objPermission.UserID      = userId;
            objPermission.DisplayName = displayName;
            this._DesktopModulePermissions.Add(objPermission, true);

            // Clear Permission List
            this._PermissionsList = null;
        }
        /// <summary>
        ///     Create a permission
        /// </summary>
        /// <param name="source"></param>
        /// <param name="permissionInfo">The permission to create</param>
        /// <param name="cancellationToken"></param>
        public static void CreatePermission(
            [NotNull] this IManagementClient source,
            [NotNull] PermissionInfo permissionInfo,
            CancellationToken cancellationToken = default
            )
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            source.CreatePermissionAsync(permissionInfo, cancellationToken)
            .GetAwaiter()
            .GetResult();
        }
 private ModulePermissionInfo AddModulePermission(ModuleInfo objModule, PermissionInfo permission, int roleId, int userId, bool allowAccess)
 {
     ModulePermissionInfo objModulePermission = new ModulePermissionInfo();
     objModulePermission.ModuleID = objModule.ModuleID;
     objModulePermission.PermissionID = permission.PermissionID;
     objModulePermission.RoleID = roleId;
     objModulePermission.UserID = userId;
     objModulePermission.PermissionKey = permission.PermissionKey;
     objModulePermission.AllowAccess = allowAccess;
     if (!objModule.ModulePermissions.Contains(objModulePermission))
     {
         objModule.ModulePermissions.Add(objModulePermission);
     }
     return objModulePermission;
 }
Beispiel #31
0
        /// <summary>
        /// 构造权限类别下拉框数据
        /// </summary>
        /// <returns></returns>
        public SelectList GetPermissionType(PermissionInfo info)
        {
            List <PermissionType> list = new List <PermissionType>();

            list.Add(new PermissionType {
                ID = 1, Name = "模块"
            });
            list.Add(new PermissionType {
                ID = 2, Name = "主窗体"
            });
            list.Add(new PermissionType {
                ID = 3, Name = "工具栏"
            });
            return(new SelectList(list, "ID", "Name"));
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Gets the Value of the permission
        /// </summary>
        /// <param name="objPerm">The permission being loaded</param>
        /// <param name="role">The role</param>
        /// <param name="column">The column of the Grid</param>
        /// <param name="defaultState">Default State.</param>
        /// <returns>A Boolean (True or False)</returns>
        /// <history>
        ///     [cnurse]    01/09/2006  Created
        /// </history>
        /// -----------------------------------------------------------------------------
        protected override string GetPermission(PermissionInfo objPerm, RoleInfo role, int column, string defaultState)
        {
            string permission;

            if (role.RoleID == AdministratorRoleId)
            {
                permission = PermissionTypeGrant;
            }
            else
            {
                //Call base class method to handle standard permissions
                permission = base.GetPermission(objPerm, role, column, PermissionTypeNull);
            }
            return(permission);
        }
Beispiel #33
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Gets the Value of the permission
        /// </summary>
        /// <param name="objPerm">The permission being loaded</param>
        /// <param name="user">The role</param>
        /// <param name="column">The column of the Grid</param>
        /// <param name="defaultState">Default State.</param>
        /// <returns>A Boolean (True or False)</returns>
        /// -----------------------------------------------------------------------------
        protected override string GetPermission(PermissionInfo objPerm, UserInfo user, int column, string defaultState)
        {
            string permission;

            if (InheritViewPermissionsFromTab && column == _ViewColumnIndex)
            {
                permission = PermissionTypeNull;
            }
            else
            {
                //Call base class method to handle standard permissions
                permission = base.GetPermission(objPerm, user, column, defaultState);
            }
            return(permission);
        }
        private ModulePermissionInfo AddModulePermission(ModuleInfo objModule, PermissionInfo permission, int roleId, int userId, bool allowAccess)
        {
            ModulePermissionInfo objModulePermission = new ModulePermissionInfo();

            objModulePermission.ModuleID      = objModule.ModuleID;
            objModulePermission.PermissionID  = permission.PermissionID;
            objModulePermission.RoleID        = roleId;
            objModulePermission.UserID        = userId;
            objModulePermission.PermissionKey = permission.PermissionKey;
            objModulePermission.AllowAccess   = allowAccess;
            if (!objModule.ModulePermissions.Contains(objModulePermission))
            {
                objModule.ModulePermissions.Add(objModulePermission);
            }
            return(objModulePermission);
        }
Beispiel #35
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Gets the Value of the permission
        /// </summary>
        /// <param name="objPerm">The permission being loaded</param>
        /// <param name="role">The role</param>
        /// <param name="column">The column of the Grid</param>
        /// <param name="defaultState">Default State.</param>
        /// <returns>A Boolean (True or False)</returns>
        /// -----------------------------------------------------------------------------
        protected override string GetPermission(PermissionInfo objPerm, RoleInfo role, int column, string defaultState)
        {
            string permission;

            if (InheritViewPermissionsFromTab && column == _ViewColumnIndex)
            {
                permission = PermissionTypeNull;
            }
            else
            {
                permission = role.RoleID == AdministratorRoleId
                                ? PermissionTypeGrant
                                : base.GetPermission(objPerm, role, column, defaultState);
            }
            return(permission);
        }
Beispiel #36
0
        /// <summary>
        /// 删除权限定义并同时删除已被引用的数据(TabPermission表)
        /// </summary>
        /// <param name="PermissionID"></param>
        /// <returns></returns>
        public static int DeletePermissionByPermissionID(int PermissionID)
        {
            PermissionInfo pinfo = GetModel(PermissionID);

            if (pinfo != null && pinfo.PermissionID <= 0)
            {
                return(-1);
            }
            int result = Delete("PermissionID=" + PermissionID);

            if (result > 0)
            {
                Delete("TabID=" + pinfo.TabID + " and PermissionID=" + PermissionID);
            }
            return(result);
        }
Beispiel #37
0
        public static int SaveModuleDefinition(ModuleDefinitionInfo moduleDefinition, bool saveChildren, bool clearCache)
        {
            int moduleDefinitionID = moduleDefinition.ModuleDefID;

            if (moduleDefinitionID == Null.NullInteger)
            {
                moduleDefinitionID = dataProvider.AddModuleDefinition(moduleDefinition.DesktopModuleID, moduleDefinition.FriendlyName, moduleDefinition.DefaultCacheTime, UserController.GetCurrentUserInfo().UserID);
            }
            else
            {
                dataProvider.UpdateModuleDefinition(moduleDefinition.ModuleDefID, moduleDefinition.FriendlyName, moduleDefinition.DefaultCacheTime, UserController.GetCurrentUserInfo().UserID);
            }
            if (saveChildren)
            {
                foreach (KeyValuePair <string, PermissionInfo> kvp in moduleDefinition.Permissions)
                {
                    kvp.Value.ModuleDefID = moduleDefinitionID;
                    PermissionController permissionController = new PermissionController();
                    ArrayList            permissions          = permissionController.GetPermissionByCodeAndKey(kvp.Value.PermissionCode, kvp.Value.PermissionKey);
                    if (permissions != null && permissions.Count == 1)
                    {
                        PermissionInfo permission = (PermissionInfo)permissions[0];
                        kvp.Value.PermissionID = permission.PermissionID;
                        permissionController.UpdatePermission(kvp.Value);
                    }
                    else
                    {
                        permissionController.AddPermission(kvp.Value);
                    }
                }
                foreach (KeyValuePair <string, ModuleControlInfo> kvp in moduleDefinition.ModuleControls)
                {
                    kvp.Value.ModuleDefID = moduleDefinitionID;
                    ModuleControlInfo moduleControl = ModuleControlController.GetModuleControlByControlKey(kvp.Value.ControlKey, kvp.Value.ModuleDefID);
                    if (moduleControl != null)
                    {
                        kvp.Value.ModuleControlID = moduleControl.ModuleControlID;
                    }
                    ModuleControlController.SaveModuleControl(kvp.Value, clearCache);
                }
            }
            if (clearCache)
            {
                DataCache.ClearHostCache(true);
            }
            return(moduleDefinitionID);
        }
Beispiel #38
0
        /// <summary>
        /// Актуализация разрешений в RabbitMQ для конкретного пользователя.
        /// </summary>
        /// <param name="user">Пользователь RabbitMQ.</param>
        /// <param name="esbPermissions">Разрешения из шины.</param>
        /// <returns>Асинхронная операция синхронизации разрешений пользователя.</returns>
        private Task SynchronizePermissionsForClient(User user, List <SendingPermission> esbPermissions = null)
        {
            List <SendingPermission> currentEsbPermissions;
            string clientId = user.Name;

            if (esbPermissions == null)
            {
                currentEsbPermissions = _dataService.Query <SendingPermission>(SendingPermission.Views.ServiceBusView).Where(p => p.Client.ID == clientId).ToList();
            }
            else
            {
                currentEsbPermissions = esbPermissions.Where(p => p.Client.ID == clientId).ToList();
            }

            Permission mqPermission = _managementClient.GetPermissionsAsync().Result.Where(p => p.User == clientId && p.Vhost == Vhost.Name).FirstOrDefault();

            if (currentEsbPermissions.Count > 0)
            {
                List <string> rmqPermissionRegex = new List <string>();
                foreach (SendingPermission esbPermission in currentEsbPermissions)
                {
                    rmqPermissionRegex.Add(_namingManager.GetExchangeName(esbPermission.MessageType.ID));
                }

                if (mqPermission == null)
                {
                    return(_managementClient.CreatePermissionAsync(CreatePermissionInfo(user, $"^({string.Join("|", rmqPermissionRegex)})$")));
                }
                else
                {
                    PermissionInfo permissionInfo = CreatePermissionInfo(user, $"^({string.Join("|", rmqPermissionRegex)})$", mqPermission.Read, mqPermission.Configure);
                    return(_managementClient.CreatePermissionAsync(permissionInfo));
                }
            }
            else
            {
                if (mqPermission == null)
                {
                    return(_managementClient.CreatePermissionAsync(CreatePermissionInfo(user)));
                }
                else
                {
                    PermissionInfo permissionInfo = CreatePermissionInfo(user, "^$", mqPermission.Read, mqPermission.Configure);
                    return(_managementClient.CreatePermissionAsync(permissionInfo));
                }
            }
        }
Beispiel #39
0
 public override bool Contains(PermissionInfo permission)
 {
     if (permission is OrgPermission)
     {
         return base.Contains(permission);
     }
     else if (permission is FilePermissionInfo)
     {
         FilePermissionInfo fp = permission as FilePermissionInfo;
         if (fp.Name.IndexOf(RES_TAG) != -1)
         {
             fp = new FilePermissionInfo(fp.Name.Substring(0, fp.Name.IndexOf(RES_TAG)), fp.Action);
             return base.Contains(fp);
         }
         else if (fp.Name.StartsWith(this.name) )
         {
             return (this.RealAction & fp.RealAction) == fp.RealAction;
         }
     }
     return base.Contains(permission);
 }
 protected override bool IsViewPermisison(PermissionInfo permissionInfo)
 {
     return (permissionInfo.PermissionKey == "VIEW");
 }
 protected override bool IsFullControl(PermissionInfo permissionInfo)
 {
     return (permissionInfo.PermissionKey == "EDIT") && PermissionProvider.Instance().SupportsFullControl();
 }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Gets the Value of the permission
 /// </summary>
 /// <param name="objPerm">The permission being loaded</param>
 /// <param name="role">The role</param>
 /// <param name="column">The column of the Grid</param>
 /// <param name="defaultState">Default State.</param>
 /// <returns>A Boolean (True or False)</returns>
 /// -----------------------------------------------------------------------------
 protected override string GetPermission(PermissionInfo objPerm, RoleInfo role, int column, string defaultState)
 {
     string permission;
     if (InheritViewPermissionsFromTab && column == _ViewColumnIndex)
     {
         permission = PermissionTypeNull;
     }
     else
     {
         permission = role.RoleID == AdministratorRoleId 
                         ? PermissionTypeGrant 
                         : base.GetPermission(objPerm, role, column, defaultState);
     }
     return permission;
 }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Gets the Enabled status of the permission
 /// </summary>
 /// <param name="objPerm">The permission being loaded</param>
 /// <param name="user">The user</param>
 /// <param name="column">The column of the Grid</param>
 /// -----------------------------------------------------------------------------
 protected override bool GetEnabled(PermissionInfo objPerm, UserInfo user, int column)
 {
     bool enabled;
     if (InheritViewPermissionsFromTab && column == _ViewColumnIndex)
     {
         enabled = false;
     }
     else
     {
         enabled = true;
     }
     return enabled;
 }
Beispiel #44
0
 /// <summary>
 /// Gets the Enabled status of the permission
 /// </summary>
 /// <param name="objPerm">The permission being loaded</param>
 /// <param name="role">The role</param>
 /// <param name="column">The column of the Grid</param>
 /// <history>
 ///     [cnurse]    01/13/2006  Created
 /// </history>
 protected virtual bool GetEnabled(PermissionInfo objPerm, RoleInfo role, int column)
 {
     return true;
 }
Beispiel #45
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Gets the Value of the permission
 /// </summary>
 /// <param name="objPerm">The permission being loaded</param>
 /// <param name="user">The role</param>
 /// <param name="column">The column of the Grid</param>
 /// <param name="defaultState">Default State.</param>
 /// <returns>A Boolean (True or False)</returns>
 /// <history>
 ///     [cnurse]    01/09/2006  Created
 /// </history>
 /// -----------------------------------------------------------------------------
 protected override string GetPermission(PermissionInfo objPerm, UserInfo user, int column, string defaultState)
 {
     string permission;
     if (InheritViewPermissionsFromTab && column == _ViewColumnIndex)
     {
         permission = PermissionTypeNull;
     }
     else
     {
         //Call base class method to handle standard permissions
         permission = base.GetPermission(objPerm, user, column, defaultState);
     }
     return permission;
 }
Beispiel #46
0
 /// <summary>
 /// Gets the Value of the permission
 /// </summary>
 /// <param name="objPerm">The permission being loaded</param>
 /// <param name="role">The role</param>
 /// <param name="column">The column of the Grid</param>
 /// <history>
 ///     [cnurse]    01/13/2006  Created
 /// </history>
 protected virtual bool GetPermission(PermissionInfo objPerm, RoleInfo role, int column)
 {
     return Convert.ToBoolean(GetPermission(objPerm, role, column, PermissionTypeDeny));
 }
Beispiel #47
0
        protected override void AddPermission(PermissionInfo permission, int roleId, string roleName, int userId, string displayName, bool allowAccess)
        {
            var objPermission = new ModulePermissionInfo(permission);
            objPermission.ModuleID = ModuleID;
            objPermission.RoleID = roleId;
            objPermission.RoleName = roleName;
            objPermission.AllowAccess = allowAccess;
            objPermission.UserID = userId;
            objPermission.DisplayName = displayName;
            _ModulePermissions.Add(objPermission, true);

            //Clear Permission List
            _PermissionsList = null;
        }
Beispiel #48
0
 /// <summary>
 /// Updates a Permission
 /// </summary>
 /// <param name="permission">The permission being updated</param>
 /// <param name="roleId">Rold Id.</param>
 /// <param name="roleName">The name of the role</param>
 /// <param name="allowAccess">The value of the permission</param>
 /// <history>
 ///     [cnurse]    01/12/2006  Created
 /// </history>
 protected virtual void UpdatePermission(PermissionInfo permission, int roleId, string roleName, bool allowAccess)
 {
     if (allowAccess)
     {
         UpdatePermission(permission, roleId, roleName, PermissionTypeGrant);
     }
     else
     {
         UpdatePermission(permission, roleId, roleName, PermissionTypeNull);
     }
 }
Beispiel #49
0
 /// <summary>
 /// Gets the Value of the permission
 /// </summary>
 /// <param name="objPerm">The permission being loaded</param>
 /// <param name="user">The user</param>
 /// <param name="column">The column of the Grid</param>
 /// <param name="defaultState">Default State.</param>
 /// <history>
 ///     [cnurse]    01/13/2006  Created
 /// </history>
 protected virtual string GetPermission(PermissionInfo objPerm, UserInfo user, int column, string defaultState)
 {
     var stateKey = defaultState;
     if (PermissionsList != null)
     {
         foreach (var permission in PermissionsList)
         {
             if (permission.PermissionID == objPerm.PermissionID && permission.UserID == user.UserID)
             {
                 if (permission.AllowAccess)
                 {
                     stateKey = PermissionTypeGrant;
                 }
                 else
                 {
                     stateKey = PermissionTypeDeny;
                 }
                 break;
             }
         }
     }
     return stateKey;
 }
Beispiel #50
0
 /// <summary>
 /// Gets the Value of the permission
 /// </summary>
 /// <param name="objPerm">The permission being loaded</param>
 /// <param name="user">The user</param>
 /// <param name="column">The column of the Grid</param>
 /// <history>
 ///     [cnurse]    01/13/2006  Created
 /// </history>
 protected virtual bool GetPermission(PermissionInfo objPerm, UserInfo user, int column)
 {
     return Convert.ToBoolean(GetPermission(objPerm, user, column, PermissionTypeDeny));
 }
Beispiel #51
0
 /// <summary>
 /// Gets the Value of the permission
 /// </summary>
 /// <param name="objPerm">The permission being loaded</param>
 /// <param name="role">The role</param>
 /// <param name="column">The column of the Grid</param>
 /// <param name="defaultState">Default State.</param>
 /// <history>
 ///     [cnurse]    01/13/2006  Created
 /// </history>
 protected virtual string GetPermission(PermissionInfo objPerm, RoleInfo role, int column, string defaultState)
 {
     string stateKey = defaultState;
     if (PermissionsList != null)
     {
         foreach (PermissionInfoBase permission in PermissionsList)
         {
             if (permission.PermissionID == objPerm.PermissionID && permission.RoleID == role.RoleID)
             {
                 if (permission.AllowAccess)
                 {
                     stateKey = PermissionTypeGrant;
                 }
                 else
                 {
                     stateKey = PermissionTypeDeny;
                 }
                 break;
             }
         }
     }
     return stateKey;
 }
Beispiel #52
0
 /// <summary>
 /// Updates a Permission
 /// </summary>
 /// <param name="permission">The permission being updated</param>
 /// <param name="displayName">The user's displayname</param>
 /// <param name="userId">The user's id</param>
 /// <param name="stateKey">The permission state</param>
 /// <history>
 ///     [cnurse]    01/12/2006  Created
 /// </history>
 protected virtual void UpdatePermission(PermissionInfo permission, string displayName, int userId, string stateKey)
 {
     RemovePermission(permission.PermissionID, int.Parse(Globals.glbRoleNothing), userId);
     switch (stateKey)
     {
         case PermissionTypeGrant:
             AddPermission(permission, int.Parse(Globals.glbRoleNothing), Null.NullString, userId, displayName, true);
             break;
         case PermissionTypeDeny:
             AddPermission(permission, int.Parse(Globals.glbRoleNothing), Null.NullString, userId, displayName, false);
             break;
     }
 }
Beispiel #53
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Gets the Enabled status of the permission
 /// </summary>
 /// <param name="objPerm">The permission being loaded</param>
 /// <param name="user">The user</param>
 /// <param name="column">The column of the Grid</param>
 /// <history>
 ///     [cnurse]    01/13/2006  Created
 /// </history>
 /// -----------------------------------------------------------------------------
 protected override bool GetEnabled(PermissionInfo objPerm, UserInfo user, int column)
 {
     return InheritViewPermissionsFromTab && column != _ViewColumnIndex;
 }
Beispiel #54
0
 /// <summary>
 /// Gets the Enabled status of the permission
 /// </summary>
 /// <param name="objPerm">The permission being loaded</param>
 /// <param name="user">The user</param>
 /// <param name="column">The column of the Grid</param>
 /// <history>
 ///     [cnurse]    01/13/2006  Created
 /// </history>
 protected virtual bool GetEnabled(PermissionInfo objPerm, UserInfo user, int column)
 {
     return true;
 }
Beispiel #55
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Gets the Enabled status of the permission
 /// </summary>
 /// <param name="objPerm">The permission being loaded</param>
 /// <param name="role">The role</param>
 /// <param name="column">The column of the Grid</param>
 /// <history>
 ///     [cnurse]    01/13/2006  Created
 /// </history>
 /// -----------------------------------------------------------------------------
 protected override bool GetEnabled(PermissionInfo objPerm, RoleInfo role, int column)
 {
     bool enabled;
     if (InheritViewPermissionsFromTab && column == _ViewColumnIndex)
     {
         enabled = false;
     }
     else
     {
         if (role.RoleID == AdministratorRoleId)
         {
             enabled = false;
         }
         else
         {
             enabled = true;
         }
     }
     return enabled;
 }
Beispiel #56
0
 /// <summary>
 /// Updates a Permission
 /// </summary>
 /// <param name="permission">The permission being updated</param>
 /// <param name="displayName">The user's displayname</param>
 /// <param name="userId">The user's id</param>
 /// <param name="allowAccess">The value of the permission</param>
 /// <history>
 ///     [cnurse]    01/12/2006  Created
 /// </history>
 protected virtual void UpdatePermission(PermissionInfo permission, string displayName, int userId, bool allowAccess)
 {
     UpdatePermission(permission, displayName, userId, allowAccess ? PermissionTypeGrant : PermissionTypeNull);
 }
Beispiel #57
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Gets the Value of the permission
 /// </summary>
 /// <param name="objPerm">The permission being loaded</param>
 /// <param name="role">The role</param>
 /// <param name="column">The column of the Grid</param>
 /// <param name="defaultState">Default State.</param>
 /// <returns>A Boolean (True or False)</returns>
 /// <history>
 ///     [cnurse]    01/09/2006  Created
 /// </history>
 /// -----------------------------------------------------------------------------
 protected override string GetPermission(PermissionInfo objPerm, RoleInfo role, int column, string defaultState)
 {
     string permission;
     if (InheritViewPermissionsFromTab && column == _ViewColumnIndex)
     {
         permission = PermissionTypeNull;
     }
     else
     {
         if (role.RoleID == AdministratorRoleId)
         {
             permission = PermissionTypeGrant;
         }
         else
         {
             //Call base class method to handle standard permissions
             permission = base.GetPermission(objPerm, role, column, defaultState);
         }
     }
     return permission;
 }
Beispiel #58
0
        protected virtual bool SupportsDenyPermissions(PermissionInfo permissionInfo)
        {
            //to maintain backward compatibility the base implementation must always call the simple parameterless version of this method
#pragma warning disable 612,618
            return SupportsDenyPermissions();
#pragma warning restore 612,618
        }
Beispiel #59
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// returns whether or not the derived grid supports Deny permissions
 /// </summary>
 /// <history>
 ///     [cnurse]    01/09/2006  Created
 /// </history>
 /// -----------------------------------------------------------------------------
 protected override bool SupportsDenyPermissions(PermissionInfo permissionInfo)
 {
     return true;
 }
Beispiel #60
0
 protected virtual void AddPermission(PermissionInfo permission, int roleId, string roleName, int userId, string displayName, bool allowAccess)
 {
 }