|
@@ -34,6 +34,7 @@ import java.util.Set;
|
|
|
* @Date: 2020/6/27
|
|
|
*/
|
|
|
public class AuthInterceptor implements HandlerInterceptor {
|
|
|
+
|
|
|
private final static Logger log = LoggerFactory.getLogger(AuthInterceptor.class);
|
|
|
|
|
|
@Resource
|
|
@@ -56,19 +57,18 @@ public class AuthInterceptor implements HandlerInterceptor {
|
|
|
if (url.equalsIgnoreCase(SystemConstant.ERROR)) {
|
|
|
throw new BusinessException(ExceptionResultEnum.NOT_FOUND);
|
|
|
}
|
|
|
- Platform platform = Platform.valueOf(ServletUtil.getRequestPlatform());
|
|
|
+ Platform platform = ServletUtil.getRequestPlatform();
|
|
|
String deviceId = ServletUtil.getRequestDeviceId();
|
|
|
String authorization = ServletUtil.getRequestAuthorization();
|
|
|
- String time = ServletUtil.getRequestTime();
|
|
|
- log.info("platform:{},deviceId:{},authorization:{},method:{},time:{}", platform, deviceId, authorization, method, time);
|
|
|
+ long time = ServletUtil.getRequestTime();
|
|
|
+ log.info("platform:{},deviceId:{},authorization:{},method:{},time:{}", platform, deviceId, authorization,
|
|
|
+ method, time);
|
|
|
Long userId = null;
|
|
|
- Long timestamp = Long.parseLong(time);
|
|
|
- if (!SystemConstant.expire(timestamp.longValue())) {
|
|
|
- final SignatureInfo info = SignatureInfo
|
|
|
- .parse(method.toLowerCase(), url, timestamp, authorization);
|
|
|
+ if (!SystemConstant.expire(time)) {
|
|
|
+ final SignatureInfo info = SignatureInfo.parse(method.toLowerCase(), url, time, authorization);
|
|
|
//测试
|
|
|
-// final SignatureInfo info = SignatureInfo
|
|
|
-// .parse(authorization);
|
|
|
+ // final SignatureInfo info = SignatureInfo
|
|
|
+ // .parse(authorization);
|
|
|
if (Objects.nonNull(info) && info.getType() == SignatureType.TOKEN) {
|
|
|
String sessionId = info.getInvoker();
|
|
|
TBSession tbSession = (TBSession) redisUtil.getUserSession(sessionId);
|
|
@@ -76,7 +76,8 @@ public class AuthInterceptor implements HandlerInterceptor {
|
|
|
throw new BusinessException(ExceptionResultEnum.LOGIN_NO);
|
|
|
} else {
|
|
|
if (info.validate(tbSession.getAccessToken()) && info.getTimestamp() < tbSession.getExpireTime()
|
|
|
- && platform.name().equalsIgnoreCase(tbSession.getPlatform()) && Objects.equals(deviceId, tbSession.getDeviceId())) {
|
|
|
+ && platform.name().equalsIgnoreCase(tbSession.getPlatform()) && Objects
|
|
|
+ .equals(deviceId, tbSession.getDeviceId())) {
|
|
|
userId = Long.parseLong(tbSession.getIdentity());
|
|
|
Long expireTime = tbSession.getExpireTime();
|
|
|
//手机端的token时长为一个月,所以会出现缓存没有的情况
|
|
@@ -99,9 +100,9 @@ public class AuthInterceptor implements HandlerInterceptor {
|
|
|
}
|
|
|
request.setAttribute(SystemConstant.ORG, authDto.getTbOrg());
|
|
|
//系统管理员拥有所有权限
|
|
|
-// if (authDto.getRoleCodes().contains(RoleEnum.SUPER_ADMIN.name())) {
|
|
|
-// return true;
|
|
|
-// }
|
|
|
+ // if (authDto.getRoleCodes().contains(RoleEnum.SUPER_ADMIN.name())) {
|
|
|
+ // return true;
|
|
|
+ // }
|
|
|
//系统公用接口不拦截
|
|
|
List<String> sysUrls = dictionaryConfig.systemUrlDomain().getUrls();
|
|
|
int sysCount = (int) sysUrls.stream().filter(s -> {
|
|
@@ -132,15 +133,13 @@ public class AuthInterceptor implements HandlerInterceptor {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void postHandle(HttpServletRequest request,
|
|
|
- HttpServletResponse response,
|
|
|
- Object o, ModelAndView modelAndView) throws Exception {
|
|
|
+ public void postHandle(HttpServletRequest request, HttpServletResponse response, Object o,
|
|
|
+ ModelAndView modelAndView) throws Exception {
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void afterCompletion(HttpServletRequest request,
|
|
|
- HttpServletResponse response,
|
|
|
- Object o, Exception e) throws Exception {
|
|
|
+ public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object o, Exception e)
|
|
|
+ throws Exception {
|
|
|
}
|
|
|
}
|