Java RESTful client [RESTEasy or Apache HttpClient] - NTLM on the other side

筅森魡賤 提交于 2019-12-12 06:30:12

问题


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

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.

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


回答1:


You can do that with this structure;

  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

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.



来源:https://stackoverflow.com/questions/21256034/java-restful-client-resteasy-or-apache-httpclient-ntlm-on-the-other-side

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!