How to avoid recursion in Java SecurityManager checkConnect?

Posted by Zilupe on Stack Overflow See other posts from Stack Overflow or by Zilupe
Published on 2010-04-12T06:50:56Z Indexed on 2010/04/12 6:53 UTC
Read the original article Hit count: 179

I'm trying to take control of a Java code base that does lots of un-documented things. I'm using a custom SecurityManager to check permission requests. Specifically, my code is checking SocketPermission checks -- checkConnect.

checkConnect is called when the application tries to resolve a host name to IP address and to connect to a specific IP address. The problem is that I don't know how to properly call host name resolution (InetAddress.getAddressByName) without falling into infinite recursion, because normally checkConnect is called even when I resolve the name from inside the SecurityManager.checkConnect. I have read on the web that I have to call the address resolution from a doPrivileged block, but no idea how.

P.S. Is this possible without writing any policy files?

© Stack Overflow or respective owner

Related posts about java

Related posts about securitymanager