Exemplo n.º 1
0
 public permission AddPermission(objectRbac mObject, operation mOperation, string PermissionName)
 {
     throw new Exception("This method have not Implement.");
 }
Exemplo n.º 2
0
 private operation Mapping(operation mOperation)
 {
     operation tempOperation;
     if (mOperation.operationid > 0) tempOperation = OperationSrv.Getbykey(mOperation.operationid);
     else
     {
         tempOperation = OperationSrv.GetByName(mOperation.name, App.AppID);
     }
     return tempOperation;
 }
Exemplo n.º 3
0
 public void AddOperation(operation mOperation)
 {
     mOperation.AppID = App.AppID;
     OperationSrv.CreateNew(mOperation);
 }
Exemplo n.º 4
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();
                }
            }
        }
Exemplo n.º 5
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();
                }
            }
        }
Exemplo n.º 6
0
 public void DeleteOperation(operation mOperation)
 {
     operation tempOperation = Mapping(mOperation);
     if (tempOperation != null) OperationSrv.Delete(tempOperation);
     OperationSrv.CommitChanges();
 }
Exemplo n.º 7
0
 public bool CheckAccess(session mSession, operation mOperation, objectRbac mObject)
 {
     throw new Exception("This method have not Implement.");
 }
Exemplo n.º 8
0
        public void InstallObject(string mObject, string[] mOperations)
        {
            if (_App == null) return;
            objectRbac tempObject = ObjectSrv.GetByName(mObject, _App.AppID);
            if (tempObject != null) return;
            tempObject = new objectRbac();
            tempObject.AppID = _App.AppID;
            tempObject.name = mObject;
            ObjectSrv.CreateNew(tempObject);
            foreach (string ope in mOperations)
            {
                operation TempOpe = OperationSrv.GetByName(ope, _App.AppID);
                if (TempOpe == null)
                {
                    TempOpe = new operation();
                    TempOpe.name = ope;
                    TempOpe.AppID = _App.AppID;
                    OperationSrv.CreateNew(TempOpe);
                }

                permission TempPermission = new permission();
                TempPermission.AppID = _App.AppID;
                TempPermission.name = tempObject.name + ":" + TempOpe.name;
                TempPermission.ObjectRBAC = tempObject;
                TempPermission.Operation = TempOpe;
                PermissionSrv.CreateNew(TempPermission);
            }
            PermissionSrv.CommitChanges();
        }