java中基于表单的身份验证
我想知道如何通过数据库在java中启用基于表单的身份验证。连接数据库后,如何验证通过html页面输入的用户名和密码是否正确?
我是否必须将操作 servlet 从 j_security_check 更改为我自己定义的另一个 servlet,该 servlet 将连接到数据库并自行完成所有验证?或者我必须将身份验证信息发送到j_security_check,它将自动连接到数据库,验证用户名和密码。
我成功地通过 context.xml 文件连接到数据库,该文件位于我自己的 Web 应用程序的 META-INF 目录中,但我无法理解我还需要做什么才能启用基于表单的身份验证。
我使用 Tomcat 6 作为 Web 服务器。
I want to know how can I enable form based authentication in java through database. After connecting to database, how can I verify whether the username and password, which I'm entering through html page is correct or not?
Do I have to change action servlets from j_security_check to another my own defined servlets, which will connect to database and do all its verification on its own? Or I've to send authentication information to j_security_check, which will automatically connect to database, verify username and password.
I'm successful in connecting to database through context.xml file, which is in META-INF directory of my own web application, but I'm not able to understand what's more I've to do enable form based authentication.
I'm using Tomcat 6 as web server.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
就我个人而言,我在webapp的context.xml中使用DataSourceRealm:
并且我在tomcat的server.xml中定义数据源(以允许在不同环境中使用相同的war):
表rolemap实际上是一个视图,因为数据库模型与 tomcat 期望的模型不同。
Personally I use a DataSourceRealm in the context.xml of the webapp:
And I define the datasource in the server.xml of tomcat (to allow the use of the same war in different environments):
the table rolemap is actually a view because the database model is different from the one that tomcat is expecting.