java.net.sockets and MS Proxy

Discussion in 'Java' started by Jack Vamvas, Jul 13, 2003.

  1. Jack Vamvas

    Jack Vamvas Guest

    I am currently working on a whiteboard application , that uses
    java.net.socket as the connection method.
    If MS Proxy 2 is not involved between the 2 machines then the connection
    works fine.
    If, on the other hand, the requestor makes the request from behind MS Proxy
    2 then the connection fails.

    has anyone had a similar problem, if so, some tips on how I could get around
    this problem would be good.

    JV





    ___________________________________________________________________
    Remotely manage MS SQL db with SQLdirector -
    www.ciquery.com/tools/sqldirector/
     
    Jack Vamvas, Jul 13, 2003
    #1
    1. Advertising

  2. Jack Vamvas

    Tim Jowers Guest

    "Jack Vamvas" <> wrote in message news:<besb5e$i32$>...
    > I am currently working on a whiteboard application , that uses
    > java.net.socket as the connection method.
    > If MS Proxy 2 is not involved between the 2 machines then the connection
    > works fine.
    > If, on the other hand, the requestor makes the request from behind MS Proxy
    > 2 then the connection fails.
    >
    > has anyone had a similar problem, if so, some tips on how I could get around
    > this problem would be good.
    >
    > JV
    >

    You have to configure the proxy according to what type it is. Thank
    Michael Montuori for this code...mybe you want to contract him for
    some contract work :)


    System.out.println(" -t {1|2|3|4} = 1-Sun
    VM");
    System.out.println("
    2-Microsoft VM (Default)");
    System.out.println(" 3-Cisco
    PIX");
    System.out.println(" 4-Socks
    4 Proxy Servers");
    System.out.println(" 5-Web
    Ftp (default anonymous)");
    ....
    if (proxyHost != null) {
    if (proxyType.equals("1") || proxyType.equals("3")) {
    System.getProperties().put( "proxySet", "true" );
    System.getProperties().put( "proxyHost", proxyHost);
    System.getProperties().put( "proxyPort", proxyPort);
    } else {
    if (proxyType.equals("4")) {
    System.getProperties().put( "socksProxySet",
    "true");
    System.getProperties().put( "socksProxyHost",
    proxyHost);
    System.getProperties().put( "SocksProxyPort" ,
    proxyPort);
    } else {
    if (proxyType.equals("5")) {
    System.getProperties().put( "ftpProxySet",
    "true" );
    System.getProperties().put( "ftpProxyHost",
    proxyHost );
    System.getProperties().put( "ftpProxyPort",
    proxyPort );
    } else {
    System.getProperties().put("firewallSet",
    "true");
    System.getProperties().put("firewallHost",
    proxyHost);
    System.getProperties().put("firewallPort",
    proxyPort);
    System.getProperties().put("http.proxyHost",
    proxyHost);
    System.getProperties().put("http.proxyPort",
    proxyPort);
    }}}
    if (https && proxyHost != null) {
    System.getProperties().put("https.proxyHost",
    proxyHost);
    System.getProperties().put("https.proxyPort",
    proxyPort);
    }
    }
    ....
    if (proxyHost != null) {
    Base64 base64 = new Base64(username + ":" + password);
    base64.encode();
    base64Encoded = "Basic " + base64.getOutgoing();
    urlConnection.setRequestProperty("Proxy-Connection","Keep-Alive");
    if (proxyType.equals("3")) {
    urlConnection.setRequestProperty("Authorization",
    base64Encoded);
    } else {
    urlConnection.setRequestProperty("Proxy-Authorization",
    base64Encoded);
    }

    ....
     
    Tim Jowers, Jul 14, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Karsten Wutzke
    Replies:
    1
    Views:
    880
    Steven Simpson
    Aug 20, 2007
  2. Alejandro Molina

    Proxy and non Proxy configurations

    Alejandro Molina, Jul 15, 2004, in forum: ASP .Net Security
    Replies:
    0
    Views:
    148
    Alejandro Molina
    Jul 15, 2004
  3. Greg
    Replies:
    4
    Views:
    308
    Steven Simpson
    Aug 16, 2012
  4. Knute Johnson
    Replies:
    0
    Views:
    203
    Knute Johnson
    Jul 29, 2012
  5. Luca Bongiorni

    Transparent Proxy and Redirecting Sockets

    Luca Bongiorni, Feb 21, 2013, in forum: Python
    Replies:
    2
    Views:
    111
    Luca Bongiorni
    Feb 21, 2013
Loading...

Share This Page