net.i2p.i2ptunnel
Class I2PTunnelHTTPClientBase

java.lang.Object
  extended by net.i2p.util.EventDispatcherImpl
      extended by net.i2p.i2ptunnel.I2PTunnelTask
          extended by net.i2p.i2ptunnel.I2PTunnelClientBase
              extended by net.i2p.i2ptunnel.I2PTunnelHTTPClientBase
All Implemented Interfaces:
Runnable, EventDispatcher
Direct Known Subclasses:
I2PTunnelConnectClient, I2PTunnelHTTPClient

public abstract class I2PTunnelHTTPClientBase
extends I2PTunnelClientBase
implements Runnable

Common things for HTTPClient and ConnectClient Retrofit over them in 0.8.2

Since:
0.8.2

Nested Class Summary
protected static class I2PTunnelHTTPClientBase.AuthResult
           
 
Field Summary
protected static long __clientId
          used to assign unique IDs to the threads / clients.
protected static long __requestId
           
protected  List<String> _proxyList
           
static String BASIC_AUTH
           
protected static int DEFAULT_READ_TIMEOUT
           
static String DIGEST_AUTH
           
protected static byte[] ERR_NO_OUTPROXY
           
static String PROP_AUTH
          all auth @since 0.8.2
static String PROP_OUTPROXY_AUTH
           
static String PROP_OUTPROXY_PW
           
static String PROP_OUTPROXY_PW_PREFIX
           
static String PROP_OUTPROXY_USER
           
static String PROP_OUTPROXY_USER_PREFIX
          passwords for specific outproxies may be added with outproxyUsername.fooproxy.i2p=user and outproxyPassword.fooproxy.i2p=pw
static String PROP_PROXY_DIGEST_PREFIX
          new style MD5 auth
static String PROP_PROXY_DIGEST_SUFFIX
           
static String PROP_PW
           
static String PROP_PW_PREFIX
          additional users may be added with proxyPassword.user=pw
static String PROP_USER
           
 
Fields inherited from class net.i2p.i2ptunnel.I2PTunnelClientBase
_clientId, _context, _log, _ownDest, DEFAULT_CONNECT_TIMEOUT, dest, l, mySockets, sockLock, sockMgr, ss
 
Fields inherited from class net.i2p.i2ptunnel.I2PTunnelTask
open
 
Constructor Summary
I2PTunnelHTTPClientBase(int localPort, boolean ownDest, Logging l, EventDispatcher notifyThis, String handlerName, I2PTunnel tunnel)
           
I2PTunnelHTTPClientBase(int localPort, Logging l, I2PSocketManager sktMgr, I2PTunnel tunnel, EventDispatcher notifyThis, long clientId)
          This constructor always starts the tunnel (ignoring the i2cp.delayOpen option).
 
Method Summary
protected  I2PTunnelHTTPClientBase.AuthResult authorize(Socket s, long requestId, String method, String authorization)
          Authorization Ref: RFC 2617 If the socket is an InternalSocket, no auth required.
protected  String getAuthError(boolean isStale)
          What to send if digest auth fails
protected static byte[] getErrorPage(I2PAppContext ctx, String base, byte[] backup)
          foo => errordir/foo-header_xx.ht for lang xx, or errordir/foo-header.ht, or the backup byte array on fail.
protected  byte[] getErrorPage(String base, byte[] backup)
          foo => errordir/foo-header_xx.ht for lang xx, or errordir/foo-header.ht, or the backup byte array on fail.
protected  String getPrefix(long requestId)
           
protected abstract  String getRealm()
           
protected  boolean isDigestAuthRequired()
           
protected  String selectProxy()
           
 
Methods inherited from class net.i2p.i2ptunnel.I2PTunnelClientBase
buildSocketManager, buildSocketManager, buildSocketManager, buildSocketManager, clientConnectionRun, close, closeSocket, createI2PSocket, createI2PSocket, getClientExecutor, getDefaultOptions, getDefaultOptions, getListenHost, getLocalPort, getSocketManager, getSocketManager, getSocketManager, killClientExecutor, manageConnection, optionsUpdated, run, startRunning, verifySocketManager
 
Methods inherited from class net.i2p.i2ptunnel.I2PTunnelTask
connected, disconnected, errorOccurred, getId, getTunnel, isOpen, reportAbuse, routerDisconnected, setId, setName, setTunnel, toString
 
Methods inherited from class net.i2p.util.EventDispatcherImpl
attachEventDispatcher, detachEventDispatcher, getEventDispatcher, getEvents, getEventValue, ignoreEvents, notifyEvent, unIgnoreEvents, waitEventValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.lang.Runnable
run
 

Field Detail

_proxyList

protected final List<String> _proxyList

ERR_NO_OUTPROXY

protected static final byte[] ERR_NO_OUTPROXY

__clientId

protected static volatile long __clientId
used to assign unique IDs to the threads / clients. no logic or functionality


DEFAULT_READ_TIMEOUT

protected static final int DEFAULT_READ_TIMEOUT
See Also:
Constant Field Values

__requestId

protected static long __requestId

PROP_AUTH

public static final String PROP_AUTH
all auth @since 0.8.2

See Also:
Constant Field Values

PROP_USER

public static final String PROP_USER
See Also:
Constant Field Values

PROP_PW

public static final String PROP_PW
See Also:
Constant Field Values

PROP_PW_PREFIX

public static final String PROP_PW_PREFIX
additional users may be added with proxyPassword.user=pw

See Also:
Constant Field Values

PROP_OUTPROXY_AUTH

public static final String PROP_OUTPROXY_AUTH
See Also:
Constant Field Values

PROP_OUTPROXY_USER

public static final String PROP_OUTPROXY_USER
See Also:
Constant Field Values

PROP_OUTPROXY_PW

public static final String PROP_OUTPROXY_PW
See Also:
Constant Field Values

PROP_OUTPROXY_USER_PREFIX

public static final String PROP_OUTPROXY_USER_PREFIX
passwords for specific outproxies may be added with outproxyUsername.fooproxy.i2p=user and outproxyPassword.fooproxy.i2p=pw

See Also:
Constant Field Values

PROP_OUTPROXY_PW_PREFIX

public static final String PROP_OUTPROXY_PW_PREFIX
See Also:
Constant Field Values

PROP_PROXY_DIGEST_PREFIX

public static final String PROP_PROXY_DIGEST_PREFIX
new style MD5 auth

See Also:
Constant Field Values

PROP_PROXY_DIGEST_SUFFIX

public static final String PROP_PROXY_DIGEST_SUFFIX
See Also:
Constant Field Values

BASIC_AUTH

public static final String BASIC_AUTH
See Also:
Constant Field Values

DIGEST_AUTH

public static final String DIGEST_AUTH
See Also:
Constant Field Values
Constructor Detail

I2PTunnelHTTPClientBase

public I2PTunnelHTTPClientBase(int localPort,
                               boolean ownDest,
                               Logging l,
                               EventDispatcher notifyThis,
                               String handlerName,
                               I2PTunnel tunnel)
                        throws IllegalArgumentException
Throws:
IllegalArgumentException

I2PTunnelHTTPClientBase

public I2PTunnelHTTPClientBase(int localPort,
                               Logging l,
                               I2PSocketManager sktMgr,
                               I2PTunnel tunnel,
                               EventDispatcher notifyThis,
                               long clientId)
                        throws IllegalArgumentException
This constructor always starts the tunnel (ignoring the i2cp.delayOpen option). It is used to add a client to an existing socket manager.

Parameters:
sktMgr - the existing socket manager
Throws:
IllegalArgumentException
Method Detail

getPrefix

protected String getPrefix(long requestId)

selectProxy

protected String selectProxy()

getRealm

protected abstract String getRealm()

isDigestAuthRequired

protected boolean isDigestAuthRequired()
Since:
0.9.4

authorize

protected I2PTunnelHTTPClientBase.AuthResult authorize(Socket s,
                                                       long requestId,
                                                       String method,
                                                       String authorization)
Authorization Ref: RFC 2617 If the socket is an InternalSocket, no auth required.

Parameters:
method - GET, POST, etc.
authorization - may be null, the full auth line e.g. "Basic lskjlksjf"
Returns:
success

getAuthError

protected String getAuthError(boolean isStale)
What to send if digest auth fails

Since:
0.9.4

getErrorPage

protected byte[] getErrorPage(String base,
                              byte[] backup)
foo => errordir/foo-header_xx.ht for lang xx, or errordir/foo-header.ht, or the backup byte array on fail. .ht files must be UTF-8 encoded and use \r\n terminators so the HTTP headers are conformant. We can't use FileUtil.readFile() because it strips \r

Returns:
non-null
Since:
0.9.4 moved from I2PTunnelHTTPClient

getErrorPage

protected static byte[] getErrorPage(I2PAppContext ctx,
                                     String base,
                                     byte[] backup)
foo => errordir/foo-header_xx.ht for lang xx, or errordir/foo-header.ht, or the backup byte array on fail. .ht files must be UTF-8 encoded and use \r\n terminators so the HTTP headers are conformant. We can't use FileUtil.readFile() because it strips \r

Returns:
non-null
Since:
0.9.4 moved from I2PTunnelHTTPClient