diff --git a/MySQL_conf_pbx/test1/db_asterisk/security.sql b/MySQL_conf_pbx/test1/db_asterisk/security.sql new file mode 100644 index 0000000..47c5b10 --- /dev/null +++ b/MySQL_conf_pbx/test1/db_asterisk/security.sql @@ -0,0 +1,94 @@ +USE asterisk_db; + +SHOW DATABASES; + +SHOW TABLES; + + +SELECT * FROM `ps_endpoints`; + +DELETE FROM `ps_endpoints` WHERE `id` = '1004'; + +SELECT * FROM `extensions_table`; +DESCRIBE `extensions_table`; + +ALTER TABLE `extensions_table` +ADD CONSTRAINT `extension_table_unique_val_two_check` UNIQUE (`exten`, `appdata`); + + +ALTER TABLE `extensions_table` +DROP INDEX `extension_table_unique_val`; + + +ALTER TABLE `extensions_table` +ADD CONSTRAINT `extension_table_unique_val` UNIQUE (`exten`, `appdata`, `priority`); + +DELETE FROM `extensions_table` WHERE priority = 4 and exten = "1005" ; +DELETE FROM `extensions_table` WHERE exten = "1005" OR exten = "1004"; + +DELETE FROM `ps_endpoints` WHERE id = "1004" OR id = "1005"; +DELETE FROM `extensions_table` WHERE exten = "1004" OR exten = "1005"; + +DELETE FROM `ps_auths` WHERE id = "1004" OR id = "1005"; +DELETE FROM `ps_aors` WHERE id = "1004" OR id = "1005"; + +SELECT * FROM `extensions_table` WHERE app = "Dial"; +SELECT * FROM extensions_table WHERE context = 'default' AND exten = '1005'; +SELECT * FROM extensions_table WHERE exten = '1004' AND context = 'default'; + + + +SELECT * FROM `ps_endpoints`; +SELECT * FROM `extensions_table`; +-- +SELECT * FROM ps_auths; +SELECT * FROM ps_aors; +DESCRIBE `ps_auths`; +DESCRIBE `ps_aors`; +DESCRIBE `extensions_table`; + +INSERT INTO `ps_aors`(`id`,`max_contacts`) VALUES ("1004", 1); +INSERT INTO `ps_auths`(`id`, `auth_type`, `username`, `password`, `md5_cred`, `realm`) VALUES("1004", "userpass", "1004", "12345", null, null); + + + + +-- USER ROLES ROLE GOES HERE +CREATE TABLE `roles`( +`role_id` INTEGER NOT NULL AUTO_INCREMENT, +`role_name` VARCHAR(20) UNIQUE NOT NULL, +CONSTRAINT `roles_pk` PRIMARY KEY (`role_id`) +)ENGINE = 'Innodb' AUTO_INCREMENT = 1, DEFAULT CHARSET 'latin1'; + +DESCRIBE `roles`; + + +CREATE TABLE `user_roles`( +`u_id` INTEGER NOT NULL, +`role_id` INTEGER NOT NULL, +CONSTRAINT `user_roles_pk` PRIMARY KEY(`u_id`,`role_id`) +)ENGINE = 'Innodb' AUTO_INCREMENT = 1, DEFAULT CHARSET 'latin1'; + + +-- foreign key to be added to this table in alter table form +CREATE TABLE `user`( +`u_id` INTEGER NOT NULL AUTO_INCREMENT, +`user_name` VARCHAR(70) UNIQUE NOT NULL, +`password` VARCHAR(68) NOT NULL, +-- fk to uder_account +CONSTRAINT `user_table_pk` PRIMARY KEY(`u_id`) +)ENGINE = 'Innodb', AUTO_INCREMENT = 1, DEFAULT CHARSET 'latin1'; + + +ALTER TABLE `user_roles` ADD CONSTRAINT `user_lones_U_fk_to_user` FOREIGN KEY(`u_id`) REFERENCES `user`(`u_id`); +ALTER TABLE `user_roles` ADD CONSTRAINT `user_lones_R_fk_to_user` FOREIGN KEY(`role_id`) REFERENCES `roles`(`role_id`); +DESC `user_roles`; + + +INSERT `roles`(`role_name`) VALUES ('ROLE_admin'); + + + + + + diff --git a/MySQL_conf_pbx/test1/mariadb_data/asterisk_db/roles.frm b/MySQL_conf_pbx/test1/mariadb_data/asterisk_db/roles.frm new file mode 100644 index 0000000..9ee21f9 Binary files /dev/null and b/MySQL_conf_pbx/test1/mariadb_data/asterisk_db/roles.frm differ diff --git a/MySQL_conf_pbx/test1/mariadb_data/asterisk_db/roles.ibd b/MySQL_conf_pbx/test1/mariadb_data/asterisk_db/roles.ibd new file mode 100644 index 0000000..8b3f545 Binary files /dev/null and b/MySQL_conf_pbx/test1/mariadb_data/asterisk_db/roles.ibd differ diff --git a/MySQL_conf_pbx/test1/mariadb_data/asterisk_db/user.frm b/MySQL_conf_pbx/test1/mariadb_data/asterisk_db/user.frm new file mode 100644 index 0000000..bb1d28e Binary files /dev/null and b/MySQL_conf_pbx/test1/mariadb_data/asterisk_db/user.frm differ diff --git a/MySQL_conf_pbx/test1/mariadb_data/asterisk_db/user.ibd b/MySQL_conf_pbx/test1/mariadb_data/asterisk_db/user.ibd new file mode 100644 index 0000000..8b3f545 Binary files /dev/null and b/MySQL_conf_pbx/test1/mariadb_data/asterisk_db/user.ibd differ diff --git a/MySQL_conf_pbx/test1/mariadb_data/asterisk_db/user_roles.frm b/MySQL_conf_pbx/test1/mariadb_data/asterisk_db/user_roles.frm new file mode 100644 index 0000000..1a6a76c Binary files /dev/null and b/MySQL_conf_pbx/test1/mariadb_data/asterisk_db/user_roles.frm differ diff --git a/MySQL_conf_pbx/test1/mariadb_data/asterisk_db/user_roles.ibd b/MySQL_conf_pbx/test1/mariadb_data/asterisk_db/user_roles.ibd new file mode 100644 index 0000000..8b3f545 Binary files /dev/null and b/MySQL_conf_pbx/test1/mariadb_data/asterisk_db/user_roles.ibd differ diff --git a/MySQL_conf_pbx/test1/mariadb_data/ddl_recovery.log b/MySQL_conf_pbx/test1/mariadb_data/ddl_recovery.log index 5e30b6d..434b85c 100644 Binary files a/MySQL_conf_pbx/test1/mariadb_data/ddl_recovery.log and b/MySQL_conf_pbx/test1/mariadb_data/ddl_recovery.log differ diff --git a/MySQL_conf_pbx/test1/mariadb_data/ib_logfile0 b/MySQL_conf_pbx/test1/mariadb_data/ib_logfile0 index c39bc67..a33bd14 100644 Binary files a/MySQL_conf_pbx/test1/mariadb_data/ib_logfile0 and b/MySQL_conf_pbx/test1/mariadb_data/ib_logfile0 differ diff --git a/MySQL_conf_pbx/test1/springCezenPBX/src/main/java/com/example/cezenPBX/config/CezenLoginSecurityChain.java b/MySQL_conf_pbx/test1/springCezenPBX/src/main/java/com/example/cezenPBX/config/CezenLoginSecurityChain.java new file mode 100644 index 0000000..b214d24 --- /dev/null +++ b/MySQL_conf_pbx/test1/springCezenPBX/src/main/java/com/example/cezenPBX/config/CezenLoginSecurityChain.java @@ -0,0 +1,11 @@ +package com.example.cezenPBX.config; + + +import org.springframework.context.annotation.Configuration; + +// this class will handel the routs that are protected and +// allow spring security to accept login details from our custom login page +@Configuration +public class CezenLoginSecurityChain { + +} diff --git a/MySQL_conf_pbx/test1/springCezenPBX/src/main/java/com/example/cezenPBX/entity/user/Role.java b/MySQL_conf_pbx/test1/springCezenPBX/src/main/java/com/example/cezenPBX/entity/user/Role.java new file mode 100644 index 0000000..154e0d9 --- /dev/null +++ b/MySQL_conf_pbx/test1/springCezenPBX/src/main/java/com/example/cezenPBX/entity/user/Role.java @@ -0,0 +1,64 @@ +package com.example.cezenPBX.entity.user; + +import jakarta.persistence.*; + +import java.util.Collection; + +@Entity +@Table(name = "role") +final public class Role { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "role_id") + private int id; + + //remember ROLE_ + @Column(name = "role_name") + private String role; + + //all employees under this role + @ManyToMany( + fetch = FetchType.LAZY, + cascade = { + //The detach operation removes the entity from the persistent context. When we use CascadeType.DETACH, the child entity will also get removed from the persistent context. + CascadeType.DETACH, + CascadeType.MERGE, + CascadeType.PERSIST, + CascadeType.REFRESH, + } + //cascade = CascadeType.ALL + ) + @JoinTable( + name = "user_roles", + joinColumns = @JoinColumn(name = "u_id"), + inverseJoinColumns = @JoinColumn(name = "role_id") + ) + private Collection employees; + + public Role(){} + + public Role(String role) { + this.role = role; + } + + public int getId() { + return id; + } + + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + public Collection getEmployees() { + return employees; + } + + public void setEmployees(Collection employees) { + this.employees = employees; + } +} diff --git a/MySQL_conf_pbx/test1/springCezenPBX/src/main/java/com/example/cezenPBX/entity/user/UserEntity.java b/MySQL_conf_pbx/test1/springCezenPBX/src/main/java/com/example/cezenPBX/entity/user/UserEntity.java new file mode 100644 index 0000000..c10873b --- /dev/null +++ b/MySQL_conf_pbx/test1/springCezenPBX/src/main/java/com/example/cezenPBX/entity/user/UserEntity.java @@ -0,0 +1,77 @@ +package com.example.cezenPBX.entity.user; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import jakarta.persistence.*; + +import java.util.Collection; +import java.util.HashSet; + +@Entity +@Table(name = "user") +final public class UserEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "u_id") + private int id; + + @Column(name = "user_name") + private String userName; + + @JsonIgnore + @Column(name = "password") + private String password; + + //ROLE + @ManyToMany( + fetch = FetchType.LAZY, + cascade = { + //The detach operation removes the entity from the persistent context. When we use CascadeType.DETACH, the child entity will also get removed from the persistent context. + CascadeType.DETACH, + CascadeType.MERGE, + CascadeType.PERSIST, + CascadeType.REFRESH, + } + //cascade = CascadeType.ALL + ) + @JoinTable( + name = "user_roles", + joinColumns = @JoinColumn(name = "u_id"), + inverseJoinColumns = @JoinColumn(name = "role_id") + ) + private Collection roles; + + + public UserEntity(){} + + public UserEntity(String userName, String password) { + this.userName = userName; + this.password = password; + } + public int getId() { + return id; + } + public String getUserName() { + return userName; + } + public void setUserName(String userName) { + this.userName = userName; + } + public String getPassword() { + return password; + } + public void setPassword(String password) { + this.password = password; + } + public Collection getRoles() { + return roles; + } + + public void setARole(Role role){ + if(this.roles == null){ + this.roles = new HashSet(); + } + + this.roles.add(role); + } +}