Validate a local user using a standalone application
From Kasai documentation
To validate a user's login and password is one the first things you would like to do in any multi-user application. The following class validates a user whos login and password are passed as command-line arguments to it's main method.
import org.manentia.kasai.KasaiFacade;
public class UserValidator {
public static void main(String args[]){
try {
String login = args[0];
String password = args[1];
KasaiFacade.getInstance().checkPasswordUser(login, password, null);
System.out.println("User successfully validated");
} catch (Exception e){
System.out.println("User could not be validated, reason: " + e.getMessage());
}
}
}
As you can imagine, the bold line is the only one really interesting in this example. Most of Kasai's functionality is available through the org.manentia.kasai.KasaiFacade class. This class doesn't have a public constructor, and you should get an instance through it's getInstance() method.
The checkPasswordUser() method receives the user's login, password and ip address (optional) and validates them against the configured authentication service (through the auth.service key in the Config.properties file). If the validation isn't successful (due to an invalid username or password, or because of another exceptional reason like the database not being accessible) an exception is raised describing the reason.

