我无法使用BASIC身份验证来使用Glassfish.我正在开发一个应用程序,我需要提示输入用户名和密码.当我尝试访问应用程序时,我已经让应用程序提示我输入密码,但在输入正确的登录信息后,我得到了HTTP Status 403 - Access to the requested resource has been denied.
我已进入Glassfish管理控制台并在file领域中创建了一些示例用户并启用了安全管理器.
接下来,在我的web.xml文件中,我添加了以下内容:
<security-constraint>
<web-resource-collection>
<web-resource-name>Secure Application</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>User</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>file</realm-name>
</login-config>
<security-role>
<role-name>User</role-name>
</security-role>
Run Code Online (Sandbox Code Playgroud)
我不确定接下来要做什么.我找了好几个小时都没有运气.验证有效,因为如果我输入错误的登录信息,它会再次提示,但在成功验证后,我会收到上面显示的拒绝访问消息.
如果它有帮助,我运行Glassfish Open Source 3.0.1并使用Netbeans 6.9进行开发.