Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

HTTPClient
Class SocksClient  view SocksClient download SocksClient.java

java.lang.Object
  extended byHTTPClient.SocksClient
All Implemented Interfaces:
GlobalConstants

class SocksClient
extends java.lang.Object
implements GlobalConstants

This class implements a SOCKS Client. Supports both versions 4 and 5. GSSAPI however is not yet implemented.

Usage is as follows: somewhere in the initialization code (and before the first socket creation call) create a SocksClient instance. Then replace each socket creation call sock = new Socket(host, port); with sock = socks_client.getSocket(host, port); (where socks_client is the above created SocksClient instance). That's all.

Version:
0.3-2 18/06/1999

Field Summary
private static byte BIND
          socks commands
static int CD_0
           
static int CD_CHUNKED
           
static int CD_CLOSE
           
static int CD_CONTLEN
           
static int CD_HDRS
           
static int CD_MP_BR
           
static int CD_NONE
          Content delimiters
private static byte CONNECT
          socks commands
static boolean DebugAll
          Debug variables
static boolean DebugAuth
           
static boolean DebugConn
           
static boolean DebugDemux
           
static boolean DebugMods
           
static boolean DebugResp
           
static boolean DebugSocks
           
static boolean DebugURLC
           
private static byte DMNAME
          socks version 5 address types
private static byte GSSAPI
          socks version 5 authentication methods
static int HTTP
          possible http protocols we (might) handle
static int HTTP_1_0
          some known http versions
static int HTTP_1_1
           
static int HTTP_NG
           
static int HTTPS
           
private static byte IP_V4
          socks version 5 address types
private static byte IP_V6
          socks version 5 address types
private static byte NO_ACC
          socks version 5 authentication methods
private static byte NO_AUTH
          socks version 5 authentication methods
static int SHTTP
           
private  java.lang.String socks_host
          the host the socks server sits on
private  int socks_port
          the port the socks server listens on
private  int socks_version
          the version of socks that the server handles
private static byte UDP_ASS
          socks commands
private  byte[] user
           
private static byte USERPWD
          socks version 5 authentication methods
private  boolean v4A
           
 
Constructor Summary
(package private) SocksClient(java.lang.String host, int port)
          Creates a new SOCKS Client using the specified host and port for the server.
(package private) SocksClient(java.lang.String host, int port, int version)
          Creates a new SOCKS Client using the specified host and port for the server.
 
Method Summary
private static java.net.Socket connect(java.lang.String host, int port)
          Connect to the host/port, trying all addresses assciated with that host.
(package private)  java.net.Socket getSocket(java.lang.String host, int port)
          Initiates a connection to the socks server, does the startup protocol and returns a socket ready for talking.
private  void negotiate_gssapi(java.io.InputStream inp, java.io.OutputStream out)
          Negotiates authentication using the gssapi protocol (draft-ietf-aft-gssapi-02).
private  void negotiate_userpwd(java.io.InputStream inp, java.io.OutputStream out)
          Negotiates authentication using the username/password protocol (rfc-1929).
 java.lang.String toString()
          produces a string.
private  void v4ProtExchg(java.io.InputStream inp, java.io.OutputStream out, java.lang.String host, int port)
          Does the protocol exchange for a version 4 SOCKS connection.
private  void v5ProtExchg(java.io.InputStream inp, java.io.OutputStream out, java.lang.String host, int port)
          Does the protocol exchange for a version 5 SOCKS connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

socks_host

private java.lang.String socks_host
the host the socks server sits on


socks_port

private int socks_port
the port the socks server listens on


socks_version

private int socks_version
the version of socks that the server handles


CONNECT

private static final byte CONNECT
socks commands

See Also:
Constant Field Values

BIND

private static final byte BIND
socks commands

See Also:
Constant Field Values

UDP_ASS

private static final byte UDP_ASS
socks commands

See Also:
Constant Field Values

NO_AUTH

private static final byte NO_AUTH
socks version 5 authentication methods

See Also:
Constant Field Values

GSSAPI

private static final byte GSSAPI
socks version 5 authentication methods

See Also:
Constant Field Values

USERPWD

private static final byte USERPWD
socks version 5 authentication methods

See Also:
Constant Field Values

NO_ACC

private static final byte NO_ACC
socks version 5 authentication methods

See Also:
Constant Field Values

