reliable and platform-independent way of getting logged-in user in java

297 views Asked by At

We need a java application to run on both solaris and windows machines and they are kerberized. We use JGSS to get the Princiapl corresponding to the logged-in user in Solaris, by specifying the loction of credential cache that is stored in KRB5CCNAME. Since windows doesn't store the details in a file like solaris does, and since we don't want to use NTSystem to get the logged-in user's name, is there a generic way to get these details from a java program? I see a lot of references mentioning about JSSE and SSPI to get these details.

Could someone please help?

1

There are 1 answers

1
Himanshu On

There is a function which returns informations similar to what you have asked. And for logged in user name, it is used as

String username = System.getProperty("user.name");