我的web应用程序(使用struts2创建,包含2页)
)部署在websphere 7中,我需要为这个应用程序启用基于角色的安全性。我有两个角色
1)用户(可以提出请求)
2)批准人
两者都有不同的证书。我不使用任何后端进行身份验证。如何使用web.xml的websphere安全特性和映射用户来实现这一点。
发布于 2012-07-31 13:10:41
我请您阅读JavaEE 6教程章节“入门保护网络应用程序”,特别是提供的示例。
您的应用程序必须声明两个安全角色-- user和approver,而web.xml必须保护servlet路径,这要归功于security-constraints。
下面是这样一个设置,作为一个起点:
<security-constraint>
<display-name>Raise Request</display-name>
<web-resource-collection>
<web-resource-name>raiserequestservlet</web-resource-name>
<description/>
<url-pattern>/raiserequest</url-pattern>
</web-resource-collection>
<auth-constraint>
<description/>
<role-name>user</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<display-name>Approve Request</display-name>
<web-resource-collection>
<web-resource-name>approverequestservlet</web-resource-name>
<description/>
<url-pattern>/approverequest</url-pattern>
</web-resource-collection>
<auth-constraint>
<description/>
<role-name>approver</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>WebSphere</realm-name>
</login-config>
<security-role>
<description>Security Role required to raise a request</description>
<role-name>user</role-name>
</security-role>
<security-role>
<description>Security Role required to approve a request</description>
<role-name>approver</role-name>
</security-role>对于第一次测试,我选择了基本身份验证,但还有其他选项。
然后,当将WAR包部署到WebSphere中时,向导将允许您将这两个应用程序角色映射到LDAP组,只要您使用LDAP作为后端进行身份验证和权限,这是非常推荐的。
运行应用程序的服务器实例默认配置为使用全局安全性,但可以为服务器/应用程序对创建专用安全域以使用专用后端。下面是指导您了解这些方面的网络部署参考文档安全部分。
https://stackoverflow.com/questions/11546443
复制相似问题