Validate a user permission over an object
From Kasai documentation
Finally you'll probably want to validate if a user has the required rights to perform a certain action over an object in your application. The following example checks whether the "jdoe" user can modify the data of the "admin" user.
import org.manentia.kasai.KasaiFacade;
public class CheckPermission {
public static void main(String args[]){
try {
KasaiFacade.getInstance().validateOperative("jdoe",
"kasai.user.commit", "/kasai/user/admin");
System.out.println("jdoe can modify the admin user data");
} catch (Exception e){
System.out.println("jdoe can not modify the admin user data, reason: " +
e.getMessage());
}
}
}
The validateOperative() method receives the user's login, the operative that he wants to perform and the object over which the action will be performed, and raises an exception if the authorization fails.
You can alternatively use the checkOperative() method that instead of raising an exception will return true or false, indicating whether the user has the required authorization or not.

