예제 #1
0
 public void AddRole(role mRole)
 {
     mRole.AppID  = App.AppID;
     RoleSrv.CreateNew(mRole);
     //throw new Exception("This method have not Implement.");
 }
예제 #2
0
 public override void CreateRole(string roleName)
 {
     if (_App == null) return;
     role mRole = RoleSrv.GetByName(roleName, _App.AppID);
     if (mRole == null)
     {
         mRole = new role();
         mRole.AppID = _App.AppID;
         mRole.name = roleName;
         RoleSrv.CreateNew(mRole);
         RoleSrv.CommitChanges();
     }
 }
예제 #3
0
 public void AddDescendant(role r_asc, role r_desc)
 {
     throw new Exception("This method have not Implement.");
 }
예제 #4
0
 public void AddInheritance(role r_asc, role r_desc)
 {
     throw new Exception("This method have not Implement.");
 }
예제 #5
0
 private role Mapping(role mRole)
 {
     role TempRole = null;
     if (mRole.roleid > 0) TempRole = RoleSrv.Getbykey(mRole.roleid);
     else
     {
         TempRole =RoleSrv.GetByName(mRole.name, App.AppID);
     }
     return TempRole;
 }
예제 #6
0
 public void AddActiveRole(user mUser, session mSession, role mRole)
 {
     throw new Exception("This method have not Implement.");
 }
예제 #7
0
 public IList<operation> RoleOperationsOnObject(role mRole, objectRbac mObject)
 {
     role TempRole = Mapping(mRole);
     objectRbac TempObject = Mapping(mObject);
     if(TempRole.AppID != App.AppID || TempObject.AppID != App.AppID) return null ;
     return (from per in TempRole.Permissions where  (per.ObjectRBAC == TempObject) select per.Operation).ToList<operation>();
 }
예제 #8
0
 public IList<permission> RolePermissions(role mRole)
 {
     role TempRole = Mapping(mRole);
     return TempRole.Permissions;
 }
예제 #9
0
        public void RevokePermission(operation mOperation, objectRbac mObject, role mRole)
        {
            role TempRole = Mapping(mRole);
            if (TempRole == null) throw new Exception("Role Does not exist in system.");

            objectRbac tempObject = Mapping(mObject);
            operation tempOperation = Mapping(mOperation);
            if (tempOperation == null || tempObject == null) return;
            //Grant permission
            string hsql = "from permission per where per.ObjectRBAC = :ObjectRBAC AND  per.Operation = :Operation ";

            List<permission> _lst = PermissionSrv.GetbyHQuery(hsql, new SQLParam("ObjectRBAC", tempObject), new SQLParam("ObjectRBAC", tempOperation));
            permission TempPermission = (_lst == null || _lst.Count == 0) ? null : _lst[0];

            if (TempPermission != null)
            {
                if (TempRole.Permissions.Contains(TempPermission))
                {
                    TempRole.Permissions.Remove(TempPermission);
                    RoleSrv.CommitChanges();
                }
            }
        }
예제 #10
0
        public void GrantPermission(objectRbac mObject, operation mOperation, role mRole)
        {
            role TempRole = Mapping(mRole);
            if (TempRole == null) throw new Exception("Role Does not exist in system.");

            objectRbac tempObject = Mapping(mObject);
            operation tempOperation = Mapping(mOperation);

            //Grant permission
            string hsql = "from permission per where per.ObjectRBAC = :ObjectRBAC AND  per.Operation = :Operation ";

            List<permission> _lst = PermissionSrv.GetbyHQuery(hsql, new SQLParam("ObjectRBAC", tempObject), new SQLParam("ObjectRBAC", tempOperation));
            permission TempPermission = (_lst == null || _lst.Count == 0) ? null : _lst[0];
            if (TempPermission == null)
            {
                TempPermission = new permission();
                TempPermission.AppID = App.AppID;
                TempPermission.name = tempObject.name + ":" + tempOperation.name;
                TempPermission.ObjectRBAC = tempObject;
                TempPermission.Operation = tempOperation;
                PermissionSrv.CreateNew(TempPermission);
                TempRole.Permissions.Add(TempPermission);
                RoleSrv.CommitChanges();
            }

            else
            {
                if (!TempRole.Permissions.Contains(TempPermission))
                {
                    TempRole.Permissions.Add(TempPermission);
                    RoleSrv.CommitChanges();
                }
            }
        }
예제 #11
0
 public void DeleteRole(role mRole)
 {
     //mapping Roles
     role TempRole = Mapping(mRole);
     if (TempRole != null)
     {
         RoleSrv.Delete(TempRole);
         RoleSrv.CommitChanges();
     }
 }
예제 #12
0
        public void DeassignUser(user mUser, role mRole)
        {
            user TempUser = Mapping(mUser);
            if (TempUser == null) throw new Exception("User does not exist in system.");

            role TempRole = Mapping(mRole);
            if (TempRole == null) throw new Exception("Role does not exist in system.");

            if (TempUser.Roles.Contains(TempRole)) TempUser.Roles.Remove(TempRole);
            UserSrv.CommitChanges();
        }
예제 #13
0
 public IList<user> AuthorizedUsers(role mRole)
 {
     role TempRole = Mapping(mRole);
     if (TempRole != null)
     {
         return TempRole.Users;
     }
     else return null;
 }