Java RESTful客户端[RESTEasy或Apache HttpClient]-另一端是NTLM [英] Java RESTful client [RESTEasy or Apache HttpClient] - NTLM on the other side

查看:193
本文介绍了Java RESTful客户端[RESTEasy或Apache HttpClient]-另一端是NTLM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何调用RESTful Web服务(从Java-使用RESTEasy/Apache HttpClient),需要在Active Directory中进行NTLM身份验证,而无需再次输入用户数据(域,用户名,密码)-用户已经在Windows中进行了身份验证?

How to call RESTful webservice (from Java - using RESTEasy/Apache HttpClient) which requires NTLM authentication within Active Directory, without necessity of entering user data again (domain, username, password) - user is already authenticated in Windows?

GET http://some_server/restapi/books

这在Web浏览器甚至java.net.URL库中都非常有效-不会提示用户输入凭据,不会出现401身份验证错误-只需返回200 OK.

This works perfectly from web browsers or even java.net.URL library - user is not getting prompted for credentials, no 401 authentication errors - simply 200 OK is returned.

如何使用Apache HttpClient或RESTEasy客户端执行相同操作?

How to do the same using Apache HttpClient or RESTEasy client?

推荐答案

您可以使用此结构;

  1. 用户首次输入用户名和密码时,可以检查用户 活动目录的详细信息,如果成功,则通过创建一个access_token 使用用户名和密码.可能是sha-256加密(请在此处用于创建sha-256)
  2. 将该access_token保存到您的数据库中,并给它一个过期时间.
  3. 成功创建access_token后,将该访问令牌响应至 用户.
  4. 从现在开始,您可以使用access_token进行服务请求
  1. When user first enter username and password, you can check user detail on active directory and if success, create an access_token by using username and password. It may be sha-256 encryption(Refer here for creating sha-256)
  2. Save that access_token to your db and give it an expire time.
  3. After successful access_token creation, respond that access token to user.
  4. From now, you can use access_token for service requests

您需要像本地存储一样在客户端上保存访问令牌.与您使用时相同 http客户端,您可以在标头中提供该access_token.

You need to save access token on client side like local storage. Same as if you are useing http client, you can give that access_token in header.

这篇关于Java RESTful客户端[RESTEasy或Apache HttpClient]-另一端是NTLM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