|
|
|
@ -7,8 +7,11 @@ import com.manage.service.cache.Cache;
|
|
|
|
|
import com.manage.service.cache.CacheManager;
|
|
|
|
|
import com.manage.service.Power_UserService;
|
|
|
|
|
import com.manage.util.Constant;
|
|
|
|
|
import com.manage.util.DateUtils;
|
|
|
|
|
import com.manage.vo.Power_UserVo;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.util.AntPathMatcher;
|
|
|
|
|
import org.springframework.util.PathMatcher;
|
|
|
|
|
import org.springframework.web.servlet.HandlerInterceptor;
|
|
|
|
@ -19,9 +22,12 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.util.Properties;
|
|
|
|
|
|
|
|
|
|
public class LoginInterceptor implements HandlerInterceptor {
|
|
|
|
|
@Value("${TOKEN_EXPIRE_TIME}")
|
|
|
|
|
private long TOKEN_EXPIRE_TIME;
|
|
|
|
|
@Autowired
|
|
|
|
|
Power_UserService powerUserService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object o) throws Exception {
|
|
|
|
|
String ctx = request.getServletContext().getContextPath();
|
|
|
|
|
String url = request.getRequestURI();
|
|
|
|
@ -46,6 +52,12 @@ public class LoginInterceptor implements HandlerInterceptor {
|
|
|
|
|
token = MD5.JM(Base64.decode(token));
|
|
|
|
|
Cache cache = CacheManager.getCacheInfo(token);
|
|
|
|
|
if (cache != null) {
|
|
|
|
|
if(!"/getSessionRemainingTime".equals(parentUrl)) {
|
|
|
|
|
//更新过期时间
|
|
|
|
|
Power_UserVo user = (Power_UserVo) cache.getValue();
|
|
|
|
|
String date = String.valueOf(DateUtils.getDate());
|
|
|
|
|
CacheManager.putCache(token, new Cache(date, user, TOKEN_EXPIRE_TIME));
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -77,8 +89,9 @@ public class LoginInterceptor implements HandlerInterceptor {
|
|
|
|
|
String[] values = value.split(",");
|
|
|
|
|
PathMatcher matcher = new AntPathMatcher();
|
|
|
|
|
for(String v : values){
|
|
|
|
|
if(matcher.match(v,url))
|
|
|
|
|
if(matcher.match(v,url)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else if(value.equals(url)){
|
|
|
|
|
return true;
|
|
|
|
|