0

我正在为我的简单 web 应用程序使用基于 websphere 7 文件的基本安全性。我的应用程序包含两个屏幕 1.Add Partner 2.List Partner。为此,我创建了两个角色 1.AddPartner 2.ListPartner。我用不同的用户名和密码映射了这两个角色。当用户单击 AddPartner 链接时,它应该要求提供凭据,就像 ListPartner 链接一样。下面是我的 web.xml 条目(我正在使用 strut2 约定)

<security-constraint>
    <web-resource-collection>
        <web-resource-name>servicepartner</web-resource-name>
        <url-pattern>/add-partner</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>AddPartner</role-name>
    </auth-constraint>
</security-constraint>

<security-constraint>
    <web-resource-collection>
    <web-resource-name>servicepartner</web-resource-name>
     <url-pattern>/list-partner</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>ListPartner</role-name>
    </auth-constraint>
</security-constraint>

<login-config>
    <auth-method>BASIC</auth-method>
</login-config>
<security-role>
    <role-name>AddPartner</role-name>
</security-role>
<security-role>
    <role-name>ListPartner</role-name>
</security-role>

但它适用于 AddPartner 但是当我单击 ListPartner 链接应用程序抛出 403 禁止错误,因为它检查 aganist AddPartner 凭据。我的服务器控制台出现以下错误。

Authorization failed for user commonuser:defaultWIMFileBasedRealm while invoking GET on default_host:/serviceapp/list-partner, Authorization failed, Not granted any of the required roles: ListPartner 

是否可以在单个应用程序中检查不同的凭据。请帮助我。

4

1 回答 1

1


必须完成这些步骤才能在 Web 模块中使用应用程序安全性:
1. 您必须在 WAS 中启用“应用程序安全性”
2. 您的应用程序 (web.xml) 必须定义角色、日志记录方法和资源限制。还请<realm-name>defaultWIMFileBasedRealm</realm-name>在您的<login-config>标签之间指定领域名称,例如。
3. 角色必须映射到主题(用户、组或特殊主题,例如所有经过身份验证的用户到“某些”领域。这可以在我猜 application.xml 中的 Rational Application Developer 中完成(物理写入 ibm-application- bnd.xmi) 或指定的部署时间
在此处输入图像描述

于 2013-07-22T08:21:08.817 回答