Is there a right way to manipulate GoogleAppEngine

2019-04-08 03:18发布

问题:

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:

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?



回答2:

if you specifically need to use jabber (xmpp), you can use app engine's XMPP API.