| Author |
to copy a policy file from server machine to client machine in java
|
kiran manohar
Ranch Hand
Joined: Sep 28, 2003
Posts: 49
|
|
hi, i have created an applet program which needs a java.policy file to work. i want to run this applet from my webserver. so if my client runs the applet from his machine, he gives the url (http://192.144.1.45:8080/examples/applet/myapplet.html) the applet downloads well in the client machine, but bcoz i havent given the necessary permissions in his machine, he is not able to run my applet program.my applet program is using socketpermissions to connect,resolve and it access the server program in the webserver. i feel that the java.policy file does not have the necessary permissions. so i am looking for a code to copy the java.policy file to the client machine and overwrite the existing java.policy file in the client. is there any code for that? or is there any workaround for this problem regards Kiran
|
 |
Joe Ess
Bartender
Joined: Oct 29, 2001
Posts: 8264
|
|
|
If you digitally sign the applet, you can get whatever permissions you want. There's instructions in the Signed Applets chapter of Advanced Programming for the Java 2 Platform.
|
"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
|
 |
Bis Bang
Greenhorn
Joined: Jan 28, 2004
Posts: 15
|
|
Hi Joe, Its a nice Article.. But how to deploy the Applet in Tomcat container.. so that we can request the same through a browser or applet viewer.I am getting error..
|
The glory lies not in not falling, but it lies in rising everytime you fall
|
 |
Joe Ess
Bartender
Joined: Oct 29, 2001
Posts: 8264
|
|
Originally posted by Bis Bang: I am getting error..
Share the error with us. We can't read minds, or what's on your computer screen. It should be easy to deploy on tomcat, just put the signed JAR and the HTML that references it in the same directory under <tomcat_home>/webapps/<web_application_context>
|
 |
Bis Bang
Greenhorn
Joined: Jan 28, 2004
Posts: 15
|
|
Hi Joe I have the following files in a Folder called Signed_Applet.. CompanyCer,compstore, SignedApplet.html, SignedApplet.jar, Write.jp, SignedAppletDemo.class, SignedAppletDemo.java, SSignedApplet.jar same as in the Article.. Now I added the Signed_Applet Folder in the Context path of the server as below.. <Context path="/demo" docBase="D:\Signed_Applet"\> Now when I give the following command ... appletviewer -J-Djava.security.policy=Write.jp http://localhost:8080/demo/SignedApplet.html from my working directory say D:/bis.... 1)The Applet starts..2)its shows Signed Applet demo in the body 3)Does not show successfuly created file in the body and 4)gives the the folowing Errors in the command prompt ....from the request been made D:\bis>appletviewer -J-Djava.security.policy=Write.jp http://localhost:8080/demo /SignedApplet.html java.security.AccessControlException: access denied (java.util.PropertyPermissio n user.home read) at java.security.AccessControlContext.checkPermission(AccessControlConte xt.java:269) at java.security.AccessController.checkPermission(AccessController.java: 401) at java.lang.SecurityManager.checkPermission(SecurityManager.java:524) at java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:12 76) at java.lang.System.getProperty(System.java:573) at SignedAppletDemo.test(SignedAppletDemo.java:28) at SignedAppletDemo.paint(SignedAppletDemo.java:55) at sun.awt.RepaintArea.paint(RepaintArea.java:177) at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:260) at java.awt.Component.dispatchEventImpl(Component.java:3678) at java.awt.Container.dispatchEventImpl(Container.java:1627) at java.awt.Component.dispatchEvent(Component.java:3477) at java.awt.EventQueue.dispatchEvent(EventQueue.java:456) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh read.java:201) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre ad.java:151) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137) at java.awt.EventDispatchThread.run(EventDispatchThread.java:100) java.security.AccessControlException: access denied (java.util.PropertyPermissio n user.home read) at java.security.AccessControlContext.checkPermission(AccessControlConte xt.java:269) at java.security.AccessController.checkPermission(AccessController.java: 401) at java.lang.SecurityManager.checkPermission(SecurityManager.java:524) at java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:12 76) at java.lang.System.getProperty(System.java:573) at SignedAppletDemo.test(SignedAppletDemo.java:28) at SignedAppletDemo.paint(SignedAppletDemo.java:55) at sun.awt.RepaintArea.paint(RepaintArea.java:177) at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:260) at java.awt.Component.dispatchEventImpl(Component.java:3678) at java.awt.Container.dispatchEventImpl(Container.java:1627) at java.awt.Component.dispatchEvent(Component.java:3477) at java.awt.EventQueue.dispatchEvent(EventQueue.java:456) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh read.java:201) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre ad.java:151) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137) at java.awt.EventDispatchThread.run(EventDispatchThread.java:100) java.security.AccessControlException: access denied (java.util.PropertyPermissio n user.home read) at java.security.AccessControlContext.checkPermission(AccessControlConte xt.java:269) at java.security.AccessController.checkPermission(AccessController.java: 401) at java.lang.SecurityManager.checkPermission(SecurityManager.java:524) at java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:12 76) at java.lang.System.getProperty(System.java:573) at SignedAppletDemo.test(SignedAppletDemo.java:28) at SignedAppletDemo.paint(SignedAppletDemo.java:55) at sun.awt.RepaintArea.paint(RepaintArea.java:177) at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:260) at java.awt.Component.dispatchEventImpl(Component.java:3678) at java.awt.Container.dispatchEventImpl(Container.java:1627) at java.awt.Component.dispatchEvent(Component.java:3477) at java.awt.EventQueue.dispatchEvent(EventQueue.java:456) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh read.java:201) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre ad.java:151) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137) at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
|
 |
Bis Bang
Greenhorn
Joined: Jan 28, 2004
Posts: 15
|
|
|
Its works when i make the request from a browser(http://localhost:8080/demo/SignedApplet.html)..and create a file in my local disk
|
 |
Joe Ess
Bartender
Joined: Oct 29, 2001
Posts: 8264
|
|
I had that same problem. It worked in a browser, but not in appletviewer.
|
 |
Jasmine kaur
Ranch Hand
Joined: Nov 25, 2003
Posts: 157
|
|
Hello everybody, well I have also made an signed applet and its running in tomcat aswell as in appletviewer ,well in tomcat we have to use catalina policy file if we want to grants permission to a signed applet or applet. well see the browser settings and javaconsole in control panel. thanks
|
jasmine kaur
|
 |
 |
|
|
subject: to copy a policy file from server machine to client machine in java
|
|
|