zoukankan      html  css  js  c++  java
  • Tomcat安全域

    安全域概念:

      是tomcat的内置功能,,org.apache.catalina.Realm接口声明了将一组用户名、密码以及所关联的角色集成到Tomcat的方法。

    提供了以下8种安全域类型:

        1.内存域(MemoryRealm):访问以一组对象的形式存放在内存中的安全认证信息。服务启动时,会从XML(conf/tomcat-users.xml)中读取安全认证信息并初始化。

        2.用户数据库域(UserDatabaseRealm):访问JNDL资源中用户数据库的安全认证信息。通常以xml文件的形式存放。

       3.JDBC域:通过JDBC驱动程序访问存放在数据库中的安全验证信息。

       4.数据源域、JNDL域、JAAS域、混合域、LoclOut域。

    二、安全域的基本配置

       首先,在web.xml配置文件中为web资源设置安全约束,需配置<security-constraint>和<login-config>

    然后在server.xml或context.xml中配置<Realm><Engine>所有虚拟主机共享</><Host>本虚拟主机所有web共享</><Context>本web应用共享

    案例:

    <security-constraint>
    <display-name>Test Security</display-name>
    <web-resource-collection>
         <web-resorce-name>Protected</web-resource-name>
         <url-pattern>/protected/*</url-pattern>
         <http-method>GET</http-method>
         <http-method>POST</http-method>
    </web-resource-collection>
    <auth-constraint>
          <role-name>admin</role-name>
    </auth-constraint>
    </security-constraint>
    
    <login-config>
       <auth-method>FROM</auth-method>(三种验证,basic基本验证,DIGEST摘要验证)
       <realm-name>登录表单验证</realm-name>
       <form-login-config>
          <form-login-page>/login.jsp</form-login-page>
          <form-error-page>/error.jsp</form-error-page>
       </form-login-config>
    </login-config>
  • 相关阅读:
    POJ 3356 水LCS
    POJ 2250 (LCS,经典输出LCS序列 dfs)
    POJ 1080( LCS变形)
    整数划分问题之最大乘积
    进程调度之FCFS算法(先来先运行算法)
    c模拟银行家资源分配算法
    c模拟内存分配算法(首次适应算法,最佳适应算法,最坏适应算法)
    HDU 2602 Bone Collector(经典01背包问题)
    NYOJ 44 字串和 (最大字串和 线性dp)
    匈牙利游戏(codevs 1269)
  • 原文地址:https://www.cnblogs.com/HYV587/p/14467508.html
Copyright © 2011-2022 走看看