Blame view

src/main/java/fr/plil/sio/web/mvc/User.java 1.63 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;
322c9502   Julien Cartigny   Ad Spring securit...
5
6
7
  import org.springframework.security.core.GrantedAuthority;
  import org.springframework.security.core.userdetails.UserDetails;
  
2070653e   Julien Iguchi-Cartigny   Switching to spri...
8
  import javax.persistence.*;
322c9502   Julien Cartigny   Ad Spring securit...
9
10
11
  import java.util.Collection;
  import java.util.Set;
  import java.util.TreeSet;
2070653e   Julien Iguchi-Cartigny   Switching to spri...
12
13
  
  @Entity
322c9502   Julien Cartigny   Ad Spring securit...
14
15
  @Table(name = "USER_T")
  public class User implements UserDetails {
2070653e   Julien Iguchi-Cartigny   Switching to spri...
16
17
  
      @Id
322c9502   Julien Cartigny   Ad Spring securit...
18
      @Column(name = "USER_ID")
2070653e   Julien Iguchi-Cartigny   Switching to spri...
19
20
21
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Long id;
  
322c9502   Julien Cartigny   Ad Spring securit...
22
      @Column(name = "USERNAME_F")
aa193b2b   Julien Iguchi-Cartigny   First version
23
      private String username;
2070653e   Julien Iguchi-Cartigny   Switching to spri...
24
  
322c9502   Julien Cartigny   Ad Spring securit...
25
      @Column(name = "PASSWORD_F")
aa193b2b   Julien Iguchi-Cartigny   First version
26
27
      private String password;
  
322c9502   Julien Cartigny   Ad Spring securit...
28
      @ManyToMany(mappedBy = "users", fetch = FetchType.EAGER)
f9b4ae49   jcartign   Fix recursion in ...
29
      @JsonManagedReference
322c9502   Julien Cartigny   Ad Spring securit...
30
31
32
33
      private Set<Role> roles = new TreeSet<>();
  
      public Set<Role> getRoles() {
          return roles;
2070653e   Julien Iguchi-Cartigny   Switching to spri...
34
35
      }
  
322c9502   Julien Cartigny   Ad Spring securit...
36
37
38
39
40
41
42
43
      public void setRoles(Set<Role> roles) {
          this.roles = roles;
      }
  
  
      @Override
      public Collection<? extends GrantedAuthority> getAuthorities() {
          return roles;
2070653e   Julien Iguchi-Cartigny   Switching to spri...
44
45
      }
  
aa193b2b   Julien Iguchi-Cartigny   First version
46
47
48
49
50
51
52
53
      public String getUsername() {
          return username;
      }
  
      public void setUsername(String username) {
          this.username = username;
      }
  
322c9502   Julien Cartigny   Ad Spring securit...
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
      @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
74
75
76
77
78
79
80
      public String getPassword() {
          return password;
      }
  
      public void setPassword(String password) {
          this.password = password;
      }
aa193b2b   Julien Iguchi-Cartigny   First version
81
  }