Esempio n. 1
0
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();
            CustomSecurityRole   userRole          = CreateUserRole();
            CustomSecurityRole   administratorRole = CreateAdministratorRole();
            PermissionPolicyUser admin             = ObjectSpace.FindObject <PermissionPolicyUser>(new BinaryOperator("UserName", "Admin"));

            if (admin == null)
            {
                admin          = ObjectSpace.CreateObject <PermissionPolicyUser>();
                admin.UserName = "******";
                admin.IsActive = true;
                admin.SetPassword("");
                admin.Roles.Add(administratorRole);
                admin.Save();
            }
            PermissionPolicyUser user = ObjectSpace.FindObject <PermissionPolicyUser>(new BinaryOperator("UserName", "User"));

            if (user == null)
            {
                user          = ObjectSpace.CreateObject <PermissionPolicyUser>();
                user.UserName = "******";
                user.IsActive = true;
                user.SetPassword("");
                user.Roles.Add(userRole);
                user.Save();
            }
        }
Esempio n. 2
0
        private void deaktivateUser()
        {
            PermissionPolicyUser curUser = this.Session.GetObjectByKey <PermissionPolicyUser>(this.Systembenutzer.Oid);

            curUser.IsActive = false;
            curUser.Save();
        }
Esempio n. 3
0
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();
            PermissionPolicyRole adminRole = ObjectSpace.FindObject <PermissionPolicyRole>(
                new BinaryOperator("Name", SecurityStrategy.AdministratorRoleName));

            if (adminRole == null)
            {
                adminRole                  = ObjectSpace.CreateObject <PermissionPolicyRole>();
                adminRole.Name             = SecurityStrategy.AdministratorRoleName;
                adminRole.IsAdministrative = true;
            }
            PermissionPolicyUser adminUser = ObjectSpace.FindObject <PermissionPolicyUser>(
                new BinaryOperator("UserName", "Administrator"));

            if (adminUser == null)
            {
                adminUser          = ObjectSpace.CreateObject <PermissionPolicyUser>();
                adminUser.UserName = "******";
                adminUser.SetPassword("");
                adminUser.Roles.Add(adminRole);
            }
            PermissionPolicyUser user1 = ObjectSpace.FindObject <PermissionPolicyUser>(
                new BinaryOperator("UserName", "Oumaima"));

            if (user1 == null)
            {
                user1          = ObjectSpace.CreateObject <PermissionPolicyUser>();
                user1.UserName = "******";
                // Set a password if the standard authentication type is used.
                user1.SetPassword("");
            }

            // If a user named 'John' does not exist in the database, create this user.
            PermissionPolicyUser user2 = ObjectSpace.FindObject <PermissionPolicyUser>(
                new BinaryOperator("UserName", "John"));

            if (user2 == null)
            {
                user2          = ObjectSpace.CreateObject <PermissionPolicyUser>();
                user2.UserName = "******";
                // Set a password if the standard authentication type is used.
                user2.SetPassword("");
            }

            user1.Save();
            user2.Save();
            ObjectSpace.CommitChanges();

            ObjectSpace.CommitChanges();
        }
Esempio n. 4
0
        //la méthode UpdateDtaBaseAfterUpdateSchema est spécifie pour la code de mise à jour à exécuter
        //aprés la mise à jour de la schéma da la BD
        public override void UpdateDatabaseAfterUpdateSchema()

        {
            base.UpdateDatabaseAfterUpdateSchema();
            // Startégie d'autorisation : détermine le comportement de système de sécurité lorsqu'il n'existe aucune autorisation spécifié
            //pour une membre spcéfique
            //créer une nouvelle instance de la classe binaryOperator



            PermissionPolicyRole adminRole = ObjectSpace.FindObject <PermissionPolicyRole>(
                new BinaryOperator("Name", SecurityStrategy.AdministratorRoleName));

            if (adminRole == null)
            {
                adminRole                  = ObjectSpace.CreateObject <PermissionPolicyRole>();
                adminRole.Name             = SecurityStrategy.AdministratorRoleName;
                adminRole.IsAdministrative = true;
            }
            PermissionPolicyUser adminUser = ObjectSpace.FindObject <PermissionPolicyUser>(
                new BinaryOperator("UserName", "Administrator"));

            if (adminUser == null)
            {
                adminUser          = ObjectSpace.CreateObject <PermissionPolicyUser>();
                adminUser.UserName = "******";
                adminUser.SetPassword("");
                adminUser.Roles.Add(adminRole);
            }
            PermissionPolicyUser user1 = ObjectSpace.FindObject <PermissionPolicyUser>(
                new BinaryOperator("UserName", "oumaima"));

            if (user1 == null)
            {
                user1          = ObjectSpace.CreateObject <PermissionPolicyUser>();
                user1.UserName = "******";
                // Set a password if the standard authentication type is used.
                user1.SetPassword("");
            }
            //la métthode CommitChanges utilisé pour enregistré les changement apportes sur les objets appartenant
            //à l'espace actuelle de la base de données.
            user1.Save();
            ObjectSpace.CommitChanges();
        }
Esempio n. 5
0
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();


            CreateClassLevelObjects();
            CreateMemberLevelObjects();
            CreateObjectLevelObjects();

            PermissionPolicyRole administratorRole = CreateAdministratorRole();

            PermissionPolicyUser userAdmin = ObjectSpace.FindObject <PermissionPolicyUser>(new BinaryOperator("UserName", "Sam"));

            if (userAdmin == null)
            {
                userAdmin          = ObjectSpace.CreateObject <PermissionPolicyUser>();
                userAdmin.UserName = "******";
                userAdmin.IsActive = true;
                userAdmin.SetPassword("");
                userAdmin.Roles.Add(administratorRole);
            }

            PermissionPolicyRole securityDemoRole = CreateSecurityDemoRole();

            PermissionPolicyUser userJohn = ObjectSpace.FindObject <PermissionPolicyUser>(new BinaryOperator("UserName", "John"));

            if (userJohn == null)
            {
                userJohn          = ObjectSpace.CreateObject <PermissionPolicyUser>();
                userJohn.UserName = "******";
                userJohn.IsActive = true;
                //userJohn.Roles.Add(defaultRole);
                userJohn.Roles.Add(securityDemoRole);
                userJohn.Save();
            }

            ObjectSpace.CommitChanges();
        }