|
@@ -2,11 +2,13 @@ package com.fdkankan.manage.controller;
|
|
|
|
|
|
import com.auth0.jwt.JWT;
|
|
|
import com.auth0.jwt.interfaces.DecodedJWT;
|
|
|
+import com.fdkankan.manage.common.ResultData;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.util.Date;
|
|
|
|
|
|
@Component
|
|
|
public class BaseController {
|
|
@@ -19,6 +21,9 @@ public class BaseController {
|
|
|
protected String getToken(){
|
|
|
return request.getHeader("token");
|
|
|
}
|
|
|
+ protected String getSign(){
|
|
|
+ return request.getHeader("sign");
|
|
|
+ }
|
|
|
|
|
|
protected Long getUserId(){
|
|
|
String token = request.getHeader("token");
|
|
@@ -26,4 +31,18 @@ public class BaseController {
|
|
|
return jwt.getClaim("userId").asLong();
|
|
|
}
|
|
|
|
|
|
+ public Boolean checkSign(){
|
|
|
+ try {
|
|
|
+ String sign = getSign();
|
|
|
+ Long time = new Date().getTime();
|
|
|
+ Long signLong = Long.valueOf(sign);
|
|
|
+ if(time -signLong >1000 * 10){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
}
|