From: rishi p. <mai...@gm...> - 2006-06-28 14:19:34
|
Hi all I built a simple applet in jython which on keyTyped event sends the typed character to the server(written in python listining on 80 port). The archive for the applet is a jar file But when I try to view it on a browser , it gives me the following error's java.security.AccessControlExce ption: access denied ( java.net.SocketPermission 192.168.2.40:80 <http://192.168.2.40/>connect,resolve) at java.security.AccessControlContext.checkPermission( AccessControlContext.java:264) at java.security.AccessController.checkPermission( AccessController.java:427) at java.lang.SecurityManager.checkPermission(SecurityManager.java :532) at java.lang.SecurityManager.checkConnect(SecurityManager.java:1034) at java.net.Socket.connect(Socket.java:501) at java.net.Socket.connect(Socket.java:457) at java.net.Socket.<init>(Socket.java:365) at java.net.Socket.<init>(Socket.java:178) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance( NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance( DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:494) at org.python.core.PyReflectedConstructor.__call__( PyReflectedConstructor.java) The code for the applet is: from java.applet import Applet from java.awt.event import KeyListener from java.awt import * from java.net import Socket from java.io import * class shell1(Applet,KeyListener): key='' def init(self): self.addKeyListener(self) self.socket=csSocket() def keyTyped(self,keyEvent): self.key=keyEvent.getKeyChar() print self.key self.socket.csWrite(self.key) self.repaint() def paint(self,g): g.setColor(Color.black) g.setColor(Color.white) g.drawString(str(self.key),50,50) def keyReleased(self,keyEvent): pass def keyPressed(self,keyEvent): pass def stop(self): self.cs.close() class csSocket(Socket): HOST='192.168.2.40' PORT=80 def __init__(self): self.cs=Socket(self.HOST,self.PORT) self.outputStream=cs.getOutputStream() self.inputStream=cs.getInputStream() def csRead(self): self.inputStream.read() def csWrite(self,data): self.outputStream.write(data) def csClose(self): self.cs.close() The server is running on 192.168.2.40:80 <http://192.168.2.40/> and the applet on 192.168.2.31 I compiled the .py file with following syntax jythonc --jar shell1.jar -a -d -J "-source 1.2" shell1.py Then on the local machine where the applet resides I generated a key with: keytool -genkey //I did'nt gave the key name and so it created key with keyname as 'mykey' Then I fired the following commands: keytool -selfcert jarsigner shell1.jar mykey It exited successfully // That means shell1.jar got signed(am I right or wrong) But still when I view the applet it repeats the above mentioned error's Do some one have the solution for this Would be grateful if I get some - Regards |