|
@ -24,7 +24,7 @@ public class ModuleAuthenInterceptor implements HandlerInterceptor { |
|
|
int count = 0; |
|
|
int count = 0; |
|
|
int index = -1; |
|
|
int index = -1; |
|
|
|
|
|
|
|
|
while(count < 5) { |
|
|
while(count < 2) { |
|
|
index = str.indexOf(c, index + 1); |
|
|
index = str.indexOf(c, index + 1); |
|
|
count++; |
|
|
count++; |
|
|
} |
|
|
} |
|
@ -33,14 +33,17 @@ public class ModuleAuthenInterceptor implements HandlerInterceptor { |
|
|
} |
|
|
} |
|
|
@Override |
|
|
@Override |
|
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { |
|
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { |
|
|
String moduleName = request.getRequestURI().substring(0,findThirdOccurrence(request.getRequestURI(),'/')); |
|
|
String uri = request.getRequestURI().substring(request.getRequestURI().indexOf("admin-api")+"admin-api".length()); |
|
|
|
|
|
String moduleName = uri.substring(0,findThirdOccurrence(request.getRequestURI(),'/')); |
|
|
|
|
|
log.info(String.format("===uri-src=%s,uri-md5=%s===",moduleName,md5.digestHex(moduleName))); |
|
|
|
|
|
log.info(String.format("===cache=%s===", new JSONObject(ModuleAuthenUtils.module).toString())); |
|
|
String endTimeStr = ModuleAuthenUtils.module.get(md5.digestHex(moduleName)); |
|
|
String endTimeStr = ModuleAuthenUtils.module.get(md5.digestHex(moduleName)); |
|
|
if(endTimeStr != null){ |
|
|
if(endTimeStr != null){ |
|
|
LocalDateTime endTime = LocalDateTime.parse(ModuleAuthenUtils.decrypt(endTimeStr,ModuleAuthenUtils.secretKey), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
|
|
LocalDateTime endTime = LocalDateTime.parse(ModuleAuthenUtils.decrypt(endTimeStr,ModuleAuthenUtils.secretKey), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
|
|
if (endTime == null || endTime.isBefore(LocalDateTime.now())){ |
|
|
if (endTime == null || endTime.isBefore(LocalDateTime.now())){ |
|
|
response.setContentType("application/json;charset=utf-8"); |
|
|
response.setContentType("application/json;charset=utf-8"); |
|
|
CommonResult result = new CommonResult<>(); |
|
|
CommonResult result = new CommonResult<>(); |
|
|
result.setCode(500); |
|
|
result.setCode(403); |
|
|
result.setMsg(String.format("【%s】模块权限到期,请联系服务商缴费", moduleName)); |
|
|
result.setMsg(String.format("【%s】模块权限到期,请联系服务商缴费", moduleName)); |
|
|
@Cleanup PrintWriter os = response.getWriter(); |
|
|
@Cleanup PrintWriter os = response.getWriter(); |
|
|
os.write(new JSONObject(result).toString()); |
|
|
os.write(new JSONObject(result).toString()); |
|
|