Signing Applets

Hi

For the past week i have been trying to sign an applet.

The reason for having my applet signed, is because i need to access a serial port. So the best solution i could come up with is signed applets.

I have been working off this site for the last week. I have managed to understand/and get to step 5 and then they sort of lose me, sigh

http://java.sun.com/developer/onlineTraining/Programming/JDCBook/signed.html#example

I have also visited

http://mindprod.com/jgloss/signedapplets.html

My applet also uses other JAR files because i need access to the protocols that my company uses in order to talk to the device on the serial port

So my questions are

1)How exactly does can my applet have permissions in order to access the serial port?In the example above they talk about the Write.jp file. I understand what is in the file, but how do i link it to my applet?

2)Are there other sites that i can go read that will explain things to me like a 5 year old? And yes i have googled "Signed applets" and i have read up on signed applets

MY APPLET CODE:

<HTML>

<Head>

<Title>ASimpleProgram</Title>

<Body>

<Applet archive="ajaxreports.jar,comm.jar,rtlib.jar" Code="ReadTagApplet.class" width="500" height="50" name="RA">

</Applet>

</Body>

</HTML>

And my Java Applet Code

import java.applet.Applet;

import java.awt.FlowLayout;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.util.Date;

import java.awt.Dimension;

import java.net.InetAddress;

import java.net.UnknownHostException;

import javax.swing.JButton;

import javax.swing.JTextField;

import net.impro.ajax.reports.admin.server.utils.comms.PROXCommand;

import net.impro.ajax.reports.admin.server.utils.hex.HexString;

import net.impro.ajax.reports.admin.server.utils.iprxprotocolframe.IPRXProtocolFrame;

import net.impro.ajax.reports.admin.server.utils.iprxprotocolframe.IPRXStatus;

import net.impro.ajax.reports.admin.server.utils.pxcontroller.PXController;

import net.impro.ajax.reports.admin.server.utils.serialcomm.DataDefinition;

import net.impro.ajax.reports.admin.server.utils.serialcomm.DeviceRS232;

import net.impro.ajax.reports.admin.server.utils.serialcomm.SerialCommImprox;

import net.impro.ajax.reports.admin.server.utils.configurationmanager.ConfigurationManager;

publicclass ReadTagAppletextends Applet{

SerialCommImprox newImprox =null;

//private final static Locale LOC = LocaleChangeManager.getLocale();

privatefinalboolean debug=false;

privateint baudRate = 38400;

privatelong tagNum;

public JButton mybutton =new JButton("READ TAG");

publicfinal JTextField myText =new JTextField();

publicvoid init(){

setLayout(new FlowLayout());

mybutton.addActionListener(new ActionListener(){

publicvoid actionPerformed(ActionEvent e){

//readTag();

System.err.println("PORT GO GO OPEN: "+getPort());

//myText.setText(""+);

}});

myText.setPreferredSize(new Dimension(200,20));

add(mybutton);

add(myText);

}

publicboolean getPort()

{

try{

newImprox.close();

}catch (RuntimeException e){

System.err.println("Noppers");

}

newImprox =new SerialCommImprox("net.impro.ajax.reports.admin.server.utils.serialcomm.DeviceRS232");

try{

//newImprox.openPort();

System.err.println("DEVICERS232 BR: "+DeviceRS232.BAUDRATE);

//ConfigurationManager cfgmgr = ConfigurationManager.getConfigurationManager();

String sPortName ="COM4";

// System.out.println("Port "+sPortName); //DBG

String sWork ="38400";

if (sWork !=null) baudRate = Integer.parseInt(sWork);

if (sPortName !=null && baudRate != 0){

if (newImprox.openPort("RA", sPortName,new String[]{DeviceRS232.BAUDRATE +"="+baudRate}) ==false){

System.err.println(new Date()+" "+Thread.currentThread().getName()+

"Failed to open Serial Port "+sPortName);

System.err.println("NO OPEN PORT FOR JOO!!!");

}else{

System.err.println("WOOTS!!!");

// Set the comms logging mode

int lm = 0;// default is no logging

int thrb = 0;// default is 27 bytes

String thresholdBytes ="27";

if (thresholdBytes !=null) thrb = Integer.parseInt(thresholdBytes);

newImprox.setLoggingThresholdBytes(thrb);

String loggingMode ="0";

if (loggingMode !=null) lm = Integer.parseInt(loggingMode);

newImprox.setLoggingMode(lm);

//MOD to support auto-reconnection

//String sReconnect = cfgmgr.getProperty("proxette.comms.autoreconnect");

//boolean blReconnect = true;

//if (sReconnect != null) blReconnect = (sReconnect.equalsIgnoreCase("TRUE"))?true:false;

//newImprox.setAutoReconnectOnErrors(blReconnect);//end MOD

if (debug){

System.err.println("******newImprox VARIABLE********");

System.err.println("newImprox app name: "+newImprox.getAppName());

System.err.println("Comm Device :"+newImprox.getCommDevice());

System.err.println("********************************");

}

returntrue;

}

}

}

catch (Exception cme){

System.err.println((new Date()).toString()+" "+Thread.currentThread().getName()+

": Unable to read from ixp1.properties File");

}

returnfalse;

}

}

Do i have to sign the JAR files that have my other classes too?

Any and all suggestions would be great.

:)

[9969 byte] By [monk3ya] at [2007-11-27 7:34:13]
# 1
I think you'll have to sign all jar files you specify in the HTML page if they need the access too.
marco@dea at 2007-7-12 19:14:41 > top of Java-index,Desktop,Core GUI APIs...
# 2

hi

thnx for the reply

I have managed to sign my applet. But now i have a bunch of security exceptions. I have been able to take care of one of those exceptions by adding

permission java.awt.AWTPermission "accessEventQueue";

to the java.policy file

But now i get this exception thrown

and i have even tried adding the

permission java.security.AllPermission;

to the same policy file but, no luck. Any suggestions?

Caused by: java.security.AccessControlException: access denied (java.util.PropertyPermission javax.comm.properties read)

at java.security.AccessControlContext.checkPermission(Unknown Source)

at java.security.AccessController.checkPermission(Unknown Source)

at java.lang.SecurityManager.checkPermission(Unknown Source)

at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)

at java.lang.System.getProperty(Unknown Source)

at javax.comm.CommPortIdentifier.<clinit>(CommPortIdentifier.java:678)

... 28 more

My applet is trying to open a Serial port, if that helps.

Any advice would be appreciated

:)

monk3ya at 2007-7-12 19:14:41 > top of Java-index,Desktop,Core GUI APIs...