From 80a5460dafd0c858d21367d692bb792adaaeffd5 Mon Sep 17 00:00:00 2001 From: Antt02 Date: Tue, 20 Feb 2024 15:59:31 +0100 Subject: [PATCH 1/4] Created Admin class --- src/main/java/cat/udl/eps/softarch/demo/domain/Admin.java | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 src/main/java/cat/udl/eps/softarch/demo/domain/Admin.java diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/Admin.java b/src/main/java/cat/udl/eps/softarch/demo/domain/Admin.java new file mode 100644 index 00000000..8abad35a --- /dev/null +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/Admin.java @@ -0,0 +1,4 @@ +package cat.udl.eps.softarch.demo.domain; + +public class Admin { +} From 37ba3df1c0a6800b909ac57bff9dd7a7e7a710a9 Mon Sep 17 00:00:00 2001 From: Antt02 Date: Tue, 20 Feb 2024 16:41:46 +0100 Subject: [PATCH 2/4] changed Admin implementation to extend UriEntity --- .../java/cat/udl/eps/softarch/demo/domain/Admin.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/Admin.java b/src/main/java/cat/udl/eps/softarch/demo/domain/Admin.java index 8abad35a..5832287f 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/domain/Admin.java +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/Admin.java @@ -1,4 +1,13 @@ package cat.udl.eps.softarch.demo.domain; -public class Admin { +import jakarta.persistence.Id; + +public class Admin extends UriEntity{ + @Id + Long id; + + @Override + public Long getId() { + return id; + } } From 28b0e98e3acde0ff857f62d57660eb9c71d456a0 Mon Sep 17 00:00:00 2001 From: Ant Date: Thu, 22 Feb 2024 15:19:14 +0100 Subject: [PATCH 3/4] extends user + added anotations --- .../cat/udl/eps/softarch/demo/domain/Admin.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/Admin.java b/src/main/java/cat/udl/eps/softarch/demo/domain/Admin.java index 5832287f..88d9c643 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/domain/Admin.java +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/Admin.java @@ -1,13 +1,12 @@ package cat.udl.eps.softarch.demo.domain; -import jakarta.persistence.Id; +import jakarta.persistence.Entity; +import lombok.Data; +import lombok.EqualsAndHashCode; -public class Admin extends UriEntity{ - @Id - Long id; +@EqualsAndHashCode(callSuper = true) +@Entity +@Data +public class Admin extends User{ - @Override - public Long getId() { - return id; - } } From 58b10d9f61264599cc4c5cf3b9d476bb2a7b72ee Mon Sep 17 00:00:00 2001 From: Ant Date: Thu, 22 Feb 2024 15:23:28 +0100 Subject: [PATCH 4/4] getAuthorities method implemented --- .../java/cat/udl/eps/softarch/demo/domain/Admin.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/Admin.java b/src/main/java/cat/udl/eps/softarch/demo/domain/Admin.java index 88d9c643..cddd8027 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/domain/Admin.java +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/Admin.java @@ -1,12 +1,22 @@ package cat.udl.eps.softarch.demo.domain; +import jakarta.persistence.ElementCollection; import jakarta.persistence.Entity; import lombok.Data; import lombok.EqualsAndHashCode; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.AuthorityUtils; + +import java.util.Collection; @EqualsAndHashCode(callSuper = true) @Entity @Data public class Admin extends User{ + @Override + @ElementCollection + public Collection getAuthorities(){ + return AuthorityUtils.commaSeparatedStringToAuthorityList("ROLE_ADMIN"); + } }