code: public Object[] doSocksAuthentication(int methodId,
                                           java.net.Socket proxySocket)
                     throws java.io.IOException{
  
        if(methodId != METHOD_ID) return null;
  
        java.io.InputStream in = proxySocket.getInputStream();
        java.io.OutputStream out = proxySocket.getOutputStream();
  
        out.write(request);
        int version = in.read();
        if(version < 0) return null; //Server closed connection
        int status = in.read();
        if(status != 0) return null; //Server closed connection, or auth failed.
  
        return new Object[] {in,out};
     }
docs: Does User/Password authentication as defined in rfc1929.
  @return An array containnig in, out streams, or null if authentication
  fails.