如何实现HTTP DIGEST认证

http://robblog.javaeye.com/blog/556436

http://advosys.ca/papers/web/63-http-digest-authentication.html

http://httpd.apache.org/

http://articles.techrepublic.com.com/5100-10878_11-5860901.html

http://www.yolinux.com/TUTORIALS/LinuxTutorialApacheAddingLoginSiteProtection.html

http://download.oracle.com/javaee/1.4/tutorial/doc/Security5.html

http://httpd.apache.org/docs/2.2/howto/auth.html

http://www.faqs.org/rfcs/rfc2617.html

http://www.webdavsystem.com/javaserver/doc/authentication

http://www.cafesoft.com/products/cams/tomcat-security.html

上面是一些参考的网络资料:

具体步骤如下:

1、在tomcat服务器下的webapps下新建一个digesttest的文件夹,在该文件夹下新建一个test的文件夹,进入test文件夹,在该文件夹下新建一个index.jsp。(jsp的内容可以随便选择,比如说是一个随意的网页的代码)

2、在digesttest新建一个WEB-INF的文件夹,在该文件夹下新建一个web.xml文件。内容如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
 xmlns="http://java.sun.com/xml/ns/javaee"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
 http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
   <security-constraint> 
    <web-resource-collection> 
        <web-resource-name> 
            My App  
        </web-resource-name> 
        <url-pattern>/test/*</url-pattern> 
    </web-resource-collection> 
    <auth-constraint> 
        <role-name>tomcat</role-name> 
    </auth-constraint> 
   </security-constraint> 
   <login-config> 
    <auth-method>DIGEST</auth-method>  <!-- DIGEST here --> 
    <realm-name>My Realm</realm-name> 
   </login-config>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>
3、在tomcat\conf下搜索tomcat-users.xml文件,打开编辑,添加一个用户,密码和角色。用户名为:test;密码:test;角色可以是默认的tomcat或者自己定义的。

4、重启tomcat服务器,在地址栏如入http://localhost:8080/digesttest/test/index.jsp。就会弹出来一个对话框,在其中输入你在tomcat-users.xml下新设置的用户名和密码(test,test)。就会跳转到该页面。

如何实现HTTP <wbr>DIGEST认证

5、如果不跳转,可能有以下原因,1)重启tomcat服务器2)新打开一个ie页面,在其下输入上述地址重试。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值