在我的项目中,我使用SSL,但它适用于所有页面。我只想将它用于登录页面,在该页面之后,它应该恢复为HTTP协议。我该怎么做呢?我在下面找到了一种方法,但它不起作用。
<security-constraint>
<web-resource-collection>
<web-resource-name>Notify page, accessed internally by application</web-resource-name>
<url-pattern>/Login.xhtml</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>Entire Site</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>我的项目是一个JSF2.0项目,我使用的是Eclipse Helios和Tomcat7.0。
谢谢。
发布于 2011-05-11 19:29:01
这不可能。当通过HTTPS请求创建会话时,它对HTTP请求不可用。最好的办法是在登录过程中自己创建一个不安全的cookie,并通过它来维护登录。
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("secure", false);
externalContext.addResponseCookie(name, value, properties);但是再想一想,HTTPS登录有什么意义呢?如果您在HTTPS之后返回到HTTP,并且希望让用户保持登录状态,则需要将会话cookie设置为不安全。通过这种方式,黑客仍然能够嗅探cookie中的会话ID来进行session fixation攻击。通过HTTPS登录,您只能防止黑客了解实际的用户名/密码,但一旦黑客在cookie中计算出会话ID,这就没有意义了。
我会说,忘记开关,在登录后一直坚持使用HTTPS。
https://stackoverflow.com/questions/5958881
复制相似问题