今のところ私の解決策は次のとおりです。
public class VersionFilter implements Filter {
..。
@Override
public void doFilter(ServletRequest request, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
String serverName = request.getServerName();
if (serverName.contains("appspot.com") && !UserBean.isAdmin()) {
HttpServletResponse httpResponse = (HttpServletResponse) servletResponse;
if (request.getParameter("login") != null) {
UserService userService = UserServiceFactory.getUserService();
httpResponse.sendRedirect(userService.createLoginURL("/"));
} else if (request.getParameter("logout") != null) {
UserService userService = UserServiceFactory.getUserService();
httpResponse.sendRedirect(userService.createLogoutURL("/"));
} else {
httpResponse.sendError(403);
}
}
filterChain.doFilter(request, servletResponse);
}
...}