Results 1 to 2 of 2
  1. #1
    PerryH is offline Member
    Join Date
    May 2011
    Location
    Minneapolis
    Posts
    1
    Rep Power
    0

    Default AWTPermission Denied Error on Signed/Trusted Java Applet

    I've been developing an applet which is used to grab image data from a user's clipboard and upload it to a server. This is for an in-house support ticketing system (currently, users can only upload pictures via a file upload page). The code itself seems pretty straight-forward (see below). Here is my development process from beginning to end:

    1. Develop the applet in Eclipse
    2. Compile it with javac v1.6.0_25: javac UploadClipboardImage.java
    3. Create a jar: jar cf UploadClipboardImage.jar UploadClipboardImage.class
    4. Sign the jar with a non-expired certificate from our company's CA: jarsigner -storetype pkcs12 -keystore CodeSigningCertificate.pfx -storepass xxxx UploadClipboardImage.jar SigningCertificate
    5. As a sanity check, verify the jar: jarsigner -verify -verbose -certs UploadClipboardImage.jar


    Finally, I upload the jar and class to the server and link it to the page with:

    XML Code:
    <APPLET
        ARCHIVE = "UploadClipboardImage.jar"
        CODEBASE = "https://(devsystem)/sandbox/java/"
        CODE = "UploadClipboardImage.class"
        NAME = "UploadClipboardImageApplet"
        WIDTH = 800
        HEIGHT = 500
        HSPACE = 0
        VSPACE = 0
        ALIGN = middle
        MAYSCRIPT>
    Your browser does not support Java...
    </APPLET>

    Now, when I load the page, I receive a prompt from Java asking me to provide my own digital certificate, which is signed by the same CA as the applet. I receive another prompt that asks if I want to run code that is both signed and unsigned which I allow. Finally, the applet loads, but returns an error message "errorjava.security.AccessControlException: access denied (java.awt.AWTPermission accessClipboard)"

    I read an article here regarding how to run the code in "privileged" mode, but that made no difference.

    Thinking this may be a bug in the most recent Java build, I downgraded to JRE/JDK v1.6.0_17, however it yielded the same results.

    I'm having trouble understanding two or three things:
    1. Why won't the applet run if it has been signed and trusted by the user?
    2. Why won't blocking the code as privileged work as a fail-safe?
    3. Is this functionality even possible with the added assurance of certificate signing? I've read a lot of contradictory articles, but haven't discovered a straight answer.


    Finally, here is the Java as it currently stands:

    Java Code:
    import java.awt.*;
    import java.awt.datatransfer.Clipboard; 
    import java.awt.datatransfer.ClipboardOwner; 
    import java.awt.datatransfer.DataFlavor; 
    import java.awt.datatransfer.Transferable; 
    import java.awt.datatransfer.UnsupportedFlavorException;
    import java.io.IOException; 
    import java.security.AccessController; 
    import java.security.PrivilegedAction;
    import javax.swing.Icon;
    import javax.swing.ImageIcon;
    import javax.swing.JButton;
    import javax.swing.JComponent;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.TransferHandler;
    
    import java.applet.*;
    
    public class UploadClipboardImage extends Applet{
    
        public String str;
        public void init(){
            try{
    	str="";
    	Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); 
    	Transferable clipData = clipboard.getContents(clipboard);
    			
                 if (clipData != null) {
    	   str=(String)clipData.getTransferData(DataFlavor.stringFlavor);
    	}
            }
            catch(Exception e){
    	str="error"+e;
            }
        }
    
        public void start(){}
        public void paint(Graphics g){g.drawString(str,50,50);}
    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,298
    Rep Power
    20

Similar Threads

  1. Replies: 0
    Last Post: 01-05-2011, 09:57 AM
  2. file acess denied error in java
    By yatin in forum Java Applets
    Replies: 2
    Last Post: 12-02-2010, 06:20 AM
  3. Signed Java Applet to read a file on hard drive?
    By ollyworks in forum Java Applets
    Replies: 2
    Last Post: 09-11-2009, 10:08 PM
  4. Signed Applet to write on LPT1 port - permission error
    By ConvoyTh in forum Java Applets
    Replies: 0
    Last Post: 07-02-2009, 10:56 AM
  5. run java signed applet in vista
    By nanaji in forum Java Applets
    Replies: 7
    Last Post: 05-14-2008, 11:59 AM

Tags for this Thread

Posting Permissions

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