Example #1
0
        public static IPermissionPolicyUser GetAnonymousPermissionPolicyUser(this IPermissionPolicyRole systemRole)
        {
            var optionsAthentication = ((IModelOptionsAuthentication)ApplicationHelper.Instance.Application.Model.Options).Athentication;
            var anonymousUserName    = optionsAthentication.AnonymousAuthentication.AnonymousUser;

            return((IPermissionPolicyUser)systemRole.GetPermissionPolicyUser(anonymousUserName));
        }
        private List <string> GetCodeLinesFromRole(IPermissionPolicyRole role)
        {
            List <string> codeLines = new List <string>();

            if (role != null)
            {
                codeLines.Add($"role.Name = \"{role.Name}\";");
                codeLines.Add($"role.PermissionPolicy = SecurityPermissionPolicy.{role.PermissionPolicy.ToString()};");
                if (role.IsAdministrative)
                {
                    codeLines.Add($"role.IsAdministrative = true;");
                }
                if (role.CanEditModel)
                {
                    codeLines.Add($"role.CanEditModel = true;");
                }
                if (CustomizeCodeLines != null)
                {
                    List <string> customCodeLines = new List <string>();
                    CustomizeCodeLines(this, new CustomizeCodeLinesEventArg(role, customCodeLines));
                    codeLines.AddRange(customCodeLines);
                }
                foreach (IPermissionPolicyTypePermissionObject typePermissionObject in role.TypePermissions)
                {
                    codeLines.AddRange(GetCodeLinesFromTypePermissionObject(typePermissionObject));
                }
                if (role is INavigationPermissions navigationPermissionsRole)
                {
                    foreach (IPermissionPolicyNavigationPermissionObject navigationPermissionObject in navigationPermissionsRole.NavigationPermissions)
                    {
                        string codeLine = GetCodeLine(navigationPermissionObject);
                        if (codeLine != string.Empty)
                        {
                            codeLines.Add(codeLine);
                        }
                    }
                }
                if (role is IActionPermissions actionPermissionsRole)
                {
                    foreach (IPermissionPolicyActionPermissionObject actionPermissionsObject in actionPermissionsRole.ActionPermissions)
                    {
                        string codeLine = GetCodeLine(actionPermissionsObject);
                        if (codeLine != string.Empty)
                        {
                            codeLines.Add(codeLine);
                        }
                    }
                }
            }
            return(codeLines);
        }
Example #3
0
 static IPermissionPolicyObjectPermissionsObject AddObjectPermission(this IPermissionPolicyRole role, Type type, string operations, string criteria, SecurityPermissionState?state)
 => (IPermissionPolicyObjectPermissionsObject)PermissionSettingHelperType
 .Method(nameof(AddObjectPermission), new[] { typeof(IPermissionPolicyRole), typeof(Type), typeof(string), typeof(string), typeof(SecurityPermissionState) }, Flags.StaticPublic)
 .Call(null, role, type, operations, criteria, state);
Example #4
0
 static IPermissionPolicyNavigationPermissionObject AddNavigationPermission(
     this IPermissionPolicyRole role, string itemPath, SecurityPermissionState?state)
 => (IPermissionPolicyNavigationPermissionObject)PermissionSettingHelperType.Method(nameof(AddNavigationPermission),
                                                                                    new [] { typeof(IPermissionPolicyRole), typeof(string), typeof(SecurityPermissionState) }, Flags.StaticPublic)
 .Call(null, role, itemPath, state);
Example #5
0
 static void AddTypePermissionsRecursively(this IPermissionPolicyRole role, Type targetType, string operations, SecurityPermissionState?state)
 => PermissionSettingHelperType
 .Method(nameof(AddTypePermissionsRecursively), new[] { typeof(IPermissionPolicyRole), typeof(Type), typeof(string), typeof(SecurityPermissionState) }, Flags.StaticPublic)
 .Call(null, role, targetType, operations, state);
Example #6
0
 void SetPermissions(IPermissionPolicyRole employersRole)
 {
     employersRole.SetTypePermission <ReportData>(SecurityOperations.ReadOnlyAccess, SecurityPermissionState.Allow);
     ((ISecurityRole)employersRole).CreatePermissionBehaviour(PermissionBehavior.ReadOnlyAccess, (role, info) =>
                                                              ((IPermissionPolicyRole)role).SetTypePermission(info.Type, SecurityOperations.ReadOnlyAccess, SecurityPermissionState.Allow));
 }
 public CustomizeCodeLinesEventArg(IPermissionPolicyRole role, List <string> customCodeLines)
 {
     Role            = role;
     CustomCodeLines = customCodeLines;
 }
 void ICustomPermissionPolicyUser.SetUserRole(IPermissionPolicyRole role)
 {
     Roles.Add((PermissionPolicyRole)role);
 }
Example #9
0
        public static ISecurityUserWithRoles GetPermissionPolicyUser(this IPermissionPolicyRole systemRole, string userName, string passWord = "")
        {
            var objectSpace = XPObjectSpace.FindObjectSpaceByObject(systemRole);

            return(objectSpace.GetUser(userName, passWord, (ISecurityRole)systemRole));
        }
Example #10
0
 public static ISecurityUserWithRoles GetAnonymousPermissionPolicyUser(this IPermissionPolicyRole systemRole, string userName)
 {
     return(systemRole.GetPermissionPolicyUser(userName));
 }