简体   繁体   English

使用JSF,Hibernate和Tomcat对Web应用程序进行授权和认证

[英]Authorization and authentication on the web application with JSF, Hibernate and Tomcat

I am programming a Web-Application with Java EE, JSF, Hibernate, MySQL by using Eclipse and Apache Tomcat. 我正在通过使用Eclipse和Apache Tomcat使用Java EE,JSF,Hibernate,MySQL编写Web应用程序。 I do not use Spring, EJB or etc. 我不使用Spring,EJB等。

I have simple login page. 我有简单的登录页面。 There are two inputs for username and password and submit button to pass values of inputs to the bean. 有两个用于用户名和密码的输入,以及用于将输入值传递给Bean的Submit按钮。 If entries of users are matched with records in DB, then next page is opened. 如果用户条目与DB中的记录匹配,则打开下一页。 However, this process has a lack of security. 但是,此过程缺乏安全性。 If user enters a URL of next pages, he/she can easily skips login process without any security. 如果用户输入下一页的URL,他/她可以轻松地跳过登录过程而无需任何安全性。

I know that my application needs authentication and authorization. 我知道我的应用程序需要身份验证和授权。 I have googled these terms for three days. 我已经用谷歌搜索了三天。 I learned lots of things, but I do not have found a simple solution for the application with JSF, Hibernate and worked on Apache Tomcat. 我学到了很多东西,但是我没有找到使用JSF,Hibernate和Apache Tomcat的应用程序的简单解决方案。

Is there any simple example that contains this kind of configuration? 有没有包含这种配置的简单示例? I do not need detailed management. 我不需要详细的管理。 Just a simple authentication (also maybe authorization). 只是一个简单的身份验证(也可能是授权)。

I am really tired, please help me. 我真的好累,请帮助我。

EDIT (1): 编辑(1):

I chose "container managed authentication" as a login strategy and I develeped some code. 我选择“容器管理的身份验证”作为登录策略,并删除了一些代码。 com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'USER_NAME' in 'where clause' - container managed authentication . com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:'where子句'中的未知列'USER_NAME'-容器管理的身份验证 However, I get com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException. 但是,我得到com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException。 I hope to reach the solution, if you help me. 如果您有帮助,我希望能找到解决方案。 All feedback appreciated! 所有反馈表示赞赏!

EDIT (2): 编辑(2):

I realized that "container managed authentication" has strict rules and it limits the freedom of coding. 我意识到“容器管理的身份验证”具有严格的规则,并且限制了编码的自由度。 Programmer cannot write code based on requirements of application with this solution. 程序员无法使用该解决方案根据应用程序的要求编写代码。 Because of that, I implement Servlet-Filter solution which is old, but powerful, in my app. 因此,我在我的应用程序中实现了旧的但功能强大的Servlet-Filter解决方案。 If you want to try new ones, Apache Shiro may be an option. 如果您想尝试新的,则可以选择Apache Shiro。 I advise to look at the article of http://balusc.blogspot.com.tr/2013/01/apache-shiro-is-it-ready-for-java-ee-6.html#ProgrammaticLogin 我建议看一下http://balusc.blogspot.com.tr/2013/01/apache-shiro-is-it-ready-for-java-ee-6.html#ProgrammaticLogin的文章

Try using Spring security, it will allow to protect the application with authentication and authorization. 尝试使用Spring安全性,它将允许通过身份验证和授权保护应用程序。 See this tutorial as a starting point. 请以本教程为起点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM