How To Self-Sign An Applet
Objective #1: What does it mean to sign an applet.
- Signing an applet is a programmers way to let the public know that whatever they are accessing has not been tampered with since it was signed.
- This also can provide the public with information as to things like name of the person who signed it, the company they work for, where they are located, etc.
Objective #2: What is "self-signing" and why would you do this.
- Self-signing an applet means that you are signing the applet without the use of a certificate(which is usually obtained by paying for it).
- The reason for self-signing an applet is quite obvious in that it is free. This is exspecially useful if you have an application which needs to be tested from an internet browser before it can be put up.
- Advantages to signing an applet
- extra access which java applets normally don't have when put on a webpage.
- program can't be tampered with and still work(will explain further below).
- allows people to trust your applet more.
Objective #3: How do you Self-Sign an applet
- unfortunatly self-signing an applet requires access to cmd prompt so this will have to be done from home.
- this also requires knowledge as to where on your computer the following two files are: jarsigner.exe & keytool.exe (these two files should be in the same folder(in C:\Program Files\Java\jdk1.7.0_05\bin or something similar))
- for code lines things that are surrounded by * * you might want to change
- The first thing you must do is you must export your project as a .jar file (right click on project folder in eclipse, click export, follow instructions). now open cmd prompt.
- your first line: cd *"C:\Program Files\Java\jdk1.7.0_05\bin"*
- "path": This line sets cmd prompts directory to the path you put in (this should be where jarsigner and keytool reside.) (doing this saves you having to type more)
- your second line: keytool -genkey -keyalg rsa -alias *key* -validity *3650*
- key: This is the name for this particular license (change to a unique memorable name)
- 3650: This is the time (in days) which your license will be valid for(ex. 3650 makes it valid for ten years).
- after typing this in cmd prompt will generate some lines which you will enter info for(screenshot below)
- Some of the lines explained
- enter keystore password: It is very important that you remember this, if you don't then bottom line... Your on your own!!! (WHEN YOU TYPE INTO THIS LINE IT WILL NOT SHOW UP BUT I DO BELEIVE THAT THE FIRST TIME THIS IS DONE IT ASKS YOU TO VERIFY)
- enter key password for : This line will change based on your "alias" value in the second line you entered in command prompt. again when you type here it will not be shown. (this must be remembered at least for the rest of this process)
- your third line: jarsigner *"C:\Users\Jason\Documents\EclipseWorkspace\WebInterface10_Addition_of_Sockets\bin\webInterface_1_1.jar"* *test*
- "path": This is the path to your .jar file
- test: This is the value you put in for alias(in second line entered into cmd prompt)
- Congradulations your applet can now do things such as write files, store cookies, etc.
- (as of now i'm not sure how to reuse the license so anytime you change your code or any file that is within the jar(JARS CAN BE EXPLORED USING WINRAR PROGRAM) you must complete this whole process again(including export step) using a different name for the alias value (keystore password remains the same). Reason you need to redo the signing: This is the security measure that they have inplace so that your program can't be changed with out the public being notified.)
Objective #3: How to verify that you didn't FAIL.
- to verify that you succeeded just put the following line into cmd prompt: jarsigner -verify -verbose -certs *"C:\Users\Jason\Documents\EclipseWorkspace\WebInterface10_Addition_of_Sockets\bin\webInterface_1_1.jar"*
- "path": This is the path to your (what you think is) signed .jar file
- That is all there is two this, now when you put your signed applet on a webpage it will come up with the coffee cup symbol with the spinning thing around it and a dialouge box will pop up asking you if you wish to allow access for the program(if you click no then it will run the same as when you put it up unsigned(failing when tring to access files)).
P.S. don't fail by just copying and pasting these lines into cmd prompt... I toke the liberty of failing for you as you can see on the first line in my screenshot(YOU MUST REMOVE THE STARS)(QUOTES STAY (JUST TO BE SAFE)).