我试过了
< Context cookies="true" crossContext="true">
< SessionCookie secure="true" httpOnly="true" />
在 context.xml 中,但在 jboss4.0 中无法识别
我在java程序中试过
String sessionid = req.getSession().getId();
resp.setHeader("SET-COOKIE", "JSESSIONID=" + sessionid + ";Path="+req.getContextPath()+"; Secure; Domain="+req.getServerName()+"; HttpOnly");
对于第二个请求,它不允许获取会话的会话验证对象,因此它显示会话过期页面
我尝试使用过滤器
public void doFilter(final ServletRequest req, final ServletResponse res, final FilterChain filterChain) throws IOException, ServletException {
final HttpServletResponse response = (HttpServletResponse) res;
final HttpServletRequest request = (HttpServletRequest) req;
System.out.println(response.containsHeader("SET-COOKIE"));
if (response.containsHeader("Set-Cookie")) { // *******
response.setHeader("SET-COOKIE", "JSESSIONID=" + request.getSession().getId() + "; Path=" + request.getContextPath()
+ "; HttpOnly" + (request.isSecure()?SECURE_FLAG : ""));
}
filterChain.doFilter(req, res);
}
如果我使用上面的过滤器 response.containsHeader("SET-COOKIE") 或 response.containsHeader("Set-Cookie") 总是返回 false
谁能给我解决jboss 4.0 Jsessionid标志配置为安全和httponly的解决方案