How to avoid recursion in Java SecurityManager checkConnect?
- by Zilupe
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?