views:

179

answers:

2

Hi all,

I have a username and password for a particular user in Linux i need to verify that if the user is valid or not using java?

Abdul Khaliq

+1  A: 

You could use Java Runtime-object to run the command line commands that suit your needs. Runtime API

Kuytu
can u suggest such command in linux?
Abdul Khaliq
There are probably several ways to do it. One might be using 'su' -command and seeing if the login is succesful or not. It might also be possible to parse the password file, but that sounds quite unsecure.
Kuytu
Actually with su command i can verify the username but not the password of a given user can u suggest a command to verify both parameters ?
Abdul Khaliq
+4  A: 

The Java way to do this would be JAAS, but you'll still need a LoginModule that works with Linux. Here's a beta implementation that claims to work.

Michael Borgwardt