socks.server
Class Ident

java.lang.Object
  |
  +--socks.server.Ident

public class Ident
extends java.lang.Object

Class Ident provides means to obtain user name of the owner of the socket on remote machine, providing remote machine runs identd daemon.

To use it:

Socket s = ss.accept();
Ident id = new Ident(s);
if(id.successful) goUseUser(id.userName);
else handleIdentError(id.errorCode,id.errorMessage)


Field Summary
static int connectionTimeout
          Maximum amount of time we should wait before dropping the connection to identd server.Setting it to 0 implies infinit timeout.
static int ERR_NO_CONNECT
          Identd on port 113 can't be contacted
static int ERR_PROTOCOL
          Identd daemon responded with ERROR, in this case errorMessage contains the string explanation, as send by the daemon.
static int ERR_PROTOCOL_INCORRECT
          When parsing server response protocol error happened.
static int ERR_TIMEOUT
          Connection timed out
 int errorCode
          Error code
 java.lang.String errorMessage
          Error Message can be null.
 java.lang.String hostType
          Host type as returned by daemon, can be null, if error happened
 boolean successful
          If this is true then userName and hostType contain valid values.
 java.lang.String userName
          User name as returned by the identd daemon, or null, if it failed
 
Constructor Summary
Ident(java.net.Socket s)
          Constructor tries to connect to Identd daemon on the host of the given socket, and retrieve user name of the owner of given socket connection on remote machine.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

errorMessage

public java.lang.String errorMessage
Error Message can be null.

hostType

public java.lang.String hostType
Host type as returned by daemon, can be null, if error happened

userName

public java.lang.String userName
User name as returned by the identd daemon, or null, if it failed

successful

public boolean successful
If this is true then userName and hostType contain valid values. Else errorCode contain the error code, and errorMessage contains the corresponding message.

errorCode

public int errorCode
Error code

ERR_NO_CONNECT

public static final int ERR_NO_CONNECT
Identd on port 113 can't be contacted

ERR_TIMEOUT

public static final int ERR_TIMEOUT
Connection timed out

ERR_PROTOCOL

public static final int ERR_PROTOCOL
Identd daemon responded with ERROR, in this case errorMessage contains the string explanation, as send by the daemon.

ERR_PROTOCOL_INCORRECT

public static final int ERR_PROTOCOL_INCORRECT
When parsing server response protocol error happened.

connectionTimeout

public static final int connectionTimeout
Maximum amount of time we should wait before dropping the connection to identd server.Setting it to 0 implies infinit timeout.
Constructor Detail

Ident

public Ident(java.net.Socket s)
Constructor tries to connect to Identd daemon on the host of the given socket, and retrieve user name of the owner of given socket connection on remote machine. After constructor returns public fields are initialised to whatever the server returned.

If user name was successfully retrieved successful is set to true, and userName and hostType are set to whatever server returned. If however for some reason user name was not obtained, successful is set to false and errorCode contains the code explaining the reason of failure, and errorMessage contains human readable explanation.

Constructor may block, for a while.

Parameters:
s - Socket whose ownership on remote end should be obtained.