fredag jan 25, 2008

Escape

Using SecurityManager with Java and Socket's is not always as easy as it first seems. You would think that when creating a DatagramChannel and operating on that (ie send and receive), you will get the SecurityException if you don't have the right permissions. But no, you have in fact to an explicit check for the permissions you need like this:

     SecurityManager security = System.getSecurityManager();
     if (security != null) {
         security.checkXXX(argument,  . . . );
     }
 

And it is the calling Thread that should be checked before doing a DatagramChannel.receive call as this call will hang forever if it doesn't have the right permissions.

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed