Glassfish中的基本身份验证

Glassfish中的基本身份验证

本文介绍了Glassfish中的基本身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法使用Glassfish进行BASIC认证。我正在开发一个应用程序,我需要提示输入用户名和密码。当我尝试访问应用程序时,我已经得到应用程序提示输入密码,但是在输入正确的登录信息后,我得到 HTTP状态403 - 访问请求的资源已被拒绝

我进入了Glassfish管理控制台,并在文件中创建了一些示例用户。领域并启用了安全管理器。


$ b 接下来,在我的 web.xml 文件中,我添加了以下内容:

 < security-constraint> 
< web-resource-collection>
< web-resource-name>安全应用程序< / web-resource-name>
< url-pattern> / *< / url-pattern>
< http-method> GET< / http-method>
< http-method> POST< / http-method>
< / web-resource-collection>

< auth-constraint>
<角色名称>用户< /角色名称>
< / auth-constraint>
< / security-constraint>

< login-config>
< auth-method> BASIC< / auth-method>
< realm-name>档案< / realm-name>
< / login-config>

< security-role>
<角色名称>用户< /角色名称>
< / security-role>

我不确定接下来要做什么。我搜索了几个小时,没有运气。如果我输入了不正确的登录信息,它会再次提示,但是在成功验证后,我得到上面显示的拒绝访问信息。



如果有帮助,我是运行Glassfish Open Source 3.0.1并使用Netbeans 6.9进行开发。

解决方案

我不确定是否应用了默认值,但您可以需要创建 sun-web.xml 并为角色User设置映射:

 < ; sun-web-app error-url => 
...
< security-role-mapping>
<角色名称>用户< /角色名称>
< group-name> filerealm-group-name< / group-name>
< / security-role-mapping>
...
< / sun-web-app>


I am having trouble getting BASIC authentication to work with Glassfish. I am developing an application and I need to be prompted for a username and password. I have gotten the application to prompt me for a password when I attempt to access the application, but after entering the correct login information, I get HTTP Status 403 - Access to the requested resource has been denied.

I have gone into the Glassfish Admin Console and created a few sample users in the file realm and enabled the Security Manager.

Next, in my web.xml file, I have added the following:

<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>

I'm not exactly sure what to do next. I have searched for several hours with no luck. The authentication works because if I enter incorrect login information, it prompts again, but after successfully authenticating, I get the access denied message shown above.

If it helps, I am running Glassfish Open Source 3.0.1 and using Netbeans 6.9 for development.

解决方案

I'm not sure if defaults apply but you may need to create sun-web.xml and set a mapping for role "User":

<sun-web-app error-url="">
  ...
  <security-role-mapping>
    <role-name>User</role-name>
    <group-name>filerealm-group-name</group-name>
  </security-role-mapping>
  ...
</sun-web-app>

这篇关于Glassfish中的基本身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 09:56