I need to know using Java if the user that executes the Java class has the required permission to change the system time.
I just need a boolean returning method.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That’s not trivial.
On Unix-based systems, you can check whether the current user has the capability
CAP_SYS_TIMEbut there is no standard way to check this from Java.On Windows, they will need admin rights but I don’t know which permission exactly. Like on Unix, there is no Java API that you could use to check.
Maybe an external script/binary could do the check. You could then use
ProcessBuilderto execute this tool.