Advertisement
andersonalmada2

Untitled

Aug 5th, 2022
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.00 KB | None | 0 0
  1. package br.ufc.mandacaru5.model;
  2.  
  3. import java.util.Collection;
  4. import java.util.List;
  5.  
  6. import javax.persistence.Column;
  7. import javax.persistence.Entity;
  8. import javax.persistence.GeneratedValue;
  9. import javax.persistence.GenerationType;
  10. import javax.persistence.Id;
  11. import javax.persistence.JoinColumn;
  12. import javax.persistence.JoinTable;
  13. import javax.persistence.ManyToMany;
  14. import javax.persistence.SequenceGenerator;
  15.  
  16. import org.springframework.security.core.GrantedAuthority;
  17. import org.springframework.security.core.userdetails.UserDetails;
  18.  
  19. @Entity
  20. public class Login implements UserDetails {
  21.  
  22.     @Id
  23.     @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "login_generator")
  24.     @SequenceGenerator(name="login_generator", sequenceName = "login_seq", allocationSize=1)
  25.     private int id;
  26.     @Column(nullable = false, unique = true)
  27.     private String email;
  28.     @Column(nullable = false)
  29.     private String password;
  30.  
  31.     @ManyToMany
  32.     @JoinTable(joinColumns = @JoinColumn(name = "user_id"), inverseJoinColumns = @JoinColumn(name = "role_id"))
  33.     private List<Role> roles;
  34.  
  35.     @Override
  36.     public Collection<? extends GrantedAuthority> getAuthorities() {
  37.         // TODO Auto-generated method stub
  38.         return roles;
  39.     }
  40.  
  41.     @Override
  42.     public String getPassword() {
  43.         // TODO Auto-generated method stub
  44.         return password;
  45.     }
  46.  
  47.     @Override
  48.     public String getUsername() {
  49.         // TODO Auto-generated method stub
  50.         return email;
  51.     }
  52.  
  53.     @Override
  54.     public boolean isAccountNonExpired() {
  55.         // TODO Auto-generated method stub
  56.         return true;
  57.     }
  58.  
  59.     @Override
  60.     public boolean isAccountNonLocked() {
  61.         // TODO Auto-generated method stub
  62.         return true;
  63.     }
  64.  
  65.     @Override
  66.     public boolean isCredentialsNonExpired() {
  67.         // TODO Auto-generated method stub
  68.         return true;
  69.     }
  70.  
  71.     @Override
  72.     public boolean isEnabled() {
  73.         // TODO Auto-generated method stub
  74.         return true;
  75.     }
  76.  
  77.     @Override
  78.     public String toString() {
  79.         return "Login [id=" + id + ", email=" + email + ", password=" + password + ", roles=" + roles + "]";
  80.     }
  81.    
  82.    
  83. }
  84.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement