示例#1
0
 public PermissionInfo GetPermission(string name, int action = PermissionInfo.NO_ACTION, int type = Profile.FILE_TYPE)
 {
     if (type == Profile.ORG_TYPE)
     {
         OrgPermission orgp = new OrgPermission(name);
         orgp.RealAction = action;
         return orgp;
     }
     else
     {
         FilePermissionInfo fp = new FilePermissionInfo(name);
         fp.RealAction = action;
         return fp;
     }
 }
示例#2
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);
 }
 /// <summary>
 /// 设置指定模块下的共享给其他帐号的共享权限
 /// </summary>
 /// <param name="module">指定分享的模块</param>
 /// <param name="p">动作</param>
 public void SetOtherPrincipalSharedPermission(string module, OtherPrincipalSharedAction action)
 {
     if (SharedPermissionCollection.OtherPrincipalSharedPermissions.ContainsKey(module))
     {
         SharedPermissionCollection.OtherPrincipalSharedPermissions[module].Action = SharedPermissionCollection.ActionMap[action];
     }
     else
     {
         //构造resource资源权限
         FilePermissionInfo fp = new FilePermissionInfo("/" + module + "/**/*", SharedPermissionCollection.ActionMap[action]);
         SharedPermissionCollection.OtherPrincipalSharedPermissions.Add(module, fp);
     }
 }
示例#4
0
 /// <summary>
 /// 创建一个路径匹配的权限并加入到此profile中
 /// </summary>
 /// <param name="path"></param>
 /// <param name="name"></param>
 /// <param name="action"></param>
 public void AddResourcePermission(string path, string name = "", string action = "crwxd")
 {
     FilePermissionInfo fp = new FilePermissionInfo(path, action);
     AddResourcePermission(fp, name);
 }
示例#5
0
 /// <summary>
 /// 保存新增的权限信息
 /// </summary>
 /// <param name="profile"></param>
 /// <param name="success"></param>
 /// <returns></returns>
 private ChangeProfileCmd SaveAdded(Profile profile, out bool success)
 {
     success = true;
     try
     {
         if (this.HasArg(ChangeProfileCmd.ARGS_RES_ADDED))
         {
             IList<PermissionArg> pargs = this.Args.ResAdded is PermissionArg[]
                                          ? ((PermissionArg[])this.Args.ResAdded).ToList()
                                          : this.Args.ResAdded as IList<PermissionArg>;
             FilePermissionInfo[] ps = new FilePermissionInfo[pargs.Count];
             for (int i = 0; i < pargs.Count; i++)
             {
                 ps[i] = new FilePermissionInfo(pargs[i].Path);
                 ps[i].RealAction |= pargs[i].Action;
             }
             Factorys.DaoFactory.GetDAO<IAccessDao>().AddPermission(profile.Id, ps);
             for (int i = 0; i < ps.Length; i++)
             {
                 profile.AddResourcePermission(ps[i], pargs[i].Name);
             }
         }
     }
     catch (Exception e)
     {
         Logger.Error("新增资源权限时发生错误!", e);
         success = false;
     }
     try
     {
         if (this.HasArg(ChangeProfileCmd.ARGS_ORG_ADDED))
         {
             IList<PermissionArg> pargs = this.Args.OrgAdded is PermissionArg[]
                                          ? ((PermissionArg[])this.Args.OrgAdded).ToList()
                                          : this.Args.OrgAdded as IList<PermissionArg>;
             OrgPermission[] ps = new OrgPermission[pargs.Count];
             for (int i = 0; i < pargs.Count; i++)
             {
                 ps[i] = new OrgPermission(pargs[i].Path);
                 ps[i].RealAction |= pargs[i].Action;
             }
             Factorys.DaoFactory.GetDAO<IAccessDao>().AddPermission(profile.Id, ps);
             for (int i = 0; i < ps.Length; i++)
             {
                 profile.AddOrgPermission(ps[i], pargs[i].Name);
             }
         }
     }
     catch (Exception e)
     {
         Logger.Error("新增机构权限时发生错误!", e);
         success = false;
     }
     return this;
 }
 public override PermissionInfo New(string newName)
 {
     FilePermissionInfo clone = new FilePermissionInfo(newName);
     clone.RealAction = this.RealAction;
     return clone;
 }