【发布时间】:2012-05-22 17:26:48
【问题描述】:
我正在使用 WebSphere 7。我有一个使用 web.xml 设置的简单示例,如下所示。
这是我测试它的方式:
我从 WebSphere 中没有用户和组开始
我尝试访问页面 (/restricted/topsecret.html) 我被提示登录。我不能。
我使用 WebSphere 管理控制台添加了用户/密码“rob/password”。我现在可以登录,但看不到页面。我收到“403:授权失败”错误。
我添加了一个名为“ROLE1”的组,并使用 WebSphere 管理控制台将该组分配给用户“rob”。我重启了firefox,我仍然可以登录,但我仍然收到“403”错误。
我写了一个小JSP(如下)来输出登录的用户名,但即使登录后用户名仍然为空。
知道我做错了什么吗?谢谢!
罗伯
<security-constraint>
<web-resource-collection>
<web-resource-name>page test 1</web-resource-name>
<url-pattern>/restricted/topsecret.html</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>ROLE1</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
usertest.jsp
<%@ page session="true" %>
Logged in username = '<%= request.getRemoteUser() %>' // is always null
<p/>
Logged in username = '<%= request.getUserPrincipal() %>' // is always null
【问题讨论】:
标签: java authentication websphere web.xml