views:

110

answers:

1

I have a GoogleAppEngine application that is required to connect to another localhost server, but when I'm trying to do this from the server code, I get:

java.security.AccessControlException: access denied (java.net.SocketPermission localhost resolve)

I know that I can specify my additional security grant by using java virtual machine arguments (I specify them in Web Application run configuration):

java -Djava.security.manager -Djava.security.policy=WEB-INF/java.policy

with java.policy contents:

grant {
       permission java.net.SocketPermission "localhost:8081", "connect, resolve";
};

but it overrides the GoogleAppEngine internal security manager which is located in private class at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager, so the properties, required for AppEngine itself are disabled in that way.

Is there any way to make GoogleAppEngine internal security manager class use my policy file instead of replacing it manually with a stub (allowing anything) file in a jar?

+1  A: 

You can't open sockets on App Engine. You need to use the URLFetch API, either via java.net or directly. How do you expect to access 'localhost' when your app has been uploaded to App Engine, though?

Nick Johnson
URLFetch will really fit my needs, I think, thank you.
shaman.sir
...no, sorry, my server's port is not 80/443, it's an openfire server and I use specific java library to use an application on it, and this library, in its way, uses `SocketAddress` to connect to. I will just use no GAE. Question is have no answer, seems, just 'No connections to non-80/443 allowed'.
shaman.sir