|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.wjholden.nmap.NmapUtilities
public final class NmapUtilities
Class created to centralize and more easily manage certain pieces of boilerplate code, often code groups that are required more than once. PMD recommended I make this a "singleton" so here goes.
Field Summary | |
---|---|
static boolean |
canGetRoot
Tells us if "su" command is available |
private static Context |
context
Experimental: save the context as a private static variable, this way you need an NmapUtilities.init(Context) method, but don't need to pass context every time you run one of these variables, thereby simplifying the Scan and Install classes. |
private static NmapUtilities |
FINAL_INSTANCE
Not used, but makes sure that only one instance of this class runs at once. |
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 | |
---|---|
private |
NmapUtilities()
Private constructor can only be called in the above FINAL_INSTANCE. |
Method Summary | |
---|---|
static java.lang.String |
checkRootPermissions()
Mimics 'which' function to find 'su' command. |
static boolean |
deleteOutputFile(java.lang.String outputFileName)
A consolidated method to delete the output file after reading it in at the end of RUN_COMPLETE in NmapMain.handler. |
static java.lang.String |
findBinDir()
Based on whether 'su' is available or not this method sets the location to write compiled binaries for later execution. |
static java.lang.String |
getDataDirectory()
Find the data directory to store applications in. |
static java.lang.String |
hashFile(java.lang.String filename,
java.lang.String algorithm)
Code slightly adapted from my previous work on MD5 Sums in Java. Does nothing if NmapMain.debug = false. |
static void |
init(Context myContext)
|
static java.lang.String |
readOutputFile(java.lang.String command,
java.lang.String type)
This used to be in the RUN_COMPLETE area of NmapMain.handler. |
static java.lang.String |
verifyTemporaryFolder()
Removed from verifyInstallation for version 21. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static boolean canGetRoot
private static Context context
private static final NmapUtilities FINAL_INSTANCE
Constructor Detail |
---|
private NmapUtilities()
Method Detail |
---|
public static java.lang.String checkRootPermissions()
public static boolean deleteOutputFile(java.lang.String outputFileName)
outputFileName
- String representation of the absolute path to the file.
public static java.lang.String findBinDir()
public static java.lang.String getDataDirectory()
public static java.lang.String hashFile(java.lang.String filename, java.lang.String algorithm) throws java.io.IOException
filename
- Filename to be hashed.algorithm
- In this program, always use "MD5".
java.io.IOException
- Should be handled in the 'ordinary' logic of the binary write process anyways.public static void init(Context myContext)
public static java.lang.String readOutputFile(java.lang.String command, java.lang.String type)
command
- Until nping and ncat are fixed this will always be 'nmap'.type
- Valid values are 'nmap', 'xml', and 'gnmap'.
public static java.lang.String verifyTemporaryFolder() throws java.io.IOException, NameNotFoundException
java.io.IOException
NameNotFoundException
|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |