我正在为我的简单 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
是否可以在单个应用程序中检查不同的凭据。请帮助我。