コード例 #1
0
        /// <exclude />
        public static IEnumerable <UserGroupPermissionDefinition> GetUserGroupPermissionDefinitions(Guid userGroupId)
        {
            if (userGroupId == Guid.Empty)
            {
                throw new ArgumentException("Guid value is empty", "userGroupId");
            }

            IEnumerable <UserGroupPermissionDefinition> userPermissionDefinitions = UserGroupPermissionDefinitionProviderPluginFacade.GetPermissionsByUserGroup(userGroupId);

            var result = new List <UserGroupPermissionDefinition>();

            foreach (UserGroupPermissionDefinition userPermissionDefinition in userPermissionDefinitions)
            {
                var entityToken = userPermissionDefinition.EntityToken;
                if (entityToken == null)
                {
                    continue;
                }

                if (!entityToken.IsValid())
                {
                    if (UserPermissionDefinitionProviderPluginFacade.CanAlterDefinitions)
                    {
                        Log.LogWarning("PermissionTypeFacade", "System removing invalid permission setting for user group '{0}' because the data entity token could not be validated. Token was '{1}'.", userGroupId, userPermissionDefinition.SerializedEntityToken);
                        UserGroupPermissionDefinitionProviderPluginFacade.RemoveUserGroupPermissionDefinition(userGroupId, userPermissionDefinition.SerializedEntityToken);
                    }
                    continue;
                }

                result.Add(userPermissionDefinition);
            }

            return(result);
        }
コード例 #2
0
        /// <exclude />
        public static void SetUserGroupPermissionDefinition(UserGroupPermissionDefinition userGroupPermissionDefinition)
        {
            Verify.ArgumentNotNull(userGroupPermissionDefinition, "userGroupPermissionDefinition");

            if (userGroupPermissionDefinition.EntityToken is NoSecurityEntityToken)
            {
                return;
            }

            if (userGroupPermissionDefinition.PermissionTypes.Contains(PermissionType.ClearPermissions) &&
                (userGroupPermissionDefinition.PermissionTypes.Count() > 1))
            {
                throw new ArgumentException(string.Format("The permission type '{0}' may not be used with other permission types", PermissionType.ClearPermissions));
            }

            Verify.That(UserPermissionDefinitionProviderPluginFacade.CanAlterDefinitions, "The user permission definition provider does not support altering user permission defintions");

            EntityTokenCacheFacade.ClearCache();

            UserGroupPermissionDefinitionProviderPluginFacade.SetUserGroupPermissionDefinition(userGroupPermissionDefinition);
        }
コード例 #3
0
        /// <exclude />
        public static void RemoveUserPermissionDefinition(Guid userGroupId, EntityToken entityToken)
        {
            if (entityToken == null)
            {
                throw new ArgumentNullException("entityToken");
            }

            if ((entityToken is NoSecurityEntityToken))
            {
                return;
            }

            if (!UserPermissionDefinitionProviderPluginFacade.CanAlterDefinitions)
            {
                throw new InvalidOperationException("The user permission definition provider does not support altering user permission defintions");
            }

            string serializedEntityToken = EntityTokenSerializer.Serialize(entityToken);

            EntityTokenCacheFacade.ClearCache();

            UserGroupPermissionDefinitionProviderPluginFacade.RemoveUserGroupPermissionDefinition(userGroupId, serializedEntityToken);
        }