source: src/main/java/it/finki/charitable/entities/AppUser.java@ 5577566

Last change on this file since 5577566 was 5577566, checked in by NikolaCenevski <cenevskinikola@…>, 3 years ago

prototip part 2

  • Property mode set to 100644
File size: 3.3 KB
Line 
1package it.finki.charitable.entities;
2
3import org.springframework.security.core.GrantedAuthority;
4import org.springframework.security.core.authority.SimpleGrantedAuthority;
5import org.springframework.security.core.userdetails.UserDetails;
6
7import javax.persistence.*;
8import java.util.ArrayList;
9import java.util.Collection;
10import java.util.Collections;
11import java.util.List;
12
13@Entity
14@Table(name = "app_user")
15public class AppUser implements UserDetails {
16
17 @SequenceGenerator(
18 name = "user_sequence",
19 sequenceName = "user_sequence",
20 allocationSize = 1
21 )
22 @GeneratedValue(
23 strategy = GenerationType.SEQUENCE,
24 generator = "user_sequence"
25 )
26 @Id
27 @Column(
28 name = "id",
29 nullable = false,
30 updatable = false
31 )
32 private Long id;
33
34 private String firstName;
35 private String lastName;
36 private String email;
37 private String password;
38 private String creditCardInfo;
39 @Enumerated(EnumType.STRING)
40 private UserRole userRole;
41 private Boolean enabled;
42
43 @OneToMany
44 private List<DonationInformation> donationInformation = new ArrayList<>();
45
46 public AppUser() {
47 }
48
49 public Long getId() {
50 return id;
51 }
52
53 public void setId(Long id) {
54 this.id = id;
55 }
56
57 public String getFirstName() {
58 return firstName;
59 }
60
61 public void setFirstName(String firstName) {
62 this.firstName = firstName;
63 }
64
65 public String getLastName() {
66 return lastName;
67 }
68
69 public void setLastName(String lastName) {
70 this.lastName = lastName;
71 }
72
73 public String getEmail() {
74 return email;
75 }
76
77 public void setEmail(String email) {
78 this.email = email;
79 }
80
81 public void setPassword(String password) {
82 this.password = password;
83 }
84
85 public String getCreditCardInfo() {
86 return creditCardInfo;
87 }
88
89 public void setCreditCardInfo(String creditCardInfo) {
90 this.creditCardInfo = creditCardInfo;
91 }
92
93 public UserRole getUserRole() {
94 return userRole;
95 }
96
97 public void setUserRole(UserRole userRole) {
98 this.userRole = userRole;
99 }
100
101 public Boolean getEnabled() {
102 return enabled;
103 }
104
105 public void setEnabled(Boolean enabled) {
106 this.enabled = enabled;
107 }
108
109 public List<DonationInformation> getDonationInformation() {
110 return donationInformation;
111 }
112
113 public void setDonationInformation(List<DonationInformation> donationInformation) {
114 this.donationInformation = donationInformation;
115 }
116
117 @Override
118 public Collection<? extends GrantedAuthority> getAuthorities() {
119 SimpleGrantedAuthority authority = new SimpleGrantedAuthority(userRole.name());
120 return Collections.singletonList(authority);
121 }
122
123 @Override
124 public String getPassword() {
125 return password;
126 }
127
128 @Override
129 public String getUsername() {
130 return email;
131 }
132
133 @Override
134 public boolean isAccountNonExpired() {
135 return true;
136 }
137
138 @Override
139 public boolean isAccountNonLocked() {
140 return true;
141 }
142
143 @Override
144 public boolean isCredentialsNonExpired() {
145 return true;
146 }
147
148 @Override
149 public boolean isEnabled() {
150 return enabled;
151 }
152}
Note: See TracBrowser for help on using the repository browser.