0

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.security.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!

Roman C
  • 49,761
  • 33
  • 66
  • 176
frx08
  • 4,222
  • 8
  • 37
  • 45
  • I solve it recompiling all the Apache library putted together with my classes so I generate an unique jar file and then I signed it – frx08 Jan 20 '11 at 23:08

1 Answers1

0

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.

Dave G
  • 9,639
  • 36
  • 41
  • 1
    1) I would recommend using the deployJava.js script that handles all that mess of applet/object/embed. 2) If this applet is coming from the same server as it is uploading to, the only reason it needs signing would be to access the files to upload. 3) If the user has the new generation plug-in (Java 1.6.0_10+) it can be deployed using JWS and use the JNLP API. The JNLP API allows even sand-boxed (unsigned) apps. to access the local file-system. – Andrew Thompson Jan 21 '11 at 05:52
  • @Andrew very good point. Can you add a reference to the documentation for deployJava.js and the webstart JNLP items? – Dave G Jan 21 '11 at 11:55