UifControllerHandlerInterceptor implements HandlerInterceptor { protected void checkHandlerMethodAccess(HttpServletRequest request, Object handler) throws Exception { String requestMethod = request.getMethod(); if(requestMethod.equalsIgnoreCase(RequestMethod.GET.name())) { return; } HandlerMethod handlerMethod = (HandlerMethod) handler; MethodAccessible methodAccessible = handlerMethod.getMethodAnnotation(MethodAccessible.class); if (methodAccessible != null) { return; } boolean isMethodAccessible = checkForMethodAccess(request); if (!isMethodAccessible) { throw new MethodAccessException(handlerMethod.getBeanType(), handlerMethod.getMethod().getName()); } }  @Override boolean preHandle(HttpServletRequest request, HttpServletResponse response,
            Object handler); @Override void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
            ModelAndView modelAndView); @Override void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler,
            Exception ex); void setModelAndViewService(ModelAndViewService modelAndViewService);  }
@Test public void testCheckHandlerMethodAccess() throws Exception { ViewPostMetadata viewPostMetadata = new ViewPostMetadata(); model.setViewPostMetadata(viewPostMetadata); assertMethodAccess("Accessible annotation not picked up", "method1", true); assertMethodAccess("Custom method should be allowed due to not being in the available methods", "method2", true); viewPostMetadata.addAvailableMethodToCall( "method2" ); assertMethodAccess("Accessible annotation picked up where not present", "method2", false); viewPostMetadata.addAccessibleMethodToCall("method4"); viewPostMetadata.addAccessibleMethodToCall("method6"); assertMethodAccess("Accessible method by view not picked up", "method4", true); assertMethodAccess("Accessible method by view not picked up", "method6", true); assertMethodAccess("Method not accessible for empty method to call", null, true); }