Sign java applet step by step [duplicate]
I'm writing a java applet that uses org.apache.commons.net.ftp.FTP to upload a file to an ftp server from a webpage
the applet works in eclipse..
My project contains Uploader.java, FtpUpload_thread.java and the commons-net-2.2.jar (to import org.apache.commons.net.ftp.FTP) files..
I compile my classes using the cmd command:
javac *.java -cp *.jar
I put the class in html:
<applet code="Uploader.class" codebase="./" archive="commons-net-2.2.jar" width="600" height="230"></applet>
but when I try to establish the connection I get the error:
java.secur开发者_如何学Pythonity.AccessControlException: access denied (java.net.SocketPermission /*myftp*/ resolve)
So I have to sign my applet..
I make my jar file:
jar cvf Uploader.jar Uploader.class FtpUpload_thread.class commons-net-2.2.jar
I generate keys:
keytool -genkey -alias signFiles -keystore compstore
and then I put the values that the program requires.. now I have the compstore database file
I Sign the JAR File
jarsigner -keystore compstore -storepass pass -keypass pass -signedjar UploaderS.jar Uploader.jar signFiles
and I have the UploaderS.jar file
so now I have my folder with:
Uploader.jar
UploaderS.jar
compstore
Uploader.class
commons-net-2.2.jar
FtpUpload_thread.class
it's all or I need other steps?
what is the html code to put my sign applet and run it with permissions?
thanks!
I would recommend utilizing the java plugin as opposed to the <applet> tag.
You will have to specify all the jars required by your class and use the signed archive
<object classid="clsid:CAFEEFAC-0016-0000-0000-ABCDEFFEDCBA" width="600" height="230">
<param name="code" value="Uploader" />
<param name="java_archive" value="UploaderS.jar, commons-net.jar" />
<comment>
<embed width="600" height="230" code="Uploader" type="application/x-java-applet;version=1.6" archive="UploaderS.jar, commons-net.jar">
<noembed>
No Java Support.
</noembed>
</embed>
</comment>
</object>
I would also recommend putting a package on your applet class.
I am not sure how to go about specifying the permissions to use by the applet.
Hope this helps.
精彩评论