Results 1 to 12 of 12

Thread: applet signing

  1. #1
    milkman128 is offline Member
    Join Date
    Oct 2008
    Posts
    6
    Rep Power
    0

    Default applet signing

    Java Plug-in 1.6.0_05
    Using JRE version 1.6.0_05 Java HotSpot(TM) Client VM
    User home directory = D:\Documents and Settings\dave


    ----------------------------------------------------

    ----------------------------------------------------

    OPEN CLICKED
    reading file E:\Music\arsise\\001.jpg
    Exception in thread "AWT-EventQueue-2" java.security.AccessControlException: access denied (java.io.FilePermission E:\Music\arsise\001.jpg read)
    at java.security.AccessControlContext.checkPermission (Unknown Source)
    at java.security.AccessController.checkPermission(Unk nown Source)
    at java.lang.SecurityManager.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkRead(Unknown Source)
    at java.io.FileInputStream.<init>(Unknown Source)
    at localfile.action(localfile.java:47)
    at java.awt.Component.handleEvent(Unknown Source)
    at java.awt.Component.postEvent(Unknown Source)
    at java.awt.Component.postEvent(Unknown Source)
    at java.awt.Component.postEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilter s(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(U nknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)


    This is my first time creating a signed applet or running a signed applet i didn't create much with respect to the source here: oh i cant post links so search google "java applet open file" should be the first one.

    Anyway I am pretty certain from the console output that it is a permission error and when i run it no allow or deny dialog pops up so the problem is with the signing.

    I have created a jar file as the site suggests. The contents of the jar are the manifest.mf, yourkey.sf, yourkey.rsa, and localfile.java. I have signed that jar file.

    I have a certificate (dont understand how it is accessed at runtime though) and my html is as follows:

    <HTML>
    <BODY>
    <body bgcolor="#dddddd">

    <APPLET CODE="localfile.class" archive="localfile.jar" WIDTH="600" HEIGHT="500">

    </APPLET>

    </BODY>
    </HTML>

    Is my manifest alright do I need to add something to it?


    Manifest:

    Manifest-Version: 1.0
    Created-By: 1.6.0_07 (Sun Microsystems Inc.)

    Name: C:/Sun/LocalFile.java
    SHA1-Digest:(numbers-letters=)

    I am new to this whole signing thing so any help is appreciated.

  2. #2
    Nicholas Jordan's Avatar
    Nicholas Jordan is offline Senior Member
    Join Date
    Jun 2008
    Location
    Southwest
    Posts
    1,018
    Rep Power
    8

    Default

    New to this?... trying to do Secure Hash Algorithm?....

    Uh, where are you studying? Can we get derivative mineral rights?
    Introduction to Programming Using Java.
    Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default

    There have been posts here on how to sign an applet. Use Search to find them.
    Here's one that has the batch files I used for the following test:
    http://www.java-forums.org/enterpris...gned-jars.html
    I refered to a jar file I'd signed for testing: Applet Reader
    Last edited by Norm; 10-05-2008 at 05:30 PM.

  4. #4
    milkman128 is offline Member
    Join Date
    Oct 2008
    Posts
    6
    Rep Power
    0

    Default

    Does the manifest that is automatically created need to be manipulated manually?

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default

    Not sure what you mean an automatically created manifest.
    What program are you using to do that?
    If its the jar program, then no manual changes are needed to sign the jar file.

  6. #6
    milkman128 is offline Member
    Join Date
    Oct 2008
    Posts
    6
    Rep Power
    0

    Default

    I was talking about using jar to auto create manifest, thanks for the input. I was reading around online and thought i had to do something with the manifest manually thats why i asked.

    Here is the code. I am trying to open a file from my machine and upload it to a webserver. Tried it in applet viewer and a local html received the error from above. Not sure how to fix it at this point. I have ran jar, jarsigner, and used jar signer verify all looks like its in place. Any suggestions?

    import java.applet.*;
    import java.awt.*;
    import java.util.*;
    import java.lang.*;
    import java.text.*;
    import java.awt.event.*;
    import java.io.*;

    public class localfile extends Applet {
    public localfile() {
    Panel p = new Panel();
    Font f;
    String osname = System.getProperty("os.name","");
    if (!osname.startsWith("Windows")) {
    f = new Font("Arial",Font.BOLD,10);
    } else {
    f = new Font("Verdana",Font.BOLD,12);
    }
    p.setFont(f);
    p.add(new Button("Open"));

    p.setBackground(new Color(255, 255, 255));

    add("North",p);

    }
    public boolean action(Event evt, Object arg) {
    if (arg.equals("Open")) {
    System.out.println("OPEN CLICKED");

    int arrlen = 10000;
    byte[] infile = new byte[arrlen];
    Frame parent = new Frame();
    FileDialog fd = new FileDialog(parent, "Please choose a file:",
    FileDialog.LOAD);
    fd.show();
    String selectedItem = fd.getFile();
    if (selectedItem == null) {
    // no file selected
    } else {
    File ffile = new File( fd.getDirectory() + File.separator +
    fd.getFile());
    // read the file
    System.out.println("reading file " + fd.getDirectory() +
    File.separator + fd.getFile() );
    try {
    FileInputStream fis = new FileInputStream(ffile);
    BufferedInputStream bis = new BufferedInputStream(fis);
    DataInputStream dis = new DataInputStream(bis);
    try {
    int filelength = dis.read(infile);
    String filestring = new String(infile, 0,
    filelength);
    System.out.println("FILE CONTENT=" + filestring);
    } catch(IOException iox) {
    System.out.println("File read error...");
    iox.printStackTrace();
    }
    } catch (FileNotFoundException fnf) {
    System.out.println("File not found...");
    fnf.printStackTrace();
    }
    }

    } else return false;
    return true;
    }

    }

  7. #7
    Nicholas Jordan's Avatar
    Nicholas Jordan is offline Senior Member
    Join Date
    Jun 2008
    Location
    Southwest
    Posts
    1,018
    Rep Power
    8

    Unhappy my apologies

    Quote Originally Posted by milkman128 View Post
    ....Any suggestions? .....
    Go to a simpler learning format. None of this has to do with codesigning and
    Java Code:
    Exception in thread "AWT-EventQueue-2" java.security.AccessControlException: access violation
    and SHA-1

    My joking remark was unfounded. An area, which is rich in various gas/oil and ore deposits, including rare earth elements, and platinoids, has been the source of speculative remarks. My rebuttal belongs there, not here. Similarly, your work belongs in an arena not related to disentangling SHA-1 and code signing. Short of it is you are trying to do a file open from an applet, you have work to do before you attempt that.
    Introduction to Programming Using Java.
    Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default

    Did you look at my post on the other thread? In that test I wrote an applet to read a file from my PC. I created a jar and signed it using the statements that I posted. I uploaded the HTML and jar file and posted its URL.
    When I load the HTML/Applet, I get a prompt from the browser re security, I click OK and the applet reads the file.

    What are you doing differently from what I did? Mine works.

    The answer is not in your source, unless you want to change the design to do NOTHING that requires permission.
    Last edited by Norm; 10-05-2008 at 11:50 PM.

  9. #9
    serjant's Avatar
    serjant is offline Senior Member
    Join Date
    Jun 2008
    Location
    Ukraine,Zaporozhye
    Posts
    487
    Rep Power
    7

    Default

    Signing Java Applet

    Scroll down and watch also my explanation

  10. #10
    milkman128 is offline Member
    Join Date
    Oct 2008
    Posts
    6
    Rep Power
    0

    Default

    Quote Originally Posted by Norm View Post
    Did you look at my post on the other thread? In that test I wrote an applet to read a file from my PC. I created a jar and signed it using the statements that I posted. I uploaded the HTML and jar file and posted its URL.
    When I load the HTML/Applet, I get a prompt from the browser re security, I click OK and the applet reads the file.

    What are you doing differently from what I did? Mine works.

    The answer is not in your source, unless you want to change the design to do NOTHING that requires permission.


    yes i ran your applet and received a file IO error so maybe its a browser thing?
    I'll augment the source to negate file IO operations.
    I did not get the permission request to pop up in mine like it did for yours. I thought I did the jar signing exactly the same I'll look at it closer.

  11. #11
    milkman128 is offline Member
    Join Date
    Oct 2008
    Posts
    6
    Rep Power
    0

    Default

    Also thanks Jordan and serjant I appreciate your input.

  12. #12
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default

    My applet tries to read a file from your C: drive that you won't have. It's getting an I/O error instead of an access denied message would mean that it had permission.

Similar Threads

  1. Signing Java Applet
    By Agri in forum New To Java
    Replies: 8
    Last Post: 09-29-2008, 06:26 PM
  2. applet and signing
    By Preethi in forum New To Java
    Replies: 0
    Last Post: 06-05-2008, 03:17 PM
  3. signing applets for a period of time
    By sandeepk84@gmail.com in forum Java Applets
    Replies: 0
    Last Post: 12-04-2007, 01:34 PM
  4. Signing An Applet!!!!! Me Need Help!!!!! Plz!
    By marco in forum Java Applets
    Replies: 3
    Last Post: 07-29-2007, 05:45 PM
  5. Unknown publisher / Signing standalone tomcat.exe
    By millross in forum New To Java
    Replies: 1
    Last Post: 06-14-2007, 02:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •