NTLM token verification in Java

旧巷老猫 提交于 2019-12-13 03:37:47

问题


I want to verify/authenticate the type3message that Apache httpd server has received from the client browser and passed to Apache Tomcat. I am just not able to figure out how to do it.

I have the following mechanism in place as depicted here. C is the client. S1 is the Apache httpd server and S2 is the Apache Tomcat server.

1. C -> S1  GET ...
2. S1 -> C  401 Unauthorized
         WWW-Authenticate: NTLM
3. C -> S1  GET ... (type 1 message)
         Authorization: NTLM TlRMTVNTUAABAAAAA7IAAAoACgApAAAACQAJACAAAABMSUdIVENJVFlVUlNBLU1JTk9S
4. S1 -> C  401 Unauthorized (type 2 message)
         WWW-Authenticate: NTLM TlRMTVNTUAACAAAAAAAAACgAAAABggAAU3J2Tm9uY2UAAAAAAAAAAA==
5. C -> S1  GET ... (type 3 message)
         Authorization: NTLM TlRMTVNTUAADAAAAGAAYAHIAAAAYABgAigAAABQAFABAAAAADAAMAFQAAAASABIAYAAAAAAAAACiAAAAAYIAAFUAUgBTAEEALQBNAEkATgBPAFIAWgBhAHAAaABvAGQATABJAEcASABUAEMASQBUAFkArYfKbe/jRoW5xDxHeoxC1gBmfWiS5+iX4OAN4xBKG/IFPwfH3agtPEia6YnhsADT
6. S1 -> S2 Challenge - TlRMTVNTUAACAAAAAAAAACgAAAABggAAU3J2Tm9uY2UAAAAAAAAAAA==
         Token - TlRMTVNTUAADAAAAGAAYAHIAAAAYABgAigAAABQAFABAAAAADAAMAFQAAAASABIAYAAAAAAAAACiAAAAAYIAAFUAUgBTAEEALQBNAEkATgBPAFIAWgBhAHAAaABvAGQATABJAEcASABUAEMASQBUAFkArYfKbe/jRoW5xDxHeoxC1gBmfWiS5+iX4OAN4xBKG/IFPwfH3agtPEia6YnhsADT
7. S2 -> S1 Authenticated or Not Authenticated
8. S1 -> C  200 Ok or 401 Unauhorized

In the Apache Tomcat server, I want to authenticate the user. I have the challenge/type2message the Apache httpd server sent to the client in step 4 and the type3message that the client responded with in step 5.

I am doing the following, however, I get an exception. I am missing some basic stuff like setting the configuration and/or the environment but for some reason my brain refuses to work.

 NtlmPasswordAuthentication np = new NtlmPasswordAuthentication(t3m.getDomain(), t3m.getUser(), serverChallenge, t3m.getLMResponse(), t3m.getNTResponse());
 InetAddress ia = InetAddress.getByName("domain");
 UniAddress ua = new UniAddress(ia);
 SmbSession.logon(ua, np); // exception is here

Am I doing it correct? I want to authenticate the user.

来源:https://stackoverflow.com/questions/25792274/ntlm-token-verification-in-java

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