Blame view

src/main/java/fr/plil/sio/web/mvc/User.java 1.96 KB
aa193b2b   Julien Iguchi-Cartigny   First version
1
2
  package fr.plil.sio.web.mvc;
  
aa193b2b   Julien Iguchi-Cartigny   First version
3
  
f9b4ae49   jcartign   Fix recursion in ...
4
  import com.fasterxml.jackson.annotation.JsonManagedReference;
353d9d4f   Zak   désactivation des...
5
  import java.util.ArrayList;
322c9502   Julien Cartigny   Ad Spring securit...
6
7
8
  import org.springframework.security.core.GrantedAuthority;
  import org.springframework.security.core.userdetails.UserDetails;
  
2070653e   Julien Iguchi-Cartigny   Switching to spri...
9
  import javax.persistence.*;
322c9502   Julien Cartigny   Ad Spring securit...
10
  import java.util.Collection;
353d9d4f   Zak   désactivation des...
11
  import java.util.List;
322c9502   Julien Cartigny   Ad Spring securit...
12
13
  import java.util.Set;
  import java.util.TreeSet;
2070653e   Julien Iguchi-Cartigny   Switching to spri...
14
15
  
  @Entity
322c9502   Julien Cartigny   Ad Spring securit...
16
17
  @Table(name = "USER_T")
  public class User implements UserDetails {
2070653e   Julien Iguchi-Cartigny   Switching to spri...
18
19
  
      @Id
322c9502   Julien Cartigny   Ad Spring securit...
20
      @Column(name = "USER_ID")
2070653e   Julien Iguchi-Cartigny   Switching to spri...
21
22
23
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Long id;
  
322c9502   Julien Cartigny   Ad Spring securit...
24
      @Column(name = "USERNAME_F")
aa193b2b   Julien Iguchi-Cartigny   First version
25
      private String username;
2070653e   Julien Iguchi-Cartigny   Switching to spri...
26
  
322c9502   Julien Cartigny   Ad Spring securit...
27
      @Column(name = "PASSWORD_F")
aa193b2b   Julien Iguchi-Cartigny   First version
28
29
      private String password;
  
353d9d4f   Zak   désactivation des...
30
31
32
33
34
35
36
37
38
39
40
41
      @OneToMany(mappedBy="holderOfDebt",cascade = CascadeType.REMOVE)
      private List<Dette> dettes = new ArrayList<Dette>();
  
      public List<Dette> getDettes() {
          return dettes;
      }
  
      public void setDettes(List<Dette> dettes) {
          this.dettes = dettes;
      }
      
      
322c9502   Julien Cartigny   Ad Spring securit...
42
      @ManyToMany(mappedBy = "users", fetch = FetchType.EAGER)
f9b4ae49   jcartign   Fix recursion in ...
43
      @JsonManagedReference
322c9502   Julien Cartigny   Ad Spring securit...
44
45
46
47
      private Set<Role> roles = new TreeSet<>();
  
      public Set<Role> getRoles() {
          return roles;
2070653e   Julien Iguchi-Cartigny   Switching to spri...
48
49
      }
  
322c9502   Julien Cartigny   Ad Spring securit...
50
51
52
53
54
55
56
57
      public void setRoles(Set<Role> roles) {
          this.roles = roles;
      }
  
  
      @Override
      public Collection<? extends GrantedAuthority> getAuthorities() {
          return roles;
2070653e   Julien Iguchi-Cartigny   Switching to spri...
58
59
      }
  
aa193b2b   Julien Iguchi-Cartigny   First version
60
61
62
63
64
65
66
67
      public String getUsername() {
          return username;
      }
  
      public void setUsername(String username) {
          this.username = username;
      }
  
322c9502   Julien Cartigny   Ad Spring securit...
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
      @Override
      public boolean isAccountNonExpired() {
          return true;
      }
  
      @Override
      public boolean isAccountNonLocked() {
          return true;
      }
  
      @Override
      public boolean isCredentialsNonExpired() {
          return true;
      }
  
      @Override
      public boolean isEnabled() {
          return true;
      }
  
aa193b2b   Julien Iguchi-Cartigny   First version
88
89
90
91
92
93
94
      public String getPassword() {
          return password;
      }
  
      public void setPassword(String password) {
          this.password = password;
      }
aa193b2b   Julien Iguchi-Cartigny   First version
95
  }