BlackBerry Forums Support Community

BlackBerry Forums Support Community (
-   Linux Users Corner (
-   -   Handset application proxy handling (

skynetchris 07-15-2008 01:45 AM

Handset application proxy handling
Hi guys,

I have an application that makes a http connection to a server, this works fine. The connection now must be made to a server that is behind a proxy. I've read in java you can use the Authenticator class to handle this. There are a few examples here and here.

My Code:

ProxyAuthenticator() {
this.user = "user";
this.password = "test";

  public PasswordAuthentication
  onAuthenticationChallenge(String description, boolean isUserIdRequired, boolean isFullAccess) {
    return new PasswordAuthentication(user.getBytes(), password.getBytes());
  public byte[] onAuthenticationResponse(byte[] userName) {return null;}

The problem seems to be that in the Blackberry environment, you can't tell the sytem what to do when it is queried by a proxy:

and put these lines of code before your code opens an URLConnection-

Authenticator.setDefault(new ProxyAuthenticator("user", "password"));
System.setProperty("http.proxyHost", "proxy host");
System.setProperty("http.proxyPort", "port");

Now all calls will successfully pass through the proxy authentication.

Can anyone tell me what you have to do to 'register' your authenticator implementation with the system?

skynetchris 07-15-2008 01:50 AM

please delete, posted under developer corner.

All times are GMT -5. The time now is 11:36 AM.

Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.