Buh*_*ndi 7 java https jsf-2 servlet-filters
我有一个带有2个属性的托管bean:userName&password(带有各自的getter和setter方法),以及一个login()访问数据库以验证登录凭据的方法.
我的问题是,当用户点击"登录"按钮时,操作必须通过https协议.我如何用JSF 2实现这一目标?
另外,如果我想要保护一些Faces(在https协议下),我该如何实现?是否有过滤器可以让我这样做?
提前致谢.
您可以在应用程序的web.xml中定义安全性约束:
<security-constraint>
<web-resource-collection>
<web-resource-name>SecureConnection</web-resource-name>
<url-pattern>*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint/>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
Run Code Online (Sandbox Code Playgroud)
调整url-pattern以包含登录页面和所有其他安全页面.https的使用由user-data-constraint定义.
如果将CONFIDENTIAL或INTEGRAL指定为安全性约束,则通常意味着需要使用SSL并应用于与Web资源集合中的URL模式匹配的所有请求,而不仅仅是登录对话框.
如果您编写了自己的login()方法并使用了Glassfish,则可以使用JDBCRealm作为替代登录方法来查看基于容器的身份验证.
| 归档时间: |
|
| 查看次数: |
9102 次 |
| 最近记录: |