Exemplo n.º 1
0
 public string MessageNotAuthorized(string activity, ZOperations operation)
 {
     return(String.Format(SecurityActivityResources.ActivityOperationNotAuthorized,
                          activity,
                          SecurityHelper.GetSecurityOperationName(operation),
                          AuthenticationManager.UserName));
 }
Exemplo n.º 2
0
        public bool IsAuthorized(string activity, ZOperations operation)
        {
            if (AuthenticationManager.IsAdministrator)
            {
                return(true);
            }

            bool result = false;

            if (!String.IsNullOrEmpty(activity))
            {
                string operationAcronym = SecurityHelper.GetSecurityOperationAcronym(operation);

                IGenericRepository <ActivityRole> repositoryActivityRole = UnitOfWork.GetRepository <ActivityRole>();
                IGenericRepository <EasyLOB.Activity.Data.Activity> repositoryActivity = UnitOfWork.GetRepository <EasyLOB.Activity.Data.Activity>();
                IGenericRepository <UserRole> repositoryUserRole = UnitOfWork.GetRepository <UserRole>();

                IQueryable <ActivityRole> activityRoles = GetActivityRoles(activity);
                foreach (ActivityRole activityRole in activityRoles.ToList())
                {
                    if (activityRole.Operations.ToUpper().Contains(operationAcronym))
                    {
                        result = true;
                        break;
                    }
                }
            }

            return(result);
        }
Exemplo n.º 3
0
        public bool IsAuthorized(string activity, ZOperations operation, ZOperationResult operationResult)
        {
            bool result = IsAuthorized(activity, operation);

            if (!result)
            {
                operationResult.ErrorMessage = MessageNotAuthorized(activity, operation);
            }

            return(result);
        }
Exemplo n.º 4
0
        private void InitialiseMachine(byte[] memory)
        {
            Console.WriteLine("Initialising ZMachine");
            _restartState = (byte[])memory.Clone();
            _zMemory      = new ZMemory(memory, () => InitialiseMachine(_restartState));
            _zOperations  = new ZOperations(_io, _fileIo, _zMemory);

            _zMemory.Stack.Push(new ZStackFrame {
                PC = _zMemory.Header.Pc
            });
        }
Exemplo n.º 5
0
        /// <summary>
        /// Get name from operation.
        /// </summary>
        /// <param name="operation"></param>
        /// <returns></returns>
        public static string GetSecurityOperationName(ZOperations operation)
        {
            string result = "";

            try
            {
                int index = (int)operation;
                result = OperationNames[index];
            }
            catch
            {
            }

            return(result);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Get operation from name.
        /// </summary>
        /// <param name="name">Name</param>
        /// <returns></returns>
        public static ZOperations GetSecurityOperationByName(string name)
        {
            ZOperations result = ZOperations.None;

            try
            {
                int index = Array.IndexOf(OperationNames, name);
                if (index > 0)
                {
                    result = (ZOperations)index;
                }
            }
            catch
            {
            }

            return(result);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Get operation from acronym.
        /// </summary>
        /// <param name="acronym">Acronym</param>
        /// <returns></returns>
        public static ZOperations GetSecurityOperationByAcronym(string acronym)
        {
            ZOperations result = ZOperations.None;

            try
            {
                int index = Array.IndexOf(OperationAcronyms, acronym);
                if (index > 0)
                {
                    result = (ZOperations)index;
                }
            }
            catch
            {
            }

            return(result);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Get "Is Operation" from activity operations.
        /// </summary>
        /// <param name="activityOperations">Activity operations</param>
        /// <param name="operation">Operation</param>
        /// <returns></returns>
        public static bool GetIsSecurityOperation(ZActivityOperations activityOperations, ZOperations operation)
        {
            bool result = false;

            switch (operation)
            {
            case ZOperations.Index:
                result = activityOperations.IsIndex;
                break;

            case ZOperations.Search:
                result = activityOperations.IsSearch;
                break;

            case ZOperations.Create:
                result = activityOperations.IsCreate;
                break;

            case ZOperations.Read:
                result = activityOperations.IsRead;
                break;

            case ZOperations.Update:
                result = activityOperations.IsUpdate;
                break;

            case ZOperations.Delete:
                result = activityOperations.IsDelete;
                break;

            case ZOperations.Export:
                result = activityOperations.IsExport;
                break;

            case ZOperations.Execute:
                result = activityOperations.IsExecute;
                break;
            }

            return(result);
        }
 public bool IsAuthorized(string activity, ZOperations operation, ZOperationResult operationResult)
 {
     return(true);
 }
Exemplo n.º 10
0
 public string MessageNotAuthorized(string activity, ZOperations operation)
 {
     return("");
 }