我用 GWT+requestfacotry(MVP)+GAE 创建了一个应用程序。有一些服务或方法暴露给 GWT 客户端,例如
1.create 2.remove 3.query
我想将授权功能添加到“创建”和“删除”,而不是“查询”。我用 servlet 过滤器做到了:
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse,
FilterChain filterChain) throws IOException, ServletException {
UserService userService = UserServiceFactory.getUserService();
HttpServletRequest request = (HttpServletRequest) servletRequest;
HttpServletResponse response = (HttpServletResponse) servletResponse;
if (!userService.isUserLoggedIn()) {
response.setHeader("login", userService.createLoginURL(request.getHeader("pageurl")));
// response.setHeader("login", userService.createLoginURL(request.getRequestURI()));
response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
return;
}
filterChain.doFilter(request, response);
}
我的问题是如何识别进来的请求(我的意思是请求将路由到哪个类和服务)?有一些头字段包含模块名称,但我不认为这是安全的方法。是否可以从 http 请求中获取 RequestFactry 相关类?
谢谢