java – Web APplication的容器管理安全性

我对Container托管安全性完全不熟悉,需要一些帮助才能在我的Web应用程序中进行配置.

我想在我的Web应用程序中限制对jsp的访问.这就是我在web.xml中配置安全性的方法

我的问题是:

login-config元素中realm-name的用途是什么?
我在哪里配置用户名,密码并将用户映射到角色?

当我尝试访问我的Web应用程序中的jsp时,我会被要求输入用户名和密码.我在那里放什么?这种安全机制如何运作?

我对安全性完全陌生,所以如果有人能指出一篇很好的文章来解释配置安全性的基础知识及其实际工作方式,我将不胜感激.

最佳答案

Q: “What is the purpose of realm-name in the login-config element?”

Java EE 6 tutorial

A realm is a security policy domain defined for a web or application server. A realm contains a collection of users,who may or may not be assigned to a group.

在当前Servlet 3.0 spec中定义的行为:

HTTP Basic Authentication,which is based on a username and password,
is the authentication mechanism defined in the HTTP/1.0 specification.
A web server requests a web client to authenticate the user. As part
of the request,the web server passes the realm (a string) in which
the user is to be authenticated. The web client obtains the username
and the password from the user and transmits them to the web server.
The web server then authenticates the user in the specified realm.

Q: “Where do i configure the username,passwords and map the users to the roles?”

这是特定于容器的.也就是说,每个服务器供应商都可以自由定义如何定义用户/组以及如何配置此信息.通常有多种方法可以做到这一点.

用户和组通常在目录中定义.然后,服务器配置为使用此目录,管理员将在部署时映射应用程序角色.

开发人员Tomcat测试服务器可能使用平面文件;生产WebSphere服务器可能通过LDAP挂钩到公司的Exchange目录.

有关更多信息,请参阅服务器文档.

你可能会比遵循Netbeans和Glassfish的Oracle Java EE 6教程更糟糕,但要注意特定于该供应商产品的步骤.

相关文章

摘要: 原创出处 https://www.bysocket.com 「公众号:泥瓦匠...
摘要: 原创出处 https://www.bysocket.com 「公众号:泥瓦匠...
今天犯了个错:“接口变动,伤筋动骨,除非你确定只有你一个...
Writer :BYSocket(泥沙砖瓦浆木匠)微 博:BYSocket豆 瓣:...
本文目录 线程与多线程 线程的运行与创建 线程的状态 1 线程...