@Override public <T extends Annotation> boolean hasMethodAnnotation(Class<T> annotationType) { return HandlerMethod.this.hasMethodAnnotation(annotationType); }
@Override public <T extends Annotation> boolean hasMethodAnnotation(Class<T> annotationType) { return HandlerMethod.this.hasMethodAnnotation(annotationType); }
@Override public <T extends Annotation> boolean hasMethodAnnotation(Class<T> annotationType) { return HandlerMethod.this.hasMethodAnnotation(annotationType); }
private boolean supportsHandler(Object handler) { return handler instanceof HandlerMethod && ((HandlerMethod) handler) .hasMethodAnnotation(Pageable.class); }
@Override public <T extends Annotation> boolean hasMethodAnnotation(Class<T> annotationType) { return HandlerMethod.this.hasMethodAnnotation(annotationType); }
private static boolean isHtmlRequest(HandlerMethod handlerMethod) { return !(handlerMethod.hasMethodAnnotation(ResponseBody.class) || handlerMethod.hasMethodAnnotation(ResponseStatus.class) || handlerMethod.getBeanType().isAnnotationPresent(ResponseBody.class) || handlerMethod.getBeanType().isAnnotationPresent(RestController.class)); }
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { if (handler instanceof HandlerMethod) { HandlerMethod method = (HandlerMethod) handler; if (method.hasMethodAnnotation(RequestMapping.class)) { RestAccessControl rqm = method.getMethodAnnotation(RestAccessControl.class); if (null == rqm) { return true; } String permission = rqm.permission(); this.extractOAuthParameters(request, permission); } } return true; }
boolean hasMethodLogin = handlerMethod.hasMethodAnnotation(Login.class); Login loginClass = handlerMethod.getBeanType().getAnnotation(Login.class); String jwtToken = request.getHeader(HttpHeaders.AUTHORIZATION);
if(!handlerMethod.hasMethodAnnotation(Api.class)){ continue;
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { // 校验访问令牌是否正确。若正确,返回授权信息 String accessToken = obtainAccess(request); OAuth2AuthenticationDTO authentication = null; if (accessToken != null) { authentication = oauth2Service.checkToken(accessToken); // 添加到 SecurityContext SecurityContext context = new SecurityContext(authentication.getUid()); SecurityContextHolder.setContext(context); } // 校验是否需要已授权 HandlerMethod method = (HandlerMethod) handler; boolean isPermitAll = method.hasMethodAnnotation(PermitAll.class); if (!isPermitAll && authentication == null) { throw new ServiceException(-1, "未授权"); } return super.preHandle(request, response, handler); }