content: package com.lzc.security.dataobject;
  
  import org.springframework.security.core.CredentialsContainer;
  import org.springframework.security.core.GrantedAuthority;
  import org.springframework.security.core.userdetails.UserDetails;
  
  import java.util.Collection;
  import java.util.HashSet;
  import java.util.Set;
  
  public class LoginUser implements UserDetails, CredentialsContainer {
  
      private String password;
      private  String username;
      private  Set<GrantedAuthority> authorities;
      private  boolean accountNonExpired;
      private  boolean accountNonLocked;
      private  boolean credentialsNonExpired;
      private  boolean enabled;
  
      private String nickName;
  
      public LoginUser() {
          this("", "", true, true, true, true, null);
      }
  
      public LoginUser(String username, String password, Collection<? extends GrantedAuthority> authorities) {
          this(username, password, true, true, true, true, authorities);
      }
  
      public LoginUser(String username, String password, boolean enabled, boolean accountNonExpired, boolean credentialsNonExpired, boolean accountNonLocked, Collection<? extends GrantedAuthority> authorities) {
          if (username != null && !"".equals(username) && password != null) {
              this.username = username;
              this.password = password;
              this.enabled = enabled;
              this.accountNonExpired = accountNonExpired;
              this.credentialsNonExpired = credentialsNonExpired;
              this.accountNonLocked = accountNonLocked;
  
              this.authorities = new HashSet<>();
              for (GrantedAuthority g : authorities) {
                  this.authorities.add(g);
              }
  
          } else {
              throw new IllegalArgumentException("Cannot pass null or empty values to constructor");
          }
      }
  
  
      @Override
      public String getPassword() {
          return password;
      }
  
      public void setPassword(String password) {
          this.password = password;
      }
  
      @Override
      public String getUsername() {
          return username;
      }
  
      public void setUsername(String username) {
          this.username = username;
      }
  
      @Override
      public Set<GrantedAuthority> getAuthorities() {
          return authorities;
      }
  
      public void setAuthorities(Set<GrantedAuthority> authorities) {
          this.authorities = authorities;
      }
  
      public String getNickName() {
          return nickName;
      }
  
      public void setNickName(String nickName) {
          this.nickName = nickName;
      }
  
      @Override
      public void eraseCredentials() {
          this.password = null;
      }
  
      @Override
      public boolean isAccountNonExpired() {
          return this.accountNonExpired;
      }
  
      @Override
      public boolean isAccountNonLocked() {
          return this.accountNonLocked;
      }
  
      @Override
      public boolean isCredentialsNonExpired() {
          return this.credentialsNonExpired;
      }
  
      @Override
      public boolean isEnabled() {
          return this.enabled;
      }
  }
  