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
You could use Java Runtime-object to run the command line commands that suit your needs. Runtime API
It's too late to answer the question but may be helpful for others. JSch library http://www.jcraft.com/jsch/ can help to achieve this. Below method will return string if authentication is successful otherwise it will throw an exception.
public String authenticate(String host, String user, String password) throws JSchException {
JSch jsch = new JSch();
Session session = jsch.getSession(user, host, 22);
session.setPassword(password);
Properties obj_Properties = new Properties();
obj_Properties.put("StrictHostKeyChecking", "no");
session.setConfig(obj_Properties);
session.connect(5000);
String version = session.getServerVersion();
session.disconnect();
return version;
}