socks.server
Class ServerAuthenticatorNone

java.lang.Object
  |
  +--socks.server.ServerAuthenticatorNone
Direct Known Subclasses:
IdentAuthenticator, UserPasswordAuthenticator

public class ServerAuthenticatorNone
extends java.lang.Object
implements ServerAuthenticator

An implementation of ServerAuthenticator, which does not do any authentication.

Warning!!
Should not be used on machines which are not behind the firewall.

It is only provided to make implementing other authentication schemes easier.
For Example:

class MyAuth extends socks.server.ServerAuthenticator{
...
public ServerAuthenticator startSession(java.net.Socket s){
if(!checkHost(s.getInetAddress()) return null;
return super.startSession(s);
}

boolean checkHost(java.net.Inetaddress addr){
boolean allow;
//Do it somehow
return allow;
}
}


Constructor Summary
ServerAuthenticatorNone()
          Creates new instance of the ServerAuthenticatorNone.
ServerAuthenticatorNone(java.io.InputStream in, java.io.OutputStream out)
          Constructs new ServerAuthenticatorNone object suitable for returning from the startSession function.
 
Method Summary
 boolean checkRequest(java.net.DatagramPacket dp, boolean out)
          Allways returns true.
 boolean checkRequest(ProxyMessage msg)
          Allways returns true.
 void endSession()
          Does nothing.
 java.io.InputStream getInputStream()
          Get input stream.
 java.io.OutputStream getOutputStream()
          Get output stream.
 UDPEncapsulation getUdpEncapsulation()
          Allways returns null.
static boolean selectSocks5Authentication(java.io.InputStream in, java.io.OutputStream out, int methodId)
          Convinience routine for selecting SOCKSv5 authentication.
 ServerAuthenticator startSession(java.net.Socket s)
          Grants access to everyone.Removes authentication related bytes from the stream, when a SOCKS5 connection is being made, selects an authentication NONE.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServerAuthenticatorNone

public ServerAuthenticatorNone()
Creates new instance of the ServerAuthenticatorNone.

ServerAuthenticatorNone

public ServerAuthenticatorNone(java.io.InputStream in,
                               java.io.OutputStream out)
Constructs new ServerAuthenticatorNone object suitable for returning from the startSession function.
Parameters:
in - Input stream to return from getInputStream method.
out - Output stream to return from getOutputStream method.
Method Detail

startSession

public ServerAuthenticator startSession(java.net.Socket s)
                                 throws java.io.IOException
Grants access to everyone.Removes authentication related bytes from the stream, when a SOCKS5 connection is being made, selects an authentication NONE.
Specified by:
startSession in interface ServerAuthenticator
Tags copied from interface: ServerAuthenticator
Parameters:
s - Accepted Socket.
Returns:
An instance of ServerAuthenticator to be used for this connection or null

getInputStream

public java.io.InputStream getInputStream()
Get input stream.
Specified by:
getInputStream in interface ServerAuthenticator
Returns:
Input stream speciefied in the constructor.

getOutputStream

public java.io.OutputStream getOutputStream()
Get output stream.
Specified by:
getOutputStream in interface ServerAuthenticator
Returns:
Output stream speciefied in the constructor.

getUdpEncapsulation

public UDPEncapsulation getUdpEncapsulation()
Allways returns null.
Specified by:
getUdpEncapsulation in interface ServerAuthenticator
Returns:
null

checkRequest

public boolean checkRequest(ProxyMessage msg)
Allways returns true.
Specified by:
checkRequest in interface ServerAuthenticator
Tags copied from interface: ServerAuthenticator
Parameters:
msg - Request message.
Returns:
true to grant request, false to reject it.

checkRequest

public boolean checkRequest(java.net.DatagramPacket dp,
                            boolean out)
Allways returns true.
Specified by:
checkRequest in interface ServerAuthenticator
Tags copied from interface: ServerAuthenticator
Parameters:
out - If true the datagram is being send out(from the client), otherwise it is an incoming datagram.
Returns:
True to forward datagram false drop it silently.

endSession

public void endSession()
Does nothing.
Specified by:
endSession in interface ServerAuthenticator

selectSocks5Authentication

public static boolean selectSocks5Authentication(java.io.InputStream in,
                                                 java.io.OutputStream out,
                                                 int methodId)
                                          throws java.io.IOException
Convinience routine for selecting SOCKSv5 authentication.

This method reads in authentication methods that client supports, checks wether it supports given method. If it does, the notification method is written back to client, that this method have been chosen for authentication. If given method was not found, authentication failure message is send to client ([5,FF]).

Parameters:
in - Input stream, version byte should be removed from the stream before calling this method.
out - Output stream.
methodId - Method which should be selected.
Returns:
true if methodId was found, false otherwise.