Appengine FetchURL: Using and authorizing a proxy (Java)

4 views
Skip to first unread message

Forepick via StackOverflow

unread,
Mar 16, 2016, 1:55:06 PM3/16/16
to google-appengin...@googlegroups.com

I'm trying to make a GET request in JAVA from an HttpServlet running on AppEngine. The request should be executed via a proxy server which has to be authorized (user and pass).

I tried using UrlFetch API, both high level (httpRequest) and low level (UrlConnection) but both didn't solve my problem.

When authorizing the proxy with

Authenticator authenticator = new Authenticator() {
    public PasswordAuthentication getPasswordAuthentication() {
        return (new PasswordAuthentication("User", "Pass".toCharArray()));
    }
};
Authenticator.setDefault(authenticator);

I'm getting this exception when running on AppEngine:

java.security.AccessControlException: access denied ("java.net.NetPermission" "setDefaultAuthenticator") at java.security.AccessControlContext.checkPermission(AccessControlContext.java:382) at java.security.AccessController.checkPermission(AccessController.java:572) at java.lang.SecurityManager.checkPermission(SecurityManager.java:549) at

com.google.apphosting.runtime.security.CustomSecurityManager.checkPermission(CustomSecurityManager.java:55) at java.net.Authenticator.setDefault(Authenticator.java:127) at com.bionic.ig_dump.FetchUrlServlet.testProxy(FetchUrlServlet.java:92) at com.bionic.ig_dump.FetchUrlServlet.doGet(FetchUrlServlet.java:47) at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)

What is the best way to implement it correctly?

Thanks!



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/36043282/appengine-fetchurl-using-and-authorizing-a-proxy-java
Reply all
Reply to author
Forward
0 new messages