com.wjholden.nmap
Class NmapInstall

java.lang.Object
  extended by 
      extended by com.wjholden.nmap.NmapInstall
All Implemented Interfaces:
NmapConstants

public class NmapInstall
extends
implements NmapConstants

Verifies the installation of Nmap binaries asynchronously. Checks whether root permissions are available or not (Nmap.canGetRoot). Creates the binary directory (Nmap.bindir).
TODO: Use md5 sums of files to ensure integrity.

Author:
William John Holden (wjholden@gmail.com)

Field Summary
private  java.lang.String bindir
           
private  Context context
           
private  boolean forceRestart
          If the second parameter sent to new NmapInstall(Context, String) is "restart" then NmapInstall will send a message to NmapMain.handler telling it to restart the app after install completes.
private  Resources resources
          Once you have the application Context, use that to establish a Resources object that can be used to open the R.raw.* files.
 
Fields inherited from interface com.wjholden.nmap.NmapConstants
BUFFER_SIZE, FORCE_RESTART, INSTALL_ERROR, INSTALL_FILENAMES, INSTALL_GOOD, INSTALL_NO_ROOT, INSTALL_RESOURCES, MG_DEBUG, MG_DEFAULT, MG_SUBNET, MI_BIN, MI_DEBUG_EMAIL, MI_DEBUG_ENABLE, MI_DEC, MI_EMAIL_SUBNET, MI_EXIT, MI_HEX, MI_MORE_HELP, MI_REINSTALL, MI_SUBNET, MI_SURVEY, RUN_COMPLETE, RUN_ERROR, RUN_SUCCESS_NO_FILE, SCANTYPE_NCAT, SCANTYPE_NDIFF, SCANTYPE_NMAP_5_30, SCANTYPE_NMAP_5_50, SCANTYPE_NPING, SET_TITLE, SUBNET_CONNECTED, SUBNET_DISCONNECTED, SUBNET_POLL_INTERVAL, TAG, THREAD_ERROR
 
Constructor Summary
NmapInstall()
           
 
Method Summary
private  void createNewFileAndDeleteExisting(java.lang.String path)
          Simple method for deleting a file if it does not exist.
protected  java.lang.Void doInBackground(java.lang.Object... params)
           
protected  void onPostExecute(java.lang.Void myVoid)
           
private  void setPermissions()
          Uses CHMOD and CHOWN to set permissions based on NmapMain.canGetRoot.
private  void writeNcat()
          Write the Ncat file to disk.
private  void writeNmap_5_30BETA1()
          Writes the Nmap binary to filesystem as provided in the R.raw.nmap_a-c resources.
Uses whatever Nmap.bindir as the location to write nmap.
private  boolean writeNmap_5_50()
           
private  void writeOthers(java.lang.String filename, int resource)
          Write the other files to disk.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bindir

private transient java.lang.String bindir

context

private transient Context context

forceRestart

private transient boolean forceRestart
If the second parameter sent to new NmapInstall(Context, String) is "restart" then NmapInstall will send a message to NmapMain.handler telling it to restart the app after install completes.


resources

private transient Resources resources
Once you have the application Context, use that to establish a Resources object that can be used to open the R.raw.* files.

Constructor Detail

NmapInstall

public NmapInstall()
Method Detail

createNewFileAndDeleteExisting

private void createNewFileAndDeleteExisting(java.lang.String path)
Simple method for deleting a file if it does not exist. Note there could be a bug here - if the expected behavior was to /create/ the file, then this is always creating a file, then deleting it. Seems a little backward.

Parameters:
path -

doInBackground

protected java.lang.Void doInBackground(java.lang.Object... params)

onPostExecute

protected void onPostExecute(java.lang.Void myVoid)

setPermissions

private void setPermissions()
                     throws java.io.IOException,
                            java.lang.InterruptedException
Uses CHMOD and CHOWN to set permissions based on NmapMain.canGetRoot.

Throws:
java.io.IOException
java.lang.InterruptedException

writeNcat

private void writeNcat()
                throws java.io.IOException
Write the Ncat file to disk.

Throws:
java.io.IOException

writeNmap_5_30BETA1

private void writeNmap_5_30BETA1()
                          throws java.io.IOException
Writes the Nmap binary to filesystem as provided in the R.raw.nmap_a-c resources.
Uses whatever Nmap.bindir as the location to write nmap.

Throws:
java.io.IOException

writeNmap_5_50

private boolean writeNmap_5_50()
                        throws java.io.IOException
Throws:
java.io.IOException

writeOthers

private void writeOthers(java.lang.String filename,
                         int resource)
                  throws java.io.IOException
Write the other files to disk.

Parameters:
filename - Filename that corresponds with the resource.
resource - Resource in R.raw.*.
Throws:
java.io.IOException