IP_V4

private static final byte IP_V4
socks version 5 address types

See Also:
Constant Field Values

DMNAME

private static final byte DMNAME
socks version 5 address types

See Also:
Constant Field Values

IP_V6

private static final byte IP_V6
socks version 5 address types

See Also:
Constant Field Values

v4A

private boolean v4A

user

private byte[] user

DebugAll

public static final boolean DebugAll
Debug variables

See Also:
Constant Field Values

DebugConn

public static final boolean DebugConn
See Also:
Constant Field Values

DebugResp

public static final boolean DebugResp
See Also:
Constant Field Values

DebugDemux

public static final boolean DebugDemux
See Also:
Constant Field Values

DebugAuth

public static final boolean DebugAuth
See Also:
Constant Field Values

DebugSocks

public static final boolean DebugSocks
See Also:
Constant Field Values

DebugMods

public static final boolean DebugMods
See Also:
Constant Field Values

DebugURLC

public static final boolean DebugURLC
See Also:
Constant Field Values

HTTP

public static final int HTTP
possible http protocols we (might) handle

See Also:
Constant Field Values

HTTPS

public static final int HTTPS
See Also:
Constant Field Values

SHTTP

public static final int SHTTP
See Also:
Constant Field Values

HTTP_NG

public static final int HTTP_NG
See Also:
Constant Field Values

HTTP_1_0

public static final int HTTP_1_0
some known http versions

See Also:
Constant Field Values

HTTP_1_1

public static final int HTTP_1_1
See Also:
Constant Field Values

CD_NONE

public static final int CD_NONE
Content delimiters

See Also:
Constant Field Values

CD_HDRS

public static final int CD_HDRS
See Also:
Constant Field Values

CD_0

public static final int CD_0
See Also:
Constant Field Values

CD_CLOSE

public static final int CD_CLOSE
See Also:
Constant Field Values

CD_CONTLEN

public static final int CD_CONTLEN
See Also:
Constant Field Values

CD_CHUNKED

public static final int CD_CHUNKED
See Also:
Constant Field Values

CD_MP_BR

public static final int CD_MP_BR
See Also:
Constant Field Values
Constructor Detail

SocksClient

SocksClient(java.lang.String host,
            int port)
Creates a new SOCKS Client using the specified host and port for the server. Will try to establish the SOCKS version used when establishing the first connection.


SocksClient

SocksClient(java.lang.String host,
            int port,
            int version)
      throws SocksException
Creates a new SOCKS Client using the specified host and port for the server.

Method Detail

getSocket

java.net.Socket getSocket(java.lang.String host,
                          int port)
                    throws java.io.IOException
Initiates a connection to the socks server, does the startup protocol and returns a socket ready for talking.


connect

private static final java.net.Socket connect(java.lang.String host,
                                             int port)
                                      throws java.io.IOException
Connect to the host/port, trying all addresses assciated with that host.


v4ProtExchg

private void v4ProtExchg(java.io.InputStream inp,
                         java.io.OutputStream out,
                         java.lang.String host,
                         int port)
                  throws SocksException,
                         java.io.IOException
Does the protocol exchange for a version 4 SOCKS connection.


v5ProtExchg

private void v5ProtExchg(java.io.InputStream inp,
                         java.io.OutputStream out,
                         java.lang.String host,
                         int port)
                  throws SocksException,
                         java.io.IOException
Does the protocol exchange for a version 5 SOCKS connection. (rfc-1928)


negotiate_gssapi

private void negotiate_gssapi(java.io.InputStream inp,
                              java.io.OutputStream out)
                       throws SocksException,
                              java.io.IOException
Negotiates authentication using the gssapi protocol (draft-ietf-aft-gssapi-02). NOTE: this is not implemented currently. Will have to wait till Java provides the necessary access to the system routines.


negotiate_userpwd

private void negotiate_userpwd(java.io.InputStream inp,
                               java.io.OutputStream out)
                        throws SocksException,
                               java.io.IOException
Negotiates authentication using the username/password protocol (rfc-1929). The username and password should previously have been stored using the scheme "SOCKS5" and realm "USER/PASS"; e.g. AuthorizationInfo.addAuthorization(socks_host, socks_port, "SOCKS5", "USER/PASS", null, { new NVPair(username, password) });


toString

public java.lang.String toString()
produces a string.