content: package com.adamzareba.spring.security.oauth2.model.security;
  
  import com.fasterxml.jackson.annotation.JsonIgnore;
  
  import org.springframework.security.core.userdetails.UserDetails;
  
  import java.io.Serializable;
  import java.util.Collection;
  
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.FetchType;
  import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  import javax.persistence.JoinColumn;
  import javax.persistence.JoinTable;
  import javax.persistence.ManyToMany;
  import javax.persistence.OrderBy;
  import javax.persistence.Table;
  import javax.persistence.UniqueConstraint;
  
  import lombok.EqualsAndHashCode;
  import lombok.Getter;
  import lombok.Setter;
  
  @Entity
  @Table(name = "USER_", uniqueConstraints = { @UniqueConstraint(columnNames = { "USER_NAME" }) })
  @Getter
  @Setter
  @EqualsAndHashCode(of = "id")
  public class User implements UserDetails, Serializable {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Column(name = "ID")
      private Long id;
  
      @Column(name = "USER_NAME")
      private String username;
  
      @Column(name = "PASSWORD")
      private String password;
  
      @Column(name = "ACCOUNT_EXPIRED")
      private boolean accountExpired;
  
      @Column(name = "ACCOUNT_LOCKED")
      private boolean accountLocked;
  
      @Column(name = "CREDENTIALS_EXPIRED")
      private boolean credentialsExpired;
  
      @Column(name = "ENABLED")
      private boolean enabled;
  
      @ManyToMany(fetch = FetchType.LAZY)
      @JoinTable(name = "USERS_AUTHORITIES", joinColumns = @JoinColumn(name = "USER_ID", referencedColumnName = "ID"), inverseJoinColumns = @JoinColumn(name = "AUTHORITY_ID", referencedColumnName = "ID"))
      @OrderBy
      @JsonIgnore
      private Collection<Authority> authorities;
  
      @Override
      public boolean isAccountNonExpired() {
          return !isAccountExpired();
      }
  
      @Override
      public boolean isAccountNonLocked() {
          return !isAccountLocked();
      }
  
      @Override
      public boolean isCredentialsNonExpired() {
          return !isCredentialsExpired();
      }
  }
  