Example #1
0
        //Security Per Process. I.e. on a global level thus being applied to each new Process Instance being started.
        public void ActionRights()
        {
            //Route to get to Action Rights. If Event ID not known.
            Activities activities = ManagementServer.GetProcInstActivities(1); //Process Instance ID

            foreach (Activity activity in activities)
            {
                Events events = ManagementServer.GetActivityEvents(activity.ID);

                foreach (Event ev in events)
                {
                    ActionRights actionRightsToSave = new ActionRights();

                    //Get all Action Rights
                    ActionRights eventActionRights = ManagementServer.GetActionRights(ev.ID);
                    foreach (ActionRight actionRight in eventActionRights)
                    {
                        actionRight.Denied  = false;
                        actionRight.Execute = true;

                        actionRightsToSave.Add(actionRight);
                    }

                    //Save Action Rights
                    ManagementServer.SaveActionRights(actionRightsToSave);
                }
            }
        }
Example #2
0
            public PRIHelper(List <ConsiderWithPRI> ConsiderWithPRIs)
            {
                authorizeList = new List <IConsider>();

                List <ConsiderWithPRI> PriorityList = new List <ConsiderWithPRI>();

                foreach (ConsiderWithPRI considerWithPRI in ConsiderWithPRIs)
                {
                    if (considerWithPRI.consider.CurPriority != ConsiderPriority.Vacancy)
                    {
                        PriorityList.Add(considerWithPRI);
                    }
                }

                PriorityList.Sort(new Comparision());

                foreach (ConsiderWithPRI considerWithPRI in PriorityList)
                {
                    ActionRights needRights = considerWithPRI.consider.NeedRights;

                    bool canAuthorize = true;

                    if ((needRights & ActionRights.Rota) == ActionRights.Rota)
                    {
                        if (RotaAuthorized)
                        {
                            canAuthorize = false;
                        }
                    }
                    if ((needRights & ActionRights.RotaTurret) == ActionRights.RotaTurret)
                    {
                        if (RotaTurretAuthorized)
                        {
                            canAuthorize = false;
                        }
                    }
                    if ((needRights & ActionRights.RotaRader) == ActionRights.RotaRader)
                    {
                        if (RotaRaderAuthorized)
                        {
                            canAuthorize = false;
                        }
                    }
                    if ((needRights & ActionRights.Move) == ActionRights.Move)
                    {
                        if (MoveAuthorized)
                        {
                            canAuthorize = false;
                        }
                    }

                    if (canAuthorize)
                    {
                        AddConsiderAuthorized(considerWithPRI.consider);
                    }
                }
            }
Example #3
0
        /// <summary>
        /// Checks if the user of the current context(session) has the ability to perform the action right on the system.
        /// If this is correct, true is returned, otherwise false.
        /// </summary>
        /// <param name="session">The session the method works on</param>
        /// <param name="actionRightId">Actionright to check. This is a system action right</param>
        /// <returns>True if the user of the current context is allowed to perform the action right on the
        /// system, false otherwise.</returns>
        public static bool HasSystemActionRight(this ISession session, ActionRights actionRightId)
        {
            var actionRights = session.GetSystemActionRights();

            if (actionRights != null && actionRights.Length > 0)
            {
                return(actionRights.Contains((int)actionRightId));
            }

            return(false);
        }
Example #4
0
        /// <summary>
        /// Checks if the user of the current context(session) has the ability to perform the action right on the system.
        /// If this is correct, true is returned, otherwise false.
        /// </summary>
        /// <param name="actionRightID">Actionright to check. This is a system action right</param>
        /// <returns>True if the user of the current context is allowed to perform the action right on the
        /// system, false otherwise.</returns>
        public static bool HasSystemActionRight(ActionRights actionRightID)
        {
            ActionRightCollection actionRights = GetSystemActionRights();

            if (actionRights != null && actionRights.Count > 0)
            {
                // use the FindMatches routine to find all entities which match with the filter on the specified actionrightid
                return(actionRights.FindMatches((ActionRightFields.ActionRightID == (int)actionRightID)).Count > 0);
            }

            return(false);
        }
Example #5
0
        /// <summary>
        /// Gets the forums to which the user has the specified action right.
        /// </summary>
        /// <param name="session">The session the method works on</param>
        /// <param name="actionRightId">The action right ID.</param>
        /// <returns>List of forums IDs</returns>
        public static List <int> GetForumsWithActionRight(this ISession session, ActionRights actionRightId)
        {
            var forumActionRights = session.GetForumsActionRights();

            if (forumActionRights == null)
            {
                return(null);
            }

            var forumIDs = forumActionRights.GetValue((int)actionRightId);

            return(forumIDs == null ? null : forumIDs.ToList());
        }
Example #6
0
        /// <summary>
        /// Gets the forums to which the user has the specified action right.
        /// </summary>
        /// <param name="actionRightID">The action right ID.</param>
        /// <returns>List of forums IDs</returns>
        public static List <int> GetForumsWithActionRight(ActionRights actionRightID)
        {
            // Get the dictionary of ForumActionRights from the session.
            Dictionary <int, List <int> > forumActionRights = GetForumsActionRights();

            if (forumActionRights != null)
            {
                // if there is an forumActionRights dictionary in the session
                List <int> forumIDs;

                // check if the dictionary contains a KeyValuePair with the specified ActionRightID key
                if (forumActionRights.TryGetValue((int)actionRightID, out forumIDs))
                {
                    return(forumIDs);
                }
            }

            return(null);
        }
Example #7
0
            private void AddConsiderAuthorized(IConsider consider)
            {
                ActionRights needRights = consider.NeedRights;

                if ((needRights & ActionRights.Rota) == ActionRights.Rota)
                {
                    RotaAuthorized = true;
                }
                if ((needRights & ActionRights.RotaTurret) == ActionRights.RotaTurret)
                {
                    RotaTurretAuthorized = true;
                }
                if ((needRights & ActionRights.RotaRader) == ActionRights.RotaRader)
                {
                    RotaRaderAuthorized = true;
                }
                if ((needRights & ActionRights.Move) == ActionRights.Move)
                {
                    MoveAuthorized = true;
                }

                authorizeList.Add(consider);
            }
Example #8
0
        /// <summary>
        /// Checks if the user of the current context has the ability to perform the action right given
        /// on the forum given. If this is correct, true is returned, otherwise false.
        /// </summary>
        /// <param name="forumID">Forum to check</param>
        /// <param name="actionRightID">Actionright to check on forum</param>
        /// <returns>True if the user of the current context is allowed to perform the action right on the
        /// forum given, false otherwise.</returns>
        public static bool CanPerformForumActionRight(int forumID, ActionRights actionRightID)
        {
            // Get the dictionary of ForumActionRights from the session.
            Dictionary <int, List <int> > forumActionRights = GetForumsActionRights();

            if (forumActionRights != null)
            {
                // if there is an forumActionRights dictionary in the session
                List <int> forumIDs;

                // check if the dictionary contains a KeyValuePair with the specified ActionRightID key
                if (forumActionRights.TryGetValue((int)actionRightID, out forumIDs))
                {
                    // Check if the List of forum IDs associated with the specified Action Right ID already contains the forumID
                    if (forumIDs.Contains(forumID))
                    {
                        // the list contains the forumID
                        return(true);
                    }
                }
            }

            return(false);
        }
Example #9
0
        /// <summary>
        /// Checks if the user of the current context has the ability to perform the action right given
        /// on the forum given. If this is correct, true is returned, otherwise false.
        /// </summary>
        /// <param name="session">The session the method works on</param>
        /// <param name="forumId">Forum to check</param>
        /// <param name="actionRightId">Actionright to check on forum</param>
        /// <returns>True if the user of the current context is allowed to perform the action right on the
        /// forum given, false otherwise.</returns>
        public static bool CanPerformForumActionRight(this ISession session, int forumId, ActionRights actionRightId)
        {
            var forumActionRights = session.GetForumsActionRights();

            return(forumActionRights != null && forumActionRights.ContainsValue((int)actionRightId, forumId));
        }