UserToken.java 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * *************************************************
  3. * Copyright (c) 2018 QMTH. All Rights Reserved.
  4. * Created by Deason on 2018-07-31 14:32:47.
  5. * *************************************************
  6. */
  7. package cn.com.qmth.examcloud.app.model;
  8. import java.io.Serializable;
  9. import java.util.Calendar;
  10. import java.util.Date;
  11. /* 用户登录信息 */
  12. public class UserToken implements Serializable {
  13. private static final long serialVersionUID = 1L;
  14. private String account;
  15. private String password;
  16. private String accountType;
  17. private Long rootOrgId;
  18. private String domain;
  19. private String key;
  20. private String token;
  21. private Date createTime;
  22. public UserToken(String account, String password, String accountType, Long rootOrgId, String domain, String key, String token) {
  23. this.account = account;
  24. this.password = password;
  25. this.accountType = accountType;
  26. this.rootOrgId = rootOrgId;
  27. this.domain = domain;
  28. this.key = key;
  29. this.token = token;
  30. this.createTime = new Date();
  31. }
  32. public UserToken() {
  33. }
  34. public boolean hasExpired(int seconds) {
  35. if (createTime == null) {
  36. return true;
  37. }
  38. Calendar c = Calendar.getInstance();
  39. c.setTime(createTime);
  40. c.add(Calendar.SECOND, seconds);
  41. //System.out.println(DateUtils.format(c.getTime()));
  42. //判断是否在n小时内
  43. if (c.getTime().after(new Date())) {
  44. return false;
  45. }
  46. return true;
  47. }
  48. public String getAccount() {
  49. return account;
  50. }
  51. public void setAccount(String account) {
  52. this.account = account;
  53. }
  54. public String getPassword() {
  55. return password;
  56. }
  57. public void setPassword(String password) {
  58. this.password = password;
  59. }
  60. public String getAccountType() {
  61. return accountType;
  62. }
  63. public void setAccountType(String accountType) {
  64. this.accountType = accountType;
  65. }
  66. public Long getRootOrgId() {
  67. return rootOrgId;
  68. }
  69. public void setRootOrgId(Long rootOrgId) {
  70. this.rootOrgId = rootOrgId;
  71. }
  72. public String getDomain() {
  73. return domain;
  74. }
  75. public void setDomain(String domain) {
  76. this.domain = domain;
  77. }
  78. public String getKey() {
  79. return key;
  80. }
  81. public void setKey(String key) {
  82. this.key = key;
  83. }
  84. public String getToken() {
  85. return token;
  86. }
  87. public void setToken(String token) {
  88. this.token = token;
  89. }
  90. public Date getCreateTime() {
  91. return createTime;
  92. }
  93. public void setCreateTime(Date createTime) {
  94. this.createTime = createTime;
  95. }
  96. }