How do I check if a .jar-File has a signature and how do I verify this signature in my code in order to make sure that my code is only executed with a specific library?
Share
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.
Not sure if your question is how to programatically check it yourself or if you refer to how make Java check it automatically for you.
For the second one, you can use the security features provided with Java. First, you must digitally sign your jar file (using jarsigner tool).
Then, you have to run your program with a security manager (
System.setSecurityManager(new SecurityManager()).Finally, you have to configure your security policy file to permit that only code signed by certain entity be run by your program.
There is a tutorial in the Java Tutorial to do this.