Created
May 27, 2013 14:50
-
-
Save dgomesbr/5657464 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class UserRequiredAnnotationInterceptor extends HandlerInterceptorAdapter | |
{ | |
@Override | |
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception | |
{ | |
if (handler == null) | |
{ | |
return true; | |
} | |
if (((HandlerMethod) handler).getMethodAnnotation(RequiredUser.class) != null) | |
{ | |
final Object userkey = request.getSession().getAttribute(LoginFilter.CURRENT_LOGGED_USER_ATTRIBUTE); | |
if (userkey == null) | |
{ | |
response.sendRedirect(SiteMap.HOME_REDIRECT); | |
return false; | |
} | |
} | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment