加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java-ee – 在Websphere7中启用基于角色的安全性

发布时间:2020-12-15 02:35:47 所属栏目:Java 来源:网络整理
导读:我的Web应用程序(使用struts2创建,包含2页 1)提出请求 2)批准请求 )部署在websphere 7.我需要为此应用程序启用基于角色的安全性.我有两个角色 1)用户(谁可以提出请求) 2)审批 两者都有不同的凭据.我没有使用任何后端进行身份验证.如何使用web.xml和映射用户
我的Web应用程序(使用struts2创建,包含2页

> 1)提出请求
> 2)批准请求

)部署在websphere 7.我需要为此应用程序启用基于角色的安全性.我有两个角色

1)用户(谁可以提出请求)

2)审批

两者都有不同的凭据.我没有使用任何后端进行身份验证.如何使用web.xml和映射用户使用websphere安全功能来执行此操作.

解决方法

我邀请您阅读 JavaEE 6 Tutorial chapter “Getting Started Securing Web Applications”,特别是提供了示例.

您的应用程序必须声明两个安全角色user和approver,并且web.xml必须保护servlet路径,这要归功于安全性约束.

以下是这样的设置作为起点:

<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作为身份验证和权限的后端,强烈建议使用.

运行应用程序的服务器实例默认配置为使用全局安全性,但您可以为服务器/应用程序对创建专用安全域以使用专用后端.这是network deployment reference documentation security section指导您的方面.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读