findango
findango

Reputation: 1483

How do I access Windows credentials from Java?

How do I (or can I?) retrieve the cached credentials for the currently logged-in Windows user in Java? I want to reuse these credentials in some other GSS-API calls. Specifically, I'm answering an SPNEGO challenge from IIS.

Thanks.

Upvotes: 8

Views: 22382

Answers (2)

Pat Gonzalez
Pat Gonzalez

Reputation: 249

If IIS has Integrated Windows Authentication turned on, then you can still access the protected page by using the http://spnego.sourceforge.net/api/net/sourceforge/spnego/SpnegoHttpURLConnection.html class. This open source project's "credential delegation" tutorial also uses the SpnegoHttpURLConnection class.

Upvotes: 0

northpole
northpole

Reputation: 10346

assuming you are using JAVA 5:

com.sun.security.auth.module.NTSystem NTSystem = new com.sun.security.auth.module.NTSystem();
System.out.println(NTSystem.getName());

here is some info on the subject

Upvotes: 10

Related Questions