在WAS下创建安全应用程序

本文介绍如何在Web应用中配置安全性,包括在web.xml文件中设置安全角色、约束及登录配置等步骤,确保只有认证用户能访问特定资源。

第一步:启用全局安全性,指定用户注册表或自定义.

第二步:在web.xml里增加安全角色

  <security-constraint>
    <display-name>everyone</display-name>
    <web-resource-collection id="WebResourceCollection_1113720484159">
      <web-resource-name>AdminPages</web-resource-name>
      <url-pattern>/servlet/*</url-pattern>
      <url-pattern>*.do</url-pattern>
      <url-pattern>*.jsp</url-pattern>
      <http-method>GET</http-method>
      <http-method>POST</http-method>
    </web-resource-collection>
    <auth-constraint>
      <description>These are the roles who have access</description>
      <role-name>All Role</role-name>
    </auth-constraint>
   <user-data-constraint>
      <description>This is how the user data must be transmitted</description>
      <transport-guarantee>NONE</transport-guarantee>
    </user-data-constraint>
  </security-constraint>
 <login-config>
  <auth-method>FORM</auth-method>
  <form-login-config>
   <form-login-page>/denglu.jsp</form-login-page>
   <form-error-page>/error.jsp</form-error-page>
  </form-login-config>
 </login-config> 
 <security-role>
  <description>All Authenticated User Role</description>
  <role-name>All Role</role-name>
 </security-role>
这样只有通过认证的用户才能访问受保护的资源 

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值