Example #1
0
        private void AgregarPermiso(Rol rol, RolParametros parametros, ReflectionClassInfo RefInfo)
        {
            SecuritySystemTypePermissionObject PermisoDeObjeto = ObjectSpace.CreateObject <SecuritySystemTypePermissionObject>();

            PermisoDeObjeto.TargetType = RefInfo.ClassType;
            if (parametros.Leer)
            {
                PermisoDeObjeto.AllowRead = true;
            }
            if (parametros.Escribir)
            {
                PermisoDeObjeto.AllowWrite = true;
            }
            if (parametros.Crear)
            {
                PermisoDeObjeto.AllowCreate = true;
            }
            if (parametros.Borrar)
            {
                PermisoDeObjeto.AllowDelete = true;
            }
            if (parametros.Navegar)
            {
                PermisoDeObjeto.AllowNavigate = true;
            }
            rol.TypePermissions.Add(PermisoDeObjeto);
        }
Example #2
0
        private void CrearPermisos(Session LocalSesion, ICollection TodasLasClasesPersistentes, Rol rol, bool BorrarPermisos)
        {
            RolParametros parametros = (RolParametros)_VistaPopup.CurrentObject;

            if (BorrarPermisos)
            {
                QuitarPermisos(rol);
            }
            ReflectionClassInfo RefInfo = null;

            foreach (System.Object item in TodasLasClasesPersistentes)
            {
                RefInfo = item as ReflectionClassInfo;
                if (ReferenceEquals(null, RefInfo))
                {
                    continue;
                }
                if (!(RefInfo.FullName.StartsWith("DevExpress") || RefInfo.ClassType.Name.StartsWith("RolParametros") || RefInfo.FullName.EndsWith("TextMessage") ||
                      RefInfo.ClassType.Name.StartsWith("Entidad") || RefInfo.FullName.EndsWith("Parameters")))
                {
                    Boolean faltante = true;
                    foreach (SecuritySystemTypePermissionObject p in rol.TypePermissions)
                    {
                        if (p.TargetType.Name == RefInfo.ClassType.Name)
                        {
                            faltante = false;
                            break;
                        }
                    }
                    if (faltante)
                    {
                        if (RefInfo.ClassType.Name.StartsWith("Usuario"))
                        {
                            rol.AddObjectAccessPermission <Usuario>("[Oid] = CurrentUserId()", SecurityOperations.ReadOnlyAccess);
                            rol.AddMemberAccessPermission <Usuario>("ChangePasswordOnFirstLogon", SecurityOperations.Write);
                            rol.AddMemberAccessPermission <Usuario>("StoredPassword", SecurityOperations.Write);
                        }
                        else if (RefInfo.ClassType.Name.StartsWith("Rol"))
                        {
                            rol.SetTypePermissionsRecursively <Rol>(SecurityOperations.Read, SecuritySystemModifier.Allow);
                        }
                        else
                        if (!parametros.RolVacio)
                        {
                            AgregarPermiso(rol, parametros, RefInfo);
                        }
                    }
                }
            }
        }
Example #3
0
        private void GenerarPerfil_Execute(object sender, PopupWindowShowActionExecuteEventArgs e)
        {
            RolParametros parametros = (RolParametros)_VistaPopup.CurrentObject;

            Rol rol = (Rol)e.CurrentObject;

            rol.SetTypePermissionsRecursively <ModelDifference>(SecurityOperations.ReadWriteAccess, SecuritySystemModifier.Allow);
            rol.SetTypePermissionsRecursively <ModelDifferenceAspect>(SecurityOperations.ReadWriteAccess, SecuritySystemModifier.Allow);

            Session     LocalSesion = ((XPObjectSpace)this.ObjectSpace).Session;
            ICollection TodasLasClasesPersistentes = LocalSesion.Dictionary.Classes;

            CrearPermisos(LocalSesion, TodasLasClasesPersistentes, rol, false);
            if (this.ObjectSpace.IsModified)
            {
                this.ObjectSpace.CommitChanges();
            }
        }