栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何在不更改tomcat-users.xml的情况下为静态tomcat Web应用程序提供基本的HTTP身份验证?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何在不更改tomcat-users.xml的情况下为静态tomcat Web应用程序提供基本的HTTP身份验证?

我在这里找到了解决方案:http
:
//wiki.metawerx.net/wiki/SecuringYourSiteWithContainerManagedSecurity

该页面介绍了如何定义

meta-INF/context.xml
指向您自己的
WEB-INF/users.xml
。不幸的是,到users.xml文件的链接必须是绝对的,并且我不想对我的配置文件中的OS /文件系统路径做任何假设。

这是我目前的情况

WEB-INF/web.xml

<?xml version="1.0" encoding="ISO-8859-1"?><web-app    xmlns="http://java.sun.com/xml/ns/j2ee"    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd"    version="2.5">    <display-name>SuperCoolTool</display-name>    <description>What an awesome app!</description>    <security-role>        <role-name>manager</role-name>    </security-role>    <security-role>        <role-name>keyuser</role-name>    </security-role>    <security-constraint>        <web-resource-collection> <web-resource-name>     Entire Application </web-resource-name> <url-pattern>/*</url-pattern>        </web-resource-collection>        <auth-constraint> <role-name>keyuser</role-name> <role-name>manager</role-name>        </auth-constraint>    </security-constraint>    <login-config>        <auth-method>BASIC</auth-method>        <realm-name>evaluation Area</realm-name>    </login-config></web-app>

匹配

meta-INF/context.xml
如下所示:

<?xml version="1.0" encoding="UTF-8"?><Context>    <Realm className="org.apache.catalina.realm.MemoryRealm"pathname="[PATH-TO-YOUR-WEBAPP]/WEB-INF/users.xml"/></Context>


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/447399.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号