Commit 4aa826bc46a36528efceceab5c5a2ccb76c7cc15

Authored by jiangjiazhi
1 parent d8af9ec085
Exists in master

add token inteceptor

Showing 2 changed files with 16 additions and 3 deletions

parent/hospital.web/src/main/java/com/lyms/hospital/inteceptor/TokenValidateInteceptor.java View file @ 4aa826b
... ... @@ -49,6 +49,14 @@
49 49 return validateToken(request, response);
50 50 }
51 51  
  52 + /**
  53 + * 获取注解
  54 + *
  55 + * @param handler HandlerMethod
  56 + * @param annotationType annotationType
  57 + * @param <T>
  58 + * @return annotation
  59 + */
52 60 private <T extends Annotation> T findAnnotation(HandlerMethod handler, Class<T> annotationType) {
53 61 T annotation = handler.getBeanType().getAnnotation(annotationType);
54 62 if (annotation != null)
... ... @@ -56,6 +64,13 @@
56 64 return handler.getMethodAnnotation(annotationType);
57 65 }
58 66  
  67 + /**
  68 + * 验证token
  69 + *
  70 + * @param httpServletRequest
  71 + * @param httpServletResponse
  72 + * @return
  73 + */
59 74 public boolean validateToken(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
60 75 String token = httpServletRequest.getHeader(Constants.AUTH_HEADER);
61 76 if (StringUtils.isEmpty(token)) {
... ... @@ -66,7 +81,7 @@
66 81 }
67 82  
68 83 /**
69   - * This implementation is empty.
  84 + * 清空threadlocal的信息.
70 85 */
71 86 @Override
72 87 public void afterCompletion(
parent/hospital.web/src/main/java/com/lyms/hospital/session/strategy/LocalRedisSessionStrategy.java View file @ 4aa826b
... ... @@ -39,8 +39,6 @@
39 39  
40 40 @Autowired
41 41 private TokenService tokenService;
42   - @Autowired
43   - private UsersService userService;
44 42  
45 43 @Override
46 44 public boolean checkSession(HttpServletRequest request, HttpServletResponse response, String token)