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.

Since:
0.4.6 COMPLETE REWRITE
Version:
0.4.8
Author:
William John Holden (wjholden@gmail.com)

Field Summary
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, MI_DEBUG_EMAIL, MI_DEBUG_ENABLE, MI_EXIT, MI_MORE_HELP, MI_REINSTALL, MI_SURVEY, RUN_COMPLETE, RUN_ERROR, RUN_LINE, SCANTYPE_NCAT, SCANTYPE_NDIFF, SCANTYPE_NMAP, SCANTYPE_NPING, 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()
          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  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

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

private void writeNmap()
                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

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