Ejemplo n.º 1
0
        public static void GrandObjectAccessRecursively(this SecuritySystemRoleBase defaultRole)
        {
            Type roleType = defaultRole.GetType();

            foreach (Type type in SecurityStrategy.GetSecuredTypes().Where(type => roleType == type || type.IsAssignableFrom(roleType)))
            {
                defaultRole.AddObjectAccessPermission(type, "[Name]='" + defaultRole.Name + "'", SecurityOperations.ReadOnlyAccess);
            }
        }
Ejemplo n.º 2
0
        public static SecuritySystemTypePermissionObject CreateTypePermission(this SecuritySystemRoleBase systemRole, Type targetType)
        {
            var objectSpace      = XPObjectSpace.FindObjectSpaceByObject(systemRole);
            var permissionObject = objectSpace.CreateObject <SecuritySystemTypePermissionObject>();

            permissionObject.TargetType = targetType;
            systemRole.TypePermissions.Add(permissionObject);
            return(permissionObject);
        }
Ejemplo n.º 3
0
        public static void CreateFullPermissionAttributes(this SecuritySystemRoleBase systemRole, Action <SecuritySystemTypePermissionObject> action = null, bool defaultAllowValues = true)
        {
            var persistentTypes = XafTypesInfo.Instance.PersistentTypes.Where(info => info.FindAttribute <FullPermissionAttribute>() != null);

            foreach (var typeInfo in persistentTypes)
            {
                systemRole.CreateTypePermission(typeInfo.Type, action, defaultAllowValues);
            }
        }
Ejemplo n.º 4
0
        public static void CreatePermissionBehaviour(this SecuritySystemRoleBase systemRole, Enum behaviourEnum, Action <SecuritySystemRoleBase, ITypeInfo> action)
        {
            var typeInfos = XafTypesInfo.Instance.PersistentTypes.Where(info => {
                var permissionBehaviorAttribute = info.FindAttribute <PermissionBehaviorAttribute>();
                return(permissionBehaviorAttribute != null && permissionBehaviorAttribute.Name.Equals(Enum.GetName(behaviourEnum.GetType(), behaviourEnum)));
            });

            foreach (var typeInfo in typeInfos)
            {
                action.Invoke(systemRole, typeInfo);
            }
        }
Ejemplo n.º 5
0
        public static SecuritySystemTypePermissionObject AddNewTypePermission(this SecuritySystemRoleBase role, Type targetType, Action <SecuritySystemTypePermissionObject> action,
                                                                              bool defaultAllowValues = true)
        {
            var permission = AddNewTypePermission(role, targetType);

            permission.AllowDelete   = defaultAllowValues;
            permission.AllowNavigate = defaultAllowValues;
            permission.AllowRead     = defaultAllowValues;
            permission.AllowWrite    = defaultAllowValues;
            permission.AllowCreate   = defaultAllowValues;
            action?.Invoke(permission);
            return(permission);
        }
Ejemplo n.º 6
0
        public static SecuritySystemTypePermissionObject CreateTypePermission(this SecuritySystemRoleBase systemRole, Type targetType, Action <SecuritySystemTypePermissionObject> action,
                                                                              bool defaultAllowValues = true)
        {
            var permission = systemRole.CreateTypePermission(targetType);

            permission.TargetType    = targetType;
            permission.AllowDelete   = defaultAllowValues;
            permission.AllowNavigate = defaultAllowValues;
            permission.AllowRead     = defaultAllowValues;
            permission.AllowWrite    = defaultAllowValues;
            permission.AllowCreate   = defaultAllowValues;
            if (action != null)
            {
                action.Invoke(permission);
            }
            return(permission);
        }
Ejemplo n.º 7
0
 public static SecuritySystemTypePermissionObject CreateTypePermission <TObject>(this SecuritySystemRoleBase systemRole)
 {
     return(CreateTypePermission(systemRole, typeof(TObject)));
 }
Ejemplo n.º 8
0
        public static SecuritySystemTypePermissionObject CreateTypePermission <TObject>(this SecuritySystemRoleBase systemRole, Action <SecuritySystemTypePermissionObject> action, bool defaultAllowValues = true)
        {
            var targetType = typeof(TObject);
            var permission = systemRole.CreateTypePermission <TObject>();

            permission.TargetType    = targetType;
            permission.AllowDelete   = defaultAllowValues;
            permission.AllowNavigate = defaultAllowValues;
            permission.AllowRead     = defaultAllowValues;
            permission.AllowWrite    = defaultAllowValues;
            permission.AllowCreate   = defaultAllowValues;
            action.Invoke(permission);
            return(permission);
        }
Ejemplo n.º 9
0
        public static ISecurityUserWithRoles GetUser(this SecuritySystemRoleBase systemRole, string userName, string passWord = "")
        {
            var objectSpace = XPObjectSpace.FindObjectSpaceByObject(systemRole);

            return(GetUser(objectSpace, userName, passWord, systemRole));
        }
Ejemplo n.º 10
0
 public static void CreateFullPermissionAttributes(this SecuritySystemRoleBase systemRole, Action <SecuritySystemTypePermissionObject> action = null, bool defaultAllowValues = true)
 {
     AddNewFullPermissionAttributes(systemRole, action, defaultAllowValues);
 }
Ejemplo n.º 11
0
 public static SecuritySystemTypePermissionObject AddNewTypePermission <TObject>(this SecuritySystemRoleBase role)
 {
     return(AddNewTypePermission(role, typeof(TObject)));
 }
Ejemplo n.º 12
0
 public static SecuritySystemTypePermissionObject AddNewTypePermission <TObject>(this SecuritySystemRoleBase role, Action <SecuritySystemTypePermissionObject> action, bool defaultAllowValues = true)
 {
     return(AddNewTypePermission(role, typeof(TObject), action, defaultAllowValues));
 }
Ejemplo n.º 13
0
 public static SecuritySystemTypePermissionObject CreateTypePermission(this SecuritySystemRoleBase systemRole, Type targetType, Action <SecuritySystemTypePermissionObject> action,
                                                                       bool defaultAllowValues = true)
 {
     return(AddNewTypePermission(systemRole, targetType, action, defaultAllowValues));
 }
Ejemplo n.º 14
0
 public static SecuritySystemTypePermissionObject CreateTypePermission(this SecuritySystemRoleBase role, Type targetType)
 {
     return(AddNewTypePermission(role, targetType));
 }