简体   繁体   English

具有Android应用程序的Java / Tomcat服务器中的Windows身份验证

[英]Windows authentication in a Java/Tomcat server with an Android app

My project is an Android application that communicates with a server. 我的项目是一个与服务器通信的Android应用程序。 The server is written in Java, deployed in Tomcat, and running on a Windows Server host. 该服务器用Java编写,部署在Tomcat中,并在Windows Server主机上运行。

I need to provide authentication against Windows domain accounts. 我需要针对Windows域帐户提供身份验证。 Basically I need to ask the user of the app to type in their username and password; 基本上,我需要让应用程序的用户输入他们的用户名和密码; send this data to the Tomcat server; 将此数据发送到Tomcat服务器; and have the server authenticate it. 并让服务器对其进行身份验证。

I'm having trouble finding a straight answer as to how to do this. 我很难找到关于如何执行此操作的直接答案。 Since my app is not a web site, I don't have the option to do browser redirects or anything like that, and obviously the Android device on which the app runs is not a Windows machine and will most likely not even be on the local network. 由于我的应用程序不是网站,因此我没有选择进行浏览器重定向之类的操作,并且显然运行该应用程序的Android设备不是Windows计算机,而且很可能不在本地计算机上网络。

I don't really need to execute anything as the Windows user, I just need to know that they are who they say they are. 作为Windows用户,我实际上不需要执行任何操作,我只需要知道他们就是他们所说的那个人。 Hopefully there is a simple way to do this? 希望有一个简单的方法可以做到这一点?

Thanks. 谢谢。

Assuming you want to use Java EE container-based form authentication, on the server you'll have to: 假设您要使用基于Java EE容器的表单身份验证,在服务器上,您必须:

On the client, you can: 在客户端上,您可以:

  • POST application/x-www-form-urlencoded login data with the special keys in the web form ( j_password , etc.) POST应用程序/ x-www-form-urlencoded登录数据,带有Web表单中的特殊键( j_password等)
  • retain the session cookies in the response for subsequent interactions with the server 在响应中保留会话cookie,以便与服务器进行后续交互

I haven't tested the specifics with these exact technologies but approach is sound. 我没有使用这些确切的技术测试具体细节,但是方法是合理的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM