|
|
|
@ -216,22 +216,24 @@ public class PageController { |
|
|
|
String time1 = (String)request.getParameter("time"); |
|
|
|
if (null != userkey1 && userkey1.length() != 0 && null != usertoken1 && usertoken1.length() != 0 && null != sing1 && sing1.length() != 0 && null != time1 && time1.length() != 0){ |
|
|
|
long time1Long = Long.parseLong(time1); |
|
|
|
long timeDifference = javaTime-time1Long; |
|
|
|
// 将时间戳转换为LocalDateTime对象
|
|
|
|
LocalDateTime dateTime1 = LocalDateTime.ofInstant(Instant.ofEpochMilli(javaTime), ZoneId.systemDefault()); |
|
|
|
LocalDateTime dateTime2 = LocalDateTime.ofInstant(Instant.ofEpochMilli(time1Long), ZoneId.systemDefault()); |
|
|
|
// 计算时间差
|
|
|
|
Duration duration = Duration.between(dateTime2, dateTime1); |
|
|
|
Duration duration = Duration.between(dateTime1, dateTime2);//上线使用,真正校验时间
|
|
|
|
//Duration duration = Duration.between(dateTime1, dateTime2);
|
|
|
|
// 获取时间差的毫秒数
|
|
|
|
long diffMillis = duration.toMillis(); |
|
|
|
/*System.out.println(dateTime1); |
|
|
|
System.out.println(dateTime2); |
|
|
|
System.out.println(diffMillis);*/ |
|
|
|
if(diffMillis<5000){//如果间隔时间不超过5秒
|
|
|
|
if(timeDifference<30000){//如果间隔时间不超过5秒
|
|
|
|
String singJava = Md5Util.md5InsensibleLogin(userkey1, usertoken1, time1); |
|
|
|
if(sing1.equals(singJava)){//校验通过允许无感登录
|
|
|
|
flag = true; |
|
|
|
}else{ |
|
|
|
//验证失败-密钥与key,token,time不匹配
|
|
|
|
msg = "验证失败"; |
|
|
|
} |
|
|
|
}else{ |
|
|
|
|