Advertisement
Guest User

Untitled

a guest
May 30th, 2018
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.84 KB | None | 0 0
  1. package com.example.app.entity;
  2. import org.springframework.security.core.userdetails.UserDetails;
  3.  
  4. import javax.persistence.*;
  5. import java.math.BigInteger;
  6. import java.util.HashSet;
  7. import java.util.Set;
  8.  
  9. @Entity
  10. @Table (name = "users")
  11. public class User implements UserDetails {
  12.  
  13. @Id
  14. @GeneratedValue(strategy = GenerationType.IDENTITY)
  15. private long id;
  16.  
  17. private String username;
  18. private String password;
  19. private String email;
  20. private boolean isAccountNonExpired;
  21. private boolean isAccountNonLocked;
  22. private boolean isCredentialsNonExpired;
  23. private boolean isEnabled;
  24.  
  25. @ManyToMany(fetch = FetchType.EAGER, cascade = {CascadeType.ALL})
  26. @JoinTable(name = "users_roles", joinColumns = @JoinColumn(name = "user_id"),
  27. inverseJoinColumns = @JoinColumn(name = "role_id"))
  28. private Set<Role> authorities = new HashSet<Role>();
  29.  
  30. @ManyToMany(fetch = FetchType.LAZY, cascade = {CascadeType.ALL}, mappedBy = "players")
  31. private Set<Event> events = new HashSet<>();
  32.  
  33. public Set<Event> getEvents() {
  34. return events;
  35. }
  36.  
  37. public void setEvents(Set<Event> events) {
  38. this.events = events;
  39. }
  40.  
  41. @Override
  42. public Set<Role> getAuthorities() {
  43. return authorities;
  44. }
  45.  
  46. @Override
  47. public String getPassword() {
  48. return password;
  49. }
  50.  
  51. @Override
  52. public String getUsername() {
  53. return username;
  54. }
  55.  
  56. @Override
  57. public boolean isAccountNonExpired() {
  58. return isAccountNonExpired;
  59. }
  60.  
  61. @Override
  62. public boolean isAccountNonLocked() {
  63. return isAccountNonLocked;
  64. }
  65.  
  66. @Override
  67. public boolean isCredentialsNonExpired() {
  68. return isCredentialsNonExpired;
  69. }
  70.  
  71. @Override
  72. public boolean isEnabled() {
  73. return isEnabled;
  74. }
  75.  
  76. public long getId() {
  77. return id;
  78. }
  79.  
  80. public void setId(long id) {
  81. this.id = id;
  82. }
  83.  
  84. public void setUsername(String username) {
  85. this.username = username;
  86. }
  87.  
  88. public void setPassword(String password) {
  89. this.password = password;
  90. }
  91.  
  92. public String getEmail() {
  93. return email;
  94. }
  95.  
  96. public void setEmail(String email) {
  97. this.email = email;
  98. }
  99.  
  100. public void setAccountNonExpired(boolean accountNonExpired) {
  101. isAccountNonExpired = accountNonExpired;
  102. }
  103.  
  104. public void setAccountNonLocked(boolean accountNonLocked) {
  105. isAccountNonLocked = accountNonLocked;
  106. }
  107.  
  108. public void setCredentialsNonExpired(boolean credentialsNonExpired) {
  109. isCredentialsNonExpired = credentialsNonExpired;
  110. }
  111.  
  112. public void setEnabled(boolean enabled) {
  113. isEnabled = enabled;
  114. }
  115.  
  116. public void setAuthorities(Set<Role> authorities) {
  117. this.authorities = authorities;
  118. }
  119. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement