dcsimg
How to tell the browser to give permission to create sockets from applets ?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Sakibul_Khan
Posted On:   Saturday, April 13, 2002 07:53 PM

Hi, I have made a Messenger type of thing & it works perfectly when I use it from appletviewer, & specify the proper security permission. To RUN:- appletviewer -J-Djava.security.policy=Messenger.policy Messenger.html My "Messenger.policy" file:- grant { permission java.net.SocketPermission "*:1024-65535", "connect,accept,resolve"; permission java.net.SocketPermission "*:80", "connect"; }; When I try to RUN it with appletviewer, without the policy file, using:- appletviewer Messenger.html It gives me:- java.security.Ac   More>>

Hi,

I have made a Messenger type of thing & it works perfectly when I use it
from appletviewer, & specify the proper security permission.



To RUN:-

appletviewer -J-Djava.security.policy=Messenger.policy Messenger.html



My "Messenger.policy" file:-

grant {

permission java.net.SocketPermission "*:1024-65535", "connect,accept,resolve";

permission java.net.SocketPermission "*:80", "connect";

};



When I try to RUN it with appletviewer, without the policy file, using:-

appletviewer Messenger.html



It gives me:- java.security.AccessControlException



Thus I am using a policy file. But my question is how do I tell the browser
to look into the policy file & then create the sockets.



I know that JRE of the browser doesn't allow access to local workstation, but
Yahoo does it in some way, in their java Yahoo Messenger, & I just want to
know how to allow to create SOCKETS, from the browser.



Sakibul Khan

skhan20@cs.mcgill.ca

   <<Less

Re: How to tell the browser to give permission to create sockets from applets ?

Posted By:   Laxman_Subramanian  
Posted On:   Wednesday, April 24, 2002 12:07 PM

Yahoo's Messenger Applet opens socket to connect to the same server where from it orginated so no issues . IF you to would like to have the same with, The applet making connections to the same server at any port then no issues it would surely work . Only if you need to make socket connections to different machine you need to sign the applet and have it ask for permissions first .

in the init add this code

try {
if (Class.forName("com.ms.security.PolicyEngine") != null) {
com.ms.security.PolicyEngine.assertPermission(com.ms.security.PermissionID.NETIO);
com.ms.security.PolicyEngine.assertPermission(com.ms.security.PermissionID.FILEIO);
}
} catch (Throwable e) {}

the above one is for IE for netscape you need to ask for netscape privalage manager .

hope this helps if you need help just give me a buzz here .I am working on the same kind of stuff so can help you . remember for copiling the applet class you will be needing the com package from microsoft which you can download from www.microsoft.com/java .Download heir kit and use it ..
About | Sitemap | Contact