91 lines
1.9 KiB
Java
91 lines
1.9 KiB
Java
package com.tiesheng.login.pojos;
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.crypto.SecureUtil;
|
|
|
|
import java.util.Objects;
|
|
|
|
public class UniqueIndexDTO extends LoginToInfo {
|
|
|
|
private String no;
|
|
private String extra;
|
|
private String info;
|
|
private String platform = "web";
|
|
private Long timestamp;
|
|
private String sign;
|
|
|
|
|
|
/**
|
|
* 验证签名是否正确
|
|
*/
|
|
public boolean validSign() {
|
|
if (StrUtil.isEmpty(getNo()) || getTimestamp() == null) {
|
|
return false;
|
|
}
|
|
if ((DateUtil.currentSeconds() - getTimestamp()) > 60) {
|
|
return false;
|
|
}
|
|
String mySign = getNo() + getTimestamp();
|
|
for (int i = 0; i < 11; i++) {
|
|
mySign = SecureUtil.md5(mySign);
|
|
}
|
|
return Objects.equals(sign, mySign);
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
// setter\getter
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
public String getNo() {
|
|
return no;
|
|
}
|
|
|
|
public void setNo(String no) {
|
|
this.no = no;
|
|
}
|
|
|
|
public String getExtra() {
|
|
if (StrUtil.isEmpty(extra)) {
|
|
extra = "";
|
|
}
|
|
return extra;
|
|
}
|
|
|
|
public void setExtra(String extra) {
|
|
this.extra = extra;
|
|
}
|
|
|
|
public String getInfo() {
|
|
return info;
|
|
}
|
|
|
|
public void setInfo(String info) {
|
|
this.info = info;
|
|
}
|
|
|
|
public String getPlatform() {
|
|
return platform;
|
|
}
|
|
|
|
public void setPlatform(String platform) {
|
|
this.platform = platform;
|
|
}
|
|
|
|
public Long getTimestamp() {
|
|
return timestamp;
|
|
}
|
|
|
|
public void setTimestamp(Long timestamp) {
|
|
this.timestamp = timestamp;
|
|
}
|
|
|
|
public String getSign() {
|
|
return sign;
|
|
}
|
|
|
|
public void setSign(String sign) {
|
|
this.sign = sign;
|
|
}
|
|
}
|