コード例 #1
0
        public static SecuritySystemRole AddMemberAccessPermissionFluent <T>(this SecuritySystemRole securityRole, string members, SecurityOperationsFluentExtension securityOperation, string criteria = null)
        {
            if (String.IsNullOrEmpty(members))
            {
                throw new ArgumentNullException(String.Format("Members arguments (Role {0} Type {1} ) is null or empty", securityRole.Name, typeof(T).FullName));
            }

            if (typeof(T).IsInterface)
            {
                foreach (var type in GetListTypesFromInterface(typeof(T), securityRole.GetType()))
                {
                    if (String.IsNullOrEmpty(criteria))
                    {
                        securityRole.AddMemberAccessPermission(type, members, GetDescriptionAttribute(securityOperation));
                    }
                    else
                    {
                        securityRole.AddMemberAccessPermission(type, members, GetDescriptionAttribute(securityOperation), criteria);
                    }
                }

                return(securityRole);
            }

            if (String.IsNullOrEmpty(criteria))
            {
                securityRole.AddMemberAccessPermission <T>(members, GetDescriptionAttribute(securityOperation));
            }
            else
            {
                securityRole.AddMemberAccessPermission <T>(members, GetDescriptionAttribute(securityOperation), criteria);
            }

            return(securityRole);
        }
コード例 #2
0
        private SecuritySystemRole CreateDefaultRole()
        {
            SecuritySystemRole defaultRole = ObjectSpace.FindObject <SecuritySystemRole>(new BinaryOperator("Name", "Default"));

            if (defaultRole == null)
            {
                defaultRole      = ObjectSpace.CreateObject <SecuritySystemRole>();
                defaultRole.Name = "Default";

                defaultRole.AddObjectAccessPermission <SecuritySystemUser>("[Oid] = CurrentUserId()", SecurityOperations.ReadOnlyAccess);
                defaultRole.AddMemberAccessPermission <SecuritySystemUser>("ChangePasswordOnFirstLogon", SecurityOperations.Write);
                defaultRole.AddMemberAccessPermission <SecuritySystemUser>("StoredPassword", SecurityOperations.Write);
                defaultRole.SetTypePermissionsRecursively <SecuritySystemRole>(SecurityOperations.Read, SecuritySystemModifier.Allow);
                defaultRole.SetTypePermissionsRecursively <AuditDataItemPersistent>(SecurityOperations.CRUDAccess, SecuritySystemModifier.Allow);
            }
            return(defaultRole);
        }
コード例 #3
0
        public static SecuritySystemRole AddMemberAccessPermissionFluent(this SecuritySystemRole securityRole, List <Type> typeList, string members, SecurityOperationsFluentExtension securityOperation, string criteria = null)
        {
            if (String.IsNullOrEmpty(members))
            {
                throw new ArgumentNullException(String.Format("Members arguments (EmployeeRole {0} list types ) is null or empty", securityRole.Name));
            }

            foreach (var type in typeList)
            {
                if (type.IsInterface)
                {
                    foreach (var classType in GetListTypesFromInterface(type, securityRole.GetType()))
                    {
                        if (String.IsNullOrEmpty(criteria))
                        {
                            securityRole.AddMemberAccessPermission(classType, members, GetDescriptionAttribute(securityOperation));
                        }
                        else
                        {
                            securityRole.AddMemberAccessPermission(classType, members, GetDescriptionAttribute(securityOperation), criteria);
                        }
                    }
                    continue;
                }

                if (String.IsNullOrEmpty(criteria))
                {
                    securityRole.AddMemberAccessPermission(type, members, GetDescriptionAttribute(securityOperation));
                }
                else
                {
                    securityRole.AddMemberAccessPermission(type, members, GetDescriptionAttribute(securityOperation), criteria);
                }
            }

            return(securityRole);
        }