java http 摘要认证_Tomcat - 设置 HTTP 摘要认证

在 Tomcat 中设置 HTTP 摘要认证的示例

在 Tomcat 中设置摘要认证与设置基本认证几乎一样,差别在于配置 web.xml 时, 元素在指定认证方法时,基本认证设置 auth-method 为 BASIC,而摘要认证设置 auth-method 为 DIGEST:

DIGEST

hueyhome

测试:

a) 无认证信息请求

C:\Users\huey> curl -I http://localhost:8080/helloweb/home/index.html

HTTP/1.1 401 Unauthorized

Server: Apache-Coyote/1.1

Pragma: No-cache

Cache-Control: no-cache

Expires: Thu, 01 Jan 1970 08:00:00 CST

WWW-Authenticate: Digest realm="hueyhome", qop="auth", nonce="1463129892972:deeaa87bec6be4057899dac852625e9c", opaque="AECB8C2E17E7F66CF7905F638B7463EA"

Content-Type: text/html;charset=utf-8

Content-Length: 951

Date: Fri, 13 May 2016 08:58:12 GMT

b) 正确认证信息且该用户无指定资源的访问权限

C:\Users\huey>curl -I --digest -u "all:all" http://localhost:8080/helloweb/home/index.html

HTTP/1.1 401 Unauthorized

Server: Apache-Coyote/1.1

Pragma: No-cache

Cache-Control: no-cache

Expires: Thu, 01 Jan 1970 08:00:00 CST

WWW-Authenticate: Digest realm="hueyhome", qop="auth", nonce="1463130123893:17b1a3bc2383eb5742e8d34e036fe75d", opaque="AECB8C2E17E7F66CF7905F638B7463EA"

Content-Type: text/html;charset=utf-8

Content-Length: 951

Date: Fri, 13 May 2016 09:02:03 GMT

HTTP/1.1 200 OK

Server: Apache-Coyote/1.1

Pragma: No-cache

Cache-Control: no-cache

Expires: Thu, 01 Jan 1970 08:00:00 CST

Accept-Ranges: bytes

ETag: W/"250-1463128711512"

Last-Modified: Fri, 13 May 2016 08:38:31 GMT

Content-Type: text/html

Content-Length: 250

Date: Fri, 13 May 2016 09:02:04 GMT

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值