Aniruddha
Aniruddha

Reputation: 3618

Java OS Authentication

I want to authenticate user with OS. I am getting username, password as input from user & I simply want to check with os whether that username, password is right or wrong.

I don't want to do LDAP authenticating. Only os authentication where my program is running. Second thing program should run on windows from xp on-wards, linux & if possible unix flavors.

Is there any way I can achieve that?

While googling I found : https://github.com/twall/jna

But still trying to figure out whether this library is right for my requirement or not

Upvotes: 2

Views: 2163

Answers (2)

Michael-O
Michael-O

Reputation: 18430

Use GSS-API with Kerberos if your are in an Active Directory environment.

Upvotes: 0

Srinivas M.V.
Srinivas M.V.

Reputation: 6608

Try WAFFLE windows Authentication framework

Steps for Windows Authentication using WAFFLE framework

Step1. Download following jars a.jna.jar b.waffle-jna.jar

Step 2 :Place these jars in your class folders

Step 3: Using waffle in your Java code below is the code snippet

public boolean isValidUser(String username , String password){
  WindowsAuthProviderImpl authenticationProvider = new WindowsAuthProviderImpl();
  IWindowsIdentity loggedOnUser = authenticationProvider.logonUser(username, password);
  if(!loggedOnUser.isGuest()){
        return true;
  }
   return false;
 }

Hope this helps !!

Upvotes: 1

Related Questions