content: package com.xiliu.server.common.security.entity;
  
  import com.xiliu.server.modules.system.entity.XlUser;
  import org.springframework.security.core.GrantedAuthority;
  import org.springframework.security.core.userdetails.UserDetails;
  
  import java.util.Collection;
  import java.util.Set;
  
  /**
   * @author xiliu
   * @description SpringSecurity需要的用户详情
   * @date 2021/9/6
   */
  public class JwtUser implements UserDetails {
  
      /**
       * 用户ID
       */
      private Long userId;
      /**
       * 登录时间
       */
      private Long loginTime;
  
      /**
       * 用户唯一标识
       */
      private String token;
  
      /**
       * 过期时间
       */
      private Long expireTime;
  
      /**
       * 登录IP地址
       */
      private String ipaddr;
  
      /**
       * 登录地点
       */
      private String loginLocation;
  
      /**
       * 浏览器类型
       */
      private String browser;
  
      /**
       * 操作系统
       */
      private String os;
  
      /**
       * 用户信息
       */
      private XlUser user;
  
      /**
       * 权限列表
       */
      private Set<String> permissions;
  
  
      public Long getUserId() {
          return userId;
      }
  
      public void setUserId(Long userId) {
          this.userId = userId;
      }
  
      public JwtUser(XlUser user, Set<String> permissions) {
          this.user = user;
          this.permissions = permissions;
      }
  
      public JwtUser(Long userId, XlUser user, Set<String> permissions) {
          this.userId = userId;
          this.user = user;
          this.permissions = permissions;
      }
  
      @Override
      public Collection<? extends GrantedAuthority> getAuthorities() {
          return null;
      }
  
      @Override
      public String getPassword() {
          return user.getPassWord();
      }
  
      @Override
      public String getUsername() {
          return user.getUserCode();
      }
      /**
       * 账户是否未过期
       **/
      @Override
      public boolean isAccountNonExpired() {
          return true;
      }
      /**
       * 账户是否未锁定
       **/
      @Override
      public boolean isAccountNonLocked() {
          return true;
      }
      /**
       * 密码是否未过期
       **/
      @Override
      public boolean isCredentialsNonExpired() {
          return true;
      }
      /**
       * 账户是否激活
       **/
      @Override
      public boolean isEnabled() {
          return user.getStatus() == 0;
      }
  
      public Long getLoginTime()
      {
          return loginTime;
      }
  
      public void setLoginTime(Long loginTime)
      {
          this.loginTime = loginTime;
      }
  
      public Set<String> getPermissions()
      {
          return permissions;
      }
  
      public void setPermissions(Set<String> permissions)
      {
          this.permissions = permissions;
      }
  
      public XlUser getUser()
      {
          return user;
      }
  
      public void setUser(XlUser user)
      {
          this.user = user;
      }
  
      public String getToken()
      {
          return token;
      }
  
      public void setToken(String token)
      {
          this.token = token;
      }
  
      public String getIpaddr()
      {
          return ipaddr;
      }
  
      public void setIpaddr(String ipaddr) {
          this.ipaddr = ipaddr;
      }
  
      public String getLoginLocation()
      {
          return loginLocation;
      }
  
      public void setLoginLocation(String loginLocation)
      {
          this.loginLocation = loginLocation;
      }
  
      public String getBrowser()
      {
          return browser;
      }
  
      public void setBrowser(String browser)
      {
          this.browser = browser;
      }
  
      public String getOs()
      {
          return os;
      }
  
      public void setOs(String os)
      {
          this.os = os;
      }
  
      public Long getExpireTime()
      {
          return expireTime;
      }
  
      public void setExpireTime(Long expireTime)
      {
          this.expireTime = expireTime;
      }
  }
  