From 0bb37a029e21fa17dba485ca9d38bb07ca5a3809 Mon Sep 17 00:00:00 2001 From: Eamonn Saunders Date: Thu, 9 Apr 2015 11:58:26 -0400 Subject: [PATCH 1/9] - Added support for connecting to remote Solr server. - Refactored local Solr server startup logic. --- .../sleuthkit/autopsy/casemodule/Case.java | 25 ++- .../autopsy/casemodule/CaseSchema.xsd | 3 + .../autopsy/casemodule/XMLCaseManagement.java | 39 ++++- .../autopsy/keywordsearch/Installer.java | 147 ++---------------- .../autopsy/keywordsearch/Server.java | 104 +++++++++++-- 5 files changed, 165 insertions(+), 153 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/Case.java b/Core/src/org/sleuthkit/autopsy/casemodule/Case.java index 6c41241135..fc527d9b9d 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/Case.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/Case.java @@ -337,16 +337,20 @@ public class Case implements SleuthkitCase.ErrorObserver { XMLCaseManagement xmlcm = new XMLCaseManagement(); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_HHmmss"); + Date date = new Date(); + String indexName = caseName + "_" + dateFormat.format(date); + String dbName = null; - // figure out the database name + + // figure out the database name and index name for text extraction if (caseType == CaseType.SINGLE_USER_CASE) { dbName = caseDir + File.separator + "autopsy.db"; //NON-NLS } else if (caseType == CaseType.MULTI_USER_CASE) { - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_HHmmss"); - dbName = caseName + "_" + dateFormat.format(new Date()); + dbName = caseName + "_" + dateFormat.format(date); } - xmlcm.create(caseDir, caseName, examiner, caseNumber, caseType, dbName); // create a new XML config file + xmlcm.create(caseDir, caseName, examiner, caseNumber, caseType, dbName, indexName); // create a new XML config file xmlcm.writeFile(); SleuthkitCase db = null; @@ -838,6 +842,19 @@ public class Case implements SleuthkitCase.ErrorObserver { } } + /** + * Get the name of the index where extracted text is stored for the case. + * + * @return Index name. + */ + public String getTextIndexName() { + if (xmlcm == null) { + return ""; + } else { + return xmlcm.getTextIndexName(); + } + } + /** * Get absolute module output directory path where modules should save their * permanent data The directory is a subdirectory of this case dir. diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/CaseSchema.xsd b/Core/src/org/sleuthkit/autopsy/casemodule/CaseSchema.xsd index 442eae823f..63c9aa49df 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/CaseSchema.xsd +++ b/Core/src/org/sleuthkit/autopsy/casemodule/CaseSchema.xsd @@ -16,6 +16,8 @@ + + @@ -99,6 +101,7 @@ + diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/XMLCaseManagement.java b/Core/src/org/sleuthkit/autopsy/casemodule/XMLCaseManagement.java index f1ad541b5e..86b9ddc770 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/XMLCaseManagement.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/XMLCaseManagement.java @@ -60,6 +60,7 @@ import org.xml.sax.SAXException; final static String SCHEMA_VERSION_NAME = "SchemaVersion"; //NON-NLS final static String AUTOPSY_CRVERSION_NAME = "AutopsyCreatedVersion"; //NON-NLS final static String AUTOPSY_MVERSION_NAME = "AutopsySavedVersion"; //NON-NLS + final static String CASE_TEXT_INDEX_NAME = "TextIndexName"; //NON-NLS // folders inside case directory final static String LOG_FOLDER_NAME = "LogFolder"; //NON-NLS final static String LOG_FOLDER_RELPATH = "Log"; //NON-NLS @@ -88,6 +89,7 @@ import org.xml.sax.SAXException; private String autopsySavedVersion; private CaseType caseType; // The type of case: local or shared private String dbName; // The name of the database + private String textIndexName; // The name of the index where extracted text is stored. // for error handling private JPanel caller; @@ -247,6 +249,34 @@ import org.xml.sax.SAXException; } /** + * Sets the text index name internally (on local variable in this class) + * + * @param textIndexName the new name for the index where extracted text + * is stored for the case. + */ + private void setTextIndexName(String textIndexName) { + this.textIndexName= textIndexName; // change this to change the xml file if needed + } + + /** + * Gets the name of the index where extracted text is stored. + * + * @return the index name + */ + public String getTextIndexName() { + if (doc == null) { + return ""; + } else { + if (getCaseElement().getElementsByTagName(CASE_TEXT_INDEX_NAME).getLength() > 0) { + Element nameElement = (Element) getCaseElement().getElementsByTagName(CASE_TEXT_INDEX_NAME).item(0); + return nameElement.getTextContent(); + } else { + return ""; /// couldn't find one, so return a blank index name + } + } + } + + /** * Sets the examiner name internally (on local variable in this class) * * @param givenExaminer the new examiner @@ -503,8 +533,9 @@ import org.xml.sax.SAXException; * @param caseNumber case number (optional), can be empty * @param dbName the name of the database. Could be a local path, could be * a Postgre db name. + * @param textIndexName The name of the index where extracted text is stored. */ - protected void create(String dirPath, String caseName, String examiner, String caseNumber, CaseType caseType, String dbName) throws CaseActionException { + protected void create(String dirPath, String caseName, String examiner, String caseNumber, CaseType caseType, String dbName, String textIndexName) throws CaseActionException { clear(); // clear the previous data // set the case Name and Directory and the parent directory @@ -514,6 +545,7 @@ import org.xml.sax.SAXException; setNumber(caseNumber); setCaseType(caseType); setDatabaseName(dbName); + setTextIndexName(textIndexName); DocumentBuilder docBuilder; DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); @@ -593,6 +625,10 @@ import org.xml.sax.SAXException; dbNameElement.appendChild(doc.createTextNode(dbName)); caseElement.appendChild(dbNameElement); + Element indexNameElement = doc.createElement(CASE_TEXT_INDEX_NAME); // ... + indexNameElement.appendChild(doc.createTextNode(textIndexName)); + caseElement.appendChild(indexNameElement); + // write more code if needed ... } @@ -761,5 +797,6 @@ import org.xml.sax.SAXException; examiner = ""; caseType = CaseType.SINGLE_USER_CASE; dbName = ""; + textIndexName = ""; } } diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Installer.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Installer.java index 99f4f288d4..677ad0e4c4 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Installer.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Installer.java @@ -38,7 +38,6 @@ import org.sleuthkit.autopsy.coreutils.Version; class Installer extends ModuleInstall { private static final Logger logger = Logger.getLogger(Installer.class.getName()); - private final static int SERVER_START_RETRIES = 5; @Override public void restored() { @@ -48,138 +47,19 @@ class Installer extends ModuleInstall { Case.addPropertyChangeListener(new KeywordSearch.CaseChangeListener()); final Server server = KeywordSearch.getServer(); - int retries = SERVER_START_RETRIES; - - //TODO revise this logic, handle other server types, move some logic to Server class try { - //check if running from previous application instance and try to shut down - logger.log(Level.INFO, "Checking if server is running"); //NON-NLS - if (server.isRunning()) { - //TODO this could hang if other type of server is running - logger.log(Level.WARNING, "Already a server running on " + server.getCurrentSolrServerPort() //NON-NLS - + " port, maybe leftover from a previous run. Trying to shut it down."); //NON-NLS - //stop gracefully - server.stop(); - logger.log(Level.INFO, "Re-checking if server is running"); //NON-NLS - if (server.isRunning()) { - int serverPort = server.getCurrentSolrServerPort(); - int serverStopPort = server.getCurrentSolrStopPort(); - logger.log(Level.SEVERE, "There's already a server running on " //NON-NLS - + serverPort + " port that can't be shutdown."); //NON-NLS - if (!Server.isPortAvailable(serverPort)) { - reportPortError(serverPort); - } else if (!Server.isPortAvailable(serverStopPort)) { - reportStopPortError(serverStopPort); - } else { - //some other reason - reportInitError(); - } - - //in this case give up - - } else { - logger.log(Level.INFO, "Old Solr server shutdown successfully."); //NON-NLS - //make sure there really isn't a hang Solr process, in case isRunning() reported false - server.killSolr(); - } - } - } catch (KeywordSearchModuleException e) { - logger.log(Level.SEVERE, "Starting server failed, will try to kill. ", e); //NON-NLS - server.killSolr(); + server.start(); + } catch (SolrServerNoPortException ex) { + logger.log(Level.SEVERE, "Failed to start Keyword Search server: ", ex); //NON-NLS + if (ex.getPortNumber() == server.getCurrentSolrServerPort()) + reportPortError(ex.getPortNumber()); + else + reportStopPortError(ex.getPortNumber()); } - - - try { - //Ensure no other process is still bound to that port, even if we think solr is not running - //Try to bind to the port 4 times at 1 second intervals. - //TODO move some of this logic to Server class - for (int i = 0; i <= 3; i++) { - logger.log(Level.INFO, "Checking if port available."); //NON-NLS - if (Server.isPortAvailable(server.getCurrentSolrServerPort())) { - logger.log(Level.INFO, "Port available, trying to start server."); //NON-NLS - server.start(); - break; - } else if (i == 3) { - logger.log(Level.INFO, "No port available, done retrying."); //NON-NLS - reportPortError(server.getCurrentSolrServerPort()); - retries = 0; - break; - } else { - try { - Thread.sleep(1000); - } catch (InterruptedException iex) { - logger.log(Level.WARNING, "Timer interrupted"); //NON-NLS - } - } - } - } catch (SolrServerNoPortException npe) { - logger.log(Level.SEVERE, "Starting server failed due to no port available. ", npe); //NON-NLS - //try to kill it - - } catch (KeywordSearchModuleException e) { - logger.log(Level.SEVERE, "Starting server failed. ", e); //NON-NLS - } - - - //retry if needed - //TODO this loop may be now redundant - while (retries-- > 0) { - try { - Thread.sleep(1000); - } catch (InterruptedException ex) { - logger.log(Level.WARNING, "Timer interrupted."); //NON-NLS - } - - try { - logger.log(Level.INFO, "Ensuring the server is running, retries remaining: " + retries); //NON-NLS - if (!server.isRunning()) { - logger.log(Level.WARNING, "Server still not running"); //NON-NLS - try { - logger.log(Level.WARNING, "Trying to start the server. "); //NON-NLS - server.start(); - } catch (SolrServerNoPortException npe) { - logger.log(Level.SEVERE, "Starting server failed due to no port available. ", npe); //NON-NLS - } - } else { - logger.log(Level.INFO, "Server appears now running. "); //NON-NLS - break; - } - } catch (KeywordSearchModuleException ex) { - logger.log(Level.SEVERE, "Starting server failed. ", ex); //NON-NLS - //retry if has retries - } - - } //end of retry while loop - - - //last check if still not running to report errors - try { - Thread.sleep(1000); - } catch (InterruptedException ex) { - logger.log(Level.WARNING, "Timer interrupted."); //NON-NLS - } - try { - logger.log(Level.INFO, "Last check if server is running. "); //NON-NLS - if (!server.isRunning()) { - logger.log(Level.SEVERE, "Server is still not running. "); //NON-NLS - //check if port is taken or some other reason - int serverPort = server.getCurrentSolrServerPort(); - int serverStopPort = server.getCurrentSolrStopPort(); - if (!Server.isPortAvailable(serverPort)) { - reportPortError(serverPort); - } else if (!Server.isPortAvailable(serverStopPort)) { - reportStopPortError(serverStopPort); - } else { - //some other reason - reportInitError(); - } - } - } catch (KeywordSearchModuleException ex) { - logger.log(Level.SEVERE, "Starting server failed. ", ex); //NON-NLS - reportInitError(); - } - - + catch (KeywordSearchModuleException ex) { + logger.log(Level.SEVERE, "Failed to start Keyword Search server: ", ex); //NON-NLS + reportInitError(ex.getMessage()); + } } @Override @@ -218,13 +98,10 @@ class Installer extends ModuleInstall { }); } - private void reportInitError() { + private void reportInitError(final String msg) { WindowManager.getDefault().invokeWhenUIReady(new Runnable() { @Override public void run() { - final String msg = NbBundle.getMessage(this.getClass(), "Installer.reportInitError", KeywordSearch.getServer().getCurrentSolrServerPort(), Version.getName(), Server.PROPERTIES_CURRENT_SERVER_PORT, Server.PROPERTIES_FILE); - MessageNotifyUtil.Notify.error(NbBundle.getMessage(this.getClass(), "Installer.errorInitKsmMsg"), msg); - MessageNotifyUtil.Notify.error(NbBundle.getMessage(this.getClass(), "Installer.errorInitKsmMsg"), msg); } }); diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Server.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Server.java index de6871788c..6e9dfeb90a 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Server.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Server.java @@ -61,6 +61,7 @@ import org.sleuthkit.autopsy.coreutils.PlatformUtil; import org.sleuthkit.datamodel.Content; import org.apache.solr.common.SolrInputDocument; import org.apache.solr.client.solrj.impl.XMLResponseParser; +import org.apache.solr.client.solrj.response.SolrPingResponse; import org.apache.solr.common.SolrDocument; import org.apache.solr.common.SolrException; @@ -148,7 +149,6 @@ public class Server { public static final long MAX_CONTENT_SIZE = 1L * 1024 * 1024 * 1024; private static final Logger logger = Logger.getLogger(Server.class.getName()); private static final String DEFAULT_CORE_NAME = "coreCase"; //NON-NLS - // TODO: DEFAULT_CORE_NAME needs to be replaced with unique names to support multiple open cases public static final String CORE_EVT = "CORE_EVT"; //NON-NLS public static final char ID_CHUNK_SEP = '_'; private String javaPath = "java"; //NON-NLS @@ -159,11 +159,14 @@ public class Server { static final String PROPERTIES_FILE = KeywordSearchSettings.MODULE_NAME; static final String PROPERTIES_CURRENT_SERVER_PORT = "IndexingServerPort"; //NON-NLS static final String PROPERTIES_CURRENT_STOP_PORT = "IndexingServerStopPort"; //NON-NLS + static final String PROPERTIES_SOLR_SERVER_HOST = "IndexingServerHost"; //NON-NLS private static final String KEY = "jjk#09s"; //NON-NLS + static final String DEFAULT_SOLR_SERVER_HOST = "localhost"; //NON-NLS static final int DEFAULT_SOLR_SERVER_PORT = 23232; static final int DEFAULT_SOLR_STOP_PORT = 34343; private int currentSolrServerPort = 0; private int currentSolrStopPort = 0; + private String solrServerHost; private static final boolean DEBUG = false;//(Version.getBuildType() == Version.Type.DEVELOPMENT); public enum CORE_EVT_STATES { @@ -185,7 +188,7 @@ public class Server { Server() { initSettings(); - this.solrUrl = "http://localhost:" + currentSolrServerPort + "/solr"; //NON-NLS + this.solrUrl = "http://" + solrServerHost + ":" + currentSolrServerPort + "/solr"; //NON-NLS this.solrServer = new HttpSolrServer(solrUrl); serverAction = new ServerAction(); solrFolder = InstalledFileLocator.getDefault().locate("solr", Server.class.getPackage().getName(), false); //NON-NLS @@ -196,6 +199,11 @@ public class Server { } private void initSettings() { + solrServerHost = ModuleSettings.getConfigSetting(PROPERTIES_FILE, PROPERTIES_SOLR_SERVER_HOST); + if (solrServerHost == null || solrServerHost.isEmpty()) { + solrServerHost = DEFAULT_SOLR_SERVER_HOST; + } + if (ModuleSettings.settingExists(PROPERTIES_FILE, PROPERTIES_CURRENT_SERVER_PORT)) { try { currentSolrServerPort = Integer.decode(ModuleSettings.getConfigSetting(PROPERTIES_FILE, PROPERTIES_CURRENT_SERVER_PORT)); @@ -328,7 +336,7 @@ public class Server { List pids = new ArrayList(); //NOTE: these needs to be in sync with process start string in start() - final String pidsQuery = "Args.4.eq=-DSTOP.KEY=" + KEY + ",Args.7.eq=start.jar"; //NON-NLS + final String pidsQuery = "Args.4.eq=-DSTOP.KEY=" + KEY + ",Args.6.eq=start.jar"; //NON-NLS long[] pidsArr = PlatformUtil.getJavaPIDs(pidsQuery); if (pidsArr != null) { @@ -358,7 +366,55 @@ public class Server { * successful. */ void start() throws KeywordSearchModuleException, SolrServerNoPortException { + + if (isSolrLocal()) { + startLocalServer(); + } + else { + try { + SolrPingResponse response = solrServer.ping(); + } + catch (SolrServerException | IOException ex) { + throw new KeywordSearchModuleException("Failed to connect to Solr server at: " + solrUrl, ex); + } + } + } + + private void startLocalServer() throws KeywordSearchModuleException, SolrServerNoPortException { + + if (isRunning()) { + // If a Solr server is running we stop it. + stop(); + } + + if (!isPortAvailable(currentSolrServerPort)){ + // There is something already listening on our port. Let's see if + // this is from an earlier run that didn't successfully shut down + // and if so kill it. + final List pids = this.getSolrPIDs(); + + // If the culprit listening on the port is not a Solr process + // we refuse to start. + if (pids.isEmpty()) { + throw new SolrServerNoPortException(currentSolrServerPort); + } + + // Ok, we've tried to stop it above but there still appears to be + // a Solr process listening on our port so we forcefully kill it. + killSolr(); + + // If either of the ports are still in use after our attempt to kill + // previously running processes we give up and throw an exception. + if (!isPortAvailable(currentSolrServerPort)) { + throw new SolrServerNoPortException(currentSolrServerPort); + } + if (!isPortAvailable(currentSolrStopPort)) { + throw new SolrServerNoPortException(currentSolrStopPort); + } + } + logger.log(Level.INFO, "Starting Solr server from: " + solrFolder.getAbsolutePath()); //NON-NLS + if (isPortAvailable(currentSolrServerPort)) { logger.log(Level.INFO, "Port [" + currentSolrServerPort + "] available, starting Solr"); //NON-NLS try { @@ -405,6 +461,7 @@ public class Server { } catch (InterruptedException ex) { logger.log(Level.WARNING, "Timer interrupted"); //NON-NLS } + final List pids = this.getSolrPIDs(); logger.log(Level.INFO, "New Solr process PID: " + pids); //NON-NLS } catch (SecurityException ex) { @@ -416,12 +473,9 @@ public class Server { throw new KeywordSearchModuleException( NbBundle.getMessage(this.getClass(), "Server.start.exception.cantStartSolr.msg2"), ex); } - } else { - logger.log(Level.SEVERE, "Could not start Solr server process, port [" + currentSolrServerPort + "] not available!"); //NON-NLS - throw new SolrServerNoPortException(currentSolrServerPort); - } + } } - + /** * Checks to see if a specific port is available. * @@ -451,6 +505,14 @@ public class Server { return false; } + /** + * + * @return true if Solr is running on the local machine, false otherwise. + */ + private boolean isSolrLocal() { + return solrServerHost.equalsIgnoreCase("localhost"); + } + /** * Changes the current solr server port. Only call this after available. * @@ -477,6 +539,11 @@ public class Server { * Waits for the stop command to finish before returning. */ synchronized void stop() { + + // For a remote Solr server this is a no-op. + if (!isSolrLocal()) + return; + try { logger.log(Level.INFO, "Stopping Solr server from: " + solrFolder.getAbsolutePath()); //NON-NLS //try graceful shutdown @@ -525,11 +592,19 @@ public class Server { */ synchronized boolean isRunning() throws KeywordSearchModuleException { try { + + if (isSolrLocal()) { + if (isPortAvailable(currentSolrServerPort)) { + return false; + } + + if (curSolrProcess != null && !curSolrProcess.isAlive()) { + return false; + } + } // making a status request here instead of just doing solrServer.ping(), because // that doesn't work when there are no cores - //TODO check if port avail and return false if it is - //TODO handle timeout in cases when some other type of server on that port CoreAdminRequest.getStatus(null, solrServer); @@ -642,7 +717,8 @@ public class Server { */ private synchronized Core openCore(Case theCase) throws KeywordSearchModuleException { String dataDir = getIndexDirPath(theCase); - return this.openCore(DEFAULT_CORE_NAME, new File(dataDir)); + String coreName = theCase.getTextIndexName(); + return this.openCore(coreName.isEmpty() ? DEFAULT_CORE_NAME : coreName, new File(dataDir)); } /** @@ -929,7 +1005,9 @@ public class Server { CoreAdminRequest.Create createCore = new CoreAdminRequest.Create(); createCore.setDataDir(dataDir.getAbsolutePath()); - createCore.setInstanceDir(instanceDir); + if (isSolrLocal()) { + createCore.setInstanceDir(instanceDir); + } createCore.setCoreName(coreName); createCore.setConfigSet("AutopsyConfig"); @@ -939,7 +1017,7 @@ public class Server { return newCore; - } catch (SolrServerException ex) { + } catch (SolrServerException | SolrException ex) { throw new KeywordSearchModuleException( NbBundle.getMessage(this.getClass(), "Server.openCore.exception.cantOpen.msg"), ex); } catch (IOException ex) { From cdbce54a7b5180acbd57da567feb6f3b1e53f877 Mon Sep 17 00:00:00 2001 From: Eamonn Saunders Date: Tue, 14 Apr 2015 17:43:30 -0400 Subject: [PATCH 2/9] Discovered a dependency on commons io during testing. --- KeywordSearch/nbproject/project.xml | 152 ++++++++++++++-------------- 1 file changed, 78 insertions(+), 74 deletions(-) diff --git a/KeywordSearch/nbproject/project.xml b/KeywordSearch/nbproject/project.xml index f07f7894a0..0f823bd9be 100644 --- a/KeywordSearch/nbproject/project.xml +++ b/KeywordSearch/nbproject/project.xml @@ -169,58 +169,14 @@ ext/bcmail-jdk15-1.45.jar release/modules/ext/bcmail-jdk15-1.45.jar - - ext/bcprov-jdk15-1.45.jar - release/modules/ext/bcprov-jdk15-1.45.jar - - - ext/commons-logging-api-1.1.jar - release/modules/ext/commons-logging-api-1.1.jar - - - ext/commons-logging-1.1.1.jar - release/modules/ext/commons-logging-1.1.1.jar - - - ext/commons-compress-1.5.jar - release/modules/ext/commons-compress-1.5.jar - - - ext/commons-lang-2.4.jar - release/modules/ext/commons-lang-2.4.jar - - - ext/commons-lang-2.4-javadoc.jar - release/modules/ext/commons-lang-2.4-javadoc.jar - - - ext/commons-lang-2.4-sources.jar - release/modules/ext/commons-lang-2.4-sources.jar - ext/tika-parsers-1.5.jar release/modules/ext/tika-parsers-1.5.jar - - ext/tika-core-1.5.jar - release/modules/ext/tika-core-1.5.jar - - - ext/metadata-extractor-2.7.2.jar - release/modules/ext/metadata-extractor-2.7.2.jar - - - ext/xmpcore-5.1.2.jar - release/modules/ext/xmpcore-5.1.2.jar - ext/jericho-html-3.3.jar release/modules/ext/jericho-html-3.3.jar - - ext/jericho-html-3.3-sources.jar - release/modules/ext/jericho-html-3.3-sources.jar - ext/org.osgi.compendium-4.0.0.jar release/modules/ext/org.osgi.compendium-4.0.0.jar @@ -234,33 +190,57 @@ release/modules/ext/xmlbeans-2.3.0.jar - ext/asm-all-3.1.jar - release/modules/ext/asm-all-3.1.jar - - - ext/poi-3.10-beta2.jar - release/modules/ext/poi-3.10-beta2.jar + ext/jempbox-1.8.4.jar + release/modules/ext/jempbox-1.8.4.jar ext/poi-ooxml-3.10-beta2.jar release/modules/ext/poi-ooxml-3.10-beta2.jar - ext/poi-ooxml-schemas-3.10-beta2.jar - release/modules/ext/poi-ooxml-schemas-3.10-beta2.jar + ext/commons-logging-api-1.1.jar + release/modules/ext/commons-logging-api-1.1.jar - ext/poi-scratchpad-3.10-beta2.jar - release/modules/ext/poi-scratchpad-3.10-beta2.jar + ext/asm-all-3.1.jar + release/modules/ext/asm-all-3.1.jar + + + ext/solr-solrj-4.9.1-javadoc.jar + release/modules/ext/solr-solrj-4.9.1-javadoc.jar + + + ext/poi-3.10-beta2.jar + release/modules/ext/poi-3.10-beta2.jar ext/icu4j-3.8.jar release/modules/ext/icu4j-3.8.jar + + ext/fontbox-1.8.4.jar + release/modules/ext/fontbox-1.8.4.jar + + + ext/xmpcore-5.1.2.jar + release/modules/ext/xmpcore-5.1.2.jar + + + ext/metadata-extractor-2.7.2.jar + release/modules/ext/metadata-extractor-2.7.2.jar + ext/tagsoup-1.2.1.jar release/modules/ext/tagsoup-1.2.1.jar + + ext/commons-compress-1.5.jar + release/modules/ext/commons-compress-1.5.jar + + + ext/commons-lang-2.4-javadoc.jar + release/modules/ext/commons-lang-2.4-javadoc.jar + ext/org.osgi.core-4.0.0.jar release/modules/ext/org.osgi.core-4.0.0.jar @@ -269,14 +249,6 @@ ext/httpclient-4.3.1.jar release/modules/ext/httpclient-4.3.1.jar - - ext/httpcore-4.3.jar - release/modules/ext/httpcore-4.3.jar - - - ext/httpmime-4.3.1.jar - release/modules/ext/httpmime-4.3.1.jar - ext/isoparser-1.0-RC-1.jar release/modules/ext/isoparser-1.0-RC-1.jar @@ -285,6 +257,14 @@ ext/log4j-1.2.17.jar release/modules/ext/log4j-1.2.17.jar + + ext/commons-lang-2.4-sources.jar + release/modules/ext/commons-lang-2.4-sources.jar + + + ext/tika-core-1.5.jar + release/modules/ext/tika-core-1.5.jar + ext/jericho-html-3.3-javadoc.jar release/modules/ext/jericho-html-3.3-javadoc.jar @@ -302,12 +282,12 @@ release/modules/ext/solr-solrj-4.9.1.jar - ext/solr-solrj-4.9.1-javadoc.jar - release/modules/ext/solr-solrj-4.9.1-javadoc.jar + ext/poi-scratchpad-3.10-beta2.jar + release/modules/ext/poi-scratchpad-3.10-beta2.jar - ext/solr-solrj-4.9.1-sources.jar - release/modules/ext/solr-solrj-4.9.1-sources.jar + ext/commons-logging-1.1.1.jar + release/modules/ext/commons-logging-1.1.1.jar ext/netcdf-4.2-min.jar @@ -317,6 +297,18 @@ ext/vorbis-java-core-0.1-tests.jar release/modules/ext/vorbis-java-core-0.1-tests.jar + + ext/commons-io-2.3.jar + release/modules/ext/commons-io-2.3.jar + + + ext/jericho-html-3.3-sources.jar + release/modules/ext/jericho-html-3.3-sources.jar + + + ext/solr-solrj-4.9.1-sources.jar + release/modules/ext/solr-solrj-4.9.1-sources.jar + ext/juniversalchardet-1.0.3.jar release/modules/ext/juniversalchardet-1.0.3.jar @@ -333,10 +325,22 @@ ext/apache-mime4j-core-0.7.2.jar release/modules/ext/apache-mime4j-core-0.7.2.jar + + ext/httpmime-4.3.1.jar + release/modules/ext/httpmime-4.3.1.jar + ext/qdox-1.12.jar release/modules/ext/qdox-1.12.jar + + ext/httpcore-4.3.jar + release/modules/ext/httpcore-4.3.jar + + + ext/commons-lang-2.4.jar + release/modules/ext/commons-lang-2.4.jar + ext/rome-0.9.jar release/modules/ext/rome-0.9.jar @@ -353,18 +357,14 @@ ext/jdom-1.0.jar release/modules/ext/jdom-1.0.jar + + ext/poi-ooxml-schemas-3.10-beta2.jar + release/modules/ext/poi-ooxml-schemas-3.10-beta2.jar + ext/pdfbox-1.8.4.jar release/modules/ext/pdfbox-1.8.4.jar - - ext/fontbox-1.8.4.jar - release/modules/ext/fontbox-1.8.4.jar - - - ext/jempbox-1.8.4.jar - release/modules/ext/jempbox-1.8.4.jar - ext/wstx-asl-3.2.7.jar release/modules/ext/wstx-asl-3.2.7.jar @@ -377,6 +377,10 @@ ext/dom4j-1.6.1.jar release/modules/ext/dom4j-1.6.1.jar + + ext/bcprov-jdk15-1.45.jar + release/modules/ext/bcprov-jdk15-1.45.jar + From a59dfb83c5cee59cc91052a01be052908dfa67ee Mon Sep 17 00:00:00 2001 From: Eamonn Saunders Date: Tue, 14 Apr 2015 18:09:32 -0400 Subject: [PATCH 3/9] Added properties for indexing server host and port (and methods to access them). --- .../autopsy/core/UserPreferences.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Core/src/org/sleuthkit/autopsy/core/UserPreferences.java b/Core/src/org/sleuthkit/autopsy/core/UserPreferences.java index 2d92ac6814..d5fecdd6a4 100755 --- a/Core/src/org/sleuthkit/autopsy/core/UserPreferences.java +++ b/Core/src/org/sleuthkit/autopsy/core/UserPreferences.java @@ -43,6 +43,8 @@ public final class UserPreferences { public static final String EXTERNAL_DATABASE_PASSWORD = "ExternalDatabasePassword"; //NON-NLS public static final String EXTERNAL_DATABASE_TYPE = "ExternalDatabaseType"; //NON-NLS public static final String NEW_CASE_TYPE = "NewCaseType"; //NON-NLS + public static final String INDEXING_SERVER_HOST = "IndexingServerHost"; //NON-NLS + public static final String INDEXING_SERVER_PORT = "IndexingServerPort"; //NON-NLS // Prevent instantiation. private UserPreferences() { @@ -126,4 +128,20 @@ public final class UserPreferences { public static void setNewCaseType(int value) { preferences.putInt(NEW_CASE_TYPE, value); } + + public static String getIndexingServerHost() { + return preferences.get(INDEXING_SERVER_HOST, ""); + } + + public static void setIndexingServerHost(String hostName) { + preferences.put(INDEXING_SERVER_HOST, hostName); + } + + public static int getIndexingServerPort() { + return preferences.getInt(INDEXING_SERVER_PORT, 0); + } + + public static void setIndexingServerPort(int port) { + preferences.putInt(INDEXING_SERVER_PORT, port); + } } From 99b10065195723f567a35134a72a1204b957d1b7 Mon Sep 17 00:00:00 2001 From: Eamonn Saunders Date: Tue, 14 Apr 2015 18:11:33 -0400 Subject: [PATCH 4/9] Realized that we need to support both a local and remote Solr server connections in the same Autopsy instance since users can choose "single" vs "multi" user for each case they create. --- .../autopsy/keywordsearch/Server.java | 118 ++++++++---------- 1 file changed, 49 insertions(+), 69 deletions(-) diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Server.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Server.java index 6e9dfeb90a..2fbb45f79c 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Server.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Server.java @@ -45,7 +45,6 @@ import org.openide.util.NbBundle; import org.sleuthkit.autopsy.coreutils.Logger; import javax.swing.AbstractAction; import org.apache.solr.client.solrj.SolrQuery; -import org.apache.solr.client.solrj.SolrServer; import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.request.CoreAdminRequest; import org.apache.solr.client.solrj.response.QueryResponse; @@ -61,9 +60,10 @@ import org.sleuthkit.autopsy.coreutils.PlatformUtil; import org.sleuthkit.datamodel.Content; import org.apache.solr.common.SolrInputDocument; import org.apache.solr.client.solrj.impl.XMLResponseParser; -import org.apache.solr.client.solrj.response.SolrPingResponse; import org.apache.solr.common.SolrDocument; import org.apache.solr.common.SolrException; +import org.sleuthkit.autopsy.casemodule.Case.CaseType; +import org.sleuthkit.autopsy.core.UserPreferences; /** * Handles for keeping track of a Solr server and its cores @@ -159,37 +159,39 @@ public class Server { static final String PROPERTIES_FILE = KeywordSearchSettings.MODULE_NAME; static final String PROPERTIES_CURRENT_SERVER_PORT = "IndexingServerPort"; //NON-NLS static final String PROPERTIES_CURRENT_STOP_PORT = "IndexingServerStopPort"; //NON-NLS - static final String PROPERTIES_SOLR_SERVER_HOST = "IndexingServerHost"; //NON-NLS private static final String KEY = "jjk#09s"; //NON-NLS static final String DEFAULT_SOLR_SERVER_HOST = "localhost"; //NON-NLS static final int DEFAULT_SOLR_SERVER_PORT = 23232; static final int DEFAULT_SOLR_STOP_PORT = 34343; private int currentSolrServerPort = 0; private int currentSolrStopPort = 0; - private String solrServerHost; private static final boolean DEBUG = false;//(Version.getBuildType() == Version.Type.DEVELOPMENT); public enum CORE_EVT_STATES { STOPPED, STARTED }; - private SolrServer solrServer; - private String instanceDir; - private File solrFolder; - private ServerAction serverAction; + + // A reference to the locally running Solr instance. + private final HttpSolrServer localSolrServer; + + // A reference to the Solr server we are currently connected to for the Case. + // This could be a local or remote server. + private HttpSolrServer currentSolrServer; + + private final String instanceDir; + private final File solrFolder; + private final ServerAction serverAction; private InputStreamPrinterThread errorRedirectThread; - private String solrUrl; /** * New instance for the server at the given URL * - * @param url should be something like "http://localhost:23232/solr/" */ Server() { initSettings(); - this.solrUrl = "http://" + solrServerHost + ":" + currentSolrServerPort + "/solr"; //NON-NLS - this.solrServer = new HttpSolrServer(solrUrl); + this.localSolrServer = new HttpSolrServer("http://localhost:" + currentSolrServerPort + "/solr"); //NON-NLS serverAction = new ServerAction(); solrFolder = InstalledFileLocator.getDefault().locate("solr", Server.class.getPackage().getName(), false); //NON-NLS instanceDir = solrFolder.getAbsolutePath() + File.separator + "solr"; //NON-NLS @@ -199,10 +201,6 @@ public class Server { } private void initSettings() { - solrServerHost = ModuleSettings.getConfigSetting(PROPERTIES_FILE, PROPERTIES_SOLR_SERVER_HOST); - if (solrServerHost == null || solrServerHost.isEmpty()) { - solrServerHost = DEFAULT_SOLR_SERVER_HOST; - } if (ModuleSettings.settingExists(PROPERTIES_FILE, PROPERTIES_CURRENT_SERVER_PORT)) { try { @@ -215,7 +213,7 @@ public class Server { currentSolrServerPort = DEFAULT_SOLR_SERVER_PORT; ModuleSettings.setConfigSetting(PROPERTIES_FILE, PROPERTIES_CURRENT_SERVER_PORT, String.valueOf(currentSolrServerPort)); } - + if (ModuleSettings.settingExists(PROPERTIES_FILE, PROPERTIES_CURRENT_STOP_PORT)) { try { currentSolrStopPort = Integer.decode(ModuleSettings.getConfigSetting(PROPERTIES_FILE, PROPERTIES_CURRENT_STOP_PORT)); @@ -333,7 +331,7 @@ public class Server { * @return */ List getSolrPIDs() { - List pids = new ArrayList(); + List pids = new ArrayList<>(); //NOTE: these needs to be in sync with process start string in start() final String pidsQuery = "Args.4.eq=-DSTOP.KEY=" + KEY + ",Args.6.eq=start.jar"; //NON-NLS @@ -361,27 +359,11 @@ public class Server { } /** - * Tries to start a Solr instance in a separate process. Returns immediately + * Tries to start a local Solr instance in a separate process. Returns immediately * (probably before the server is ready) and doesn't check whether it was * successful. */ void start() throws KeywordSearchModuleException, SolrServerNoPortException { - - if (isSolrLocal()) { - startLocalServer(); - } - else { - try { - SolrPingResponse response = solrServer.ping(); - } - catch (SolrServerException | IOException ex) { - throw new KeywordSearchModuleException("Failed to connect to Solr server at: " + solrUrl, ex); - } - } - } - - private void startLocalServer() throws KeywordSearchModuleException, SolrServerNoPortException { - if (isRunning()) { // If a Solr server is running we stop it. stop(); @@ -475,7 +457,7 @@ public class Server { } } } - + /** * Checks to see if a specific port is available. * @@ -505,14 +487,6 @@ public class Server { return false; } - /** - * - * @return true if Solr is running on the local machine, false otherwise. - */ - private boolean isSolrLocal() { - return solrServerHost.equalsIgnoreCase("localhost"); - } - /** * Changes the current solr server port. Only call this after available. * @@ -534,16 +508,12 @@ public class Server { } /** - * Tries to stop a Solr instance. + * Tries to stop the local Solr instance. * * Waits for the stop command to finish before returning. */ synchronized void stop() { - // For a remote Solr server this is a no-op. - if (!isSolrLocal()) - return; - try { logger.log(Level.INFO, "Stopping Solr server from: " + solrFolder.getAbsolutePath()); //NON-NLS //try graceful shutdown @@ -565,8 +535,7 @@ public class Server { curSolrProcess = null; } - } catch (InterruptedException ex) { - } catch (IOException ex) { + } catch (InterruptedException | IOException ex) { } finally { //stop Solr stream -> log redirect threads try { @@ -584,7 +553,7 @@ public class Server { } /** - * Tests if there's a Solr server running by sending it a core-status + * Tests if there's a local Solr server running by sending it a core-status * request. * * @return false if the request failed with a connection error, otherwise @@ -593,20 +562,19 @@ public class Server { synchronized boolean isRunning() throws KeywordSearchModuleException { try { - if (isSolrLocal()) { - if (isPortAvailable(currentSolrServerPort)) { - return false; - } - - if (curSolrProcess != null && !curSolrProcess.isAlive()) { - return false; - } + if (isPortAvailable(currentSolrServerPort)) { + return false; } + + if (curSolrProcess != null && !curSolrProcess.isAlive()) { + return false; + } + // making a status request here instead of just doing solrServer.ping(), because // that doesn't work when there are no cores //TODO handle timeout in cases when some other type of server on that port - CoreAdminRequest.getStatus(null, solrServer); + CoreAdminRequest.getStatus(null, localSolrServer); logger.log(Level.INFO, "Solr server is running"); //NON-NLS } catch (SolrServerException ex) { @@ -718,7 +686,7 @@ public class Server { private synchronized Core openCore(Case theCase) throws KeywordSearchModuleException { String dataDir = getIndexDirPath(theCase); String coreName = theCase.getTextIndexName(); - return this.openCore(coreName.isEmpty() ? DEFAULT_CORE_NAME : coreName, new File(dataDir)); + return this.openCore(coreName.isEmpty() ? DEFAULT_CORE_NAME : coreName, new File(dataDir), theCase.getCaseType()); } /** @@ -990,7 +958,7 @@ public class Server { * @param dataDir directory to load/store the core data from/to * @return new core */ - private Core openCore(String coreName, File dataDir) throws KeywordSearchModuleException { + private Core openCore(String coreName, File dataDir, CaseType caseType) throws KeywordSearchModuleException { try { if (!dataDir.exists()) { dataDir.mkdirs(); @@ -1005,13 +973,18 @@ public class Server { CoreAdminRequest.Create createCore = new CoreAdminRequest.Create(); createCore.setDataDir(dataDir.getAbsolutePath()); - if (isSolrLocal()) { - createCore.setInstanceDir(instanceDir); - } createCore.setCoreName(coreName); createCore.setConfigSet("AutopsyConfig"); - this.solrServer.request(createCore); + if (caseType == CaseType.SINGLE_USER_CASE) { + currentSolrServer = this.localSolrServer; + //createCore.setInstanceDir(instanceDir); + } + else { + currentSolrServer = connectToRemoteSolrServer(); + } + + currentSolrServer.request(createCore); final Core newCore = new Core(coreName); @@ -1026,6 +999,13 @@ public class Server { } } + private HttpSolrServer connectToRemoteSolrServer() { + String host = UserPreferences.getIndexingServerHost(); + String port = Integer.toString(UserPreferences.getIndexingServerPort()); + + return new HttpSolrServer("http://" + host + ":" + port + "/solr"); + } + class Core { // handle to the core in Solr @@ -1037,7 +1017,7 @@ public class Server { private Core(String name) { this.name = name; - this.solrCore = new HttpSolrServer(solrUrl + "/" + name); + this.solrCore = new HttpSolrServer(currentSolrServer.getBaseURL() + "/" + name); //TODO test these settings //solrCore.setSoTimeout(1000 * 60); // socket read timeout, make large enough so can index larger files @@ -1140,7 +1120,7 @@ public class Server { synchronized void close() throws KeywordSearchModuleException { try { - CoreAdminRequest.unloadCore(this.name, solrServer); + CoreAdminRequest.unloadCore(this.name, currentSolrServer); } catch (SolrServerException ex) { throw new KeywordSearchModuleException( NbBundle.getMessage(this.getClass(), "Server.close.exception.msg"), ex); From 247ef1f1ecc9baff1463d133a988852339291d62 Mon Sep 17 00:00:00 2001 From: Eamonn Saunders Date: Wed, 15 Apr 2015 14:53:12 -0400 Subject: [PATCH 5/9] Added CaseType member and accessor. Modified CaseType enum so as not to confuse me with its use of caseName. --- .../sleuthkit/autopsy/casemodule/Case.java | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/Case.java b/Core/src/org/sleuthkit/autopsy/casemodule/Case.java index fc527d9b9d..cbf727947c 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/Case.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/Case.java @@ -141,20 +141,20 @@ public class Case implements SleuthkitCase.ErrorObserver { SINGLE_USER_CASE("Single-user case"), MULTI_USER_CASE("Multi-user case"); - private final String caseName; + private final String caseType; private CaseType(String s) { - caseName = s; + caseType = s; } - public boolean equalsName(String otherName) { - return (otherName == null) ? false : caseName.equals(otherName); + public boolean equalsName(String otherType) { + return (otherType == null) ? false : caseType.equals(otherType); } - public static CaseType fromString(String text) { - if (text != null) { + public static CaseType fromString(String typeName) { + if (typeName != null) { for (CaseType c : CaseType.values()) { - if (text.equalsIgnoreCase(c.caseName)) { + if (typeName.equalsIgnoreCase(c.caseType)) { return c; } } @@ -164,7 +164,7 @@ public class Case implements SleuthkitCase.ErrorObserver { @Override public String toString() { - return caseName; + return caseType; } }; @@ -176,6 +176,7 @@ public class Case implements SleuthkitCase.ErrorObserver { private SleuthkitCase db; // Track the current case (only set with changeCase() method) private static Case currentCase = null; + private CaseType caseType; private Services services; private static final Logger logger = Logger.getLogger(Case.class.getName()); static final String CASE_EXTENSION = "aut"; //NON-NLS @@ -189,12 +190,13 @@ public class Case implements SleuthkitCase.ErrorObserver { /** * Constructor for the Case class */ - private Case(String name, String number, String examiner, String configFilePath, XMLCaseManagement xmlcm, SleuthkitCase db) { + private Case(String name, String number, String examiner, String configFilePath, XMLCaseManagement xmlcm, SleuthkitCase db, CaseType type) { this.name = name; this.number = number; this.examiner = examiner; this.configFilePath = configFilePath; this.xmlcm = xmlcm; + this.caseType = type; this.db = db; this.services = new Services(db); db.addErrorObserver(this); @@ -367,7 +369,7 @@ public class Case implements SleuthkitCase.ErrorObserver { NbBundle.getMessage(Case.class, "Case.create.exception.msg", caseName, caseDir), ex); } - Case newCase = new Case(caseName, caseNumber, examiner, configFilePath, xmlcm, db); + Case newCase = new Case(caseName, caseNumber, examiner, configFilePath, xmlcm, db, caseType); // newCase.messenger.start(); changeCase(newCase); @@ -396,7 +398,7 @@ public class Case implements SleuthkitCase.ErrorObserver { SleuthkitCase db; if (caseType == CaseType.SINGLE_USER_CASE) { - // if the caseName is "", case / config file can't be opened + // if the caseType is "", case / config file can't be opened if (caseName.equals("")) { throw new CaseActionException(NbBundle.getMessage(Case.class, "Case.open.exception.blankCase.msg")); } @@ -423,7 +425,7 @@ public class Case implements SleuthkitCase.ErrorObserver { checkImagesExist(db); - Case openedCase = new Case(caseName, caseNumber, examiner, configFilePath, xmlcm, db); + Case openedCase = new Case(caseName, caseNumber, examiner, configFilePath, xmlcm, db, caseType); // openedCase.messenger.start(); changeCase(openedCase); @@ -777,6 +779,14 @@ public class Case implements SleuthkitCase.ErrorObserver { } } + /** + * Get the case type. + * @return + */ + public CaseType getCaseType() { + return this.caseType; + } + /** * Gets the full path to the temp directory of this case * From a276c5facb02754ca6e29d2ea940f945bf924cee Mon Sep 17 00:00:00 2001 From: Eamonn Saunders Date: Wed, 15 Apr 2015 14:54:02 -0400 Subject: [PATCH 6/9] Use new solr.xml file format. --- KeywordSearch/release/solr/solr/solr.xml | 36 ++++++++++++++++-------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/KeywordSearch/release/solr/solr/solr.xml b/KeywordSearch/release/solr/solr/solr.xml index f2d49d693e..94d60b6a29 100644 --- a/KeywordSearch/release/solr/solr/solr.xml +++ b/KeywordSearch/release/solr/solr/solr.xml @@ -17,17 +17,29 @@ --> - + This is an example of a simple "solr.xml" file for configuring one or + more Solr Cores, as well as allowing Cores to be added, removed, and + reloaded via HTTP requests. + + More information about options available in this configuration file, + and Solr Core administration can be found online: + http://wiki.apache.org/solr/CoreAdmin +--> + + + + + ${host:} + ${jetty.port:8983} + ${hostContext:solr} + ${zkClientTimeout:30000} + ${genericCoreNodeNames:true} + + + + ${socketTimeout:0} + ${connTimeout:0} + - - - From c28c2d39342120ebf7719716be229307a4fd769e Mon Sep 17 00:00:00 2001 From: Eamonn Saunders Date: Wed, 15 Apr 2015 14:55:35 -0400 Subject: [PATCH 7/9] Added Solr and database strings for Multi User options panel. --- .../sleuthkit/autopsy/corecomponents/Bundle.properties | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/Bundle.properties b/Core/src/org/sleuthkit/autopsy/corecomponents/Bundle.properties index 97eb746ab7..c1819fc812 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/Bundle.properties @@ -162,3 +162,12 @@ MultiUserSettingsPanel.tbHostnameOrIp.text= MultiUserSettingsPanel.lbMessagingSettings.text=Messaging Settings MultiUserSettingsPanel.cbEnableMultiUser.text=Enable Multi-user cases MultiUserSettingsPanel.lbDatabaseSettings.text=Database Settings +MultiUserSettingsPanel.tbIndexingServerHost.toolTipText=Hostname or IP Address +MultiUserSettingsPanel.tbIndexingServerHost.text= +MultiUserSettingsPanel.tbIndexingServerPort.text= +MultiUserSettingsPanel.tbIndexingServerPort.toolTipText=Port Number +MultiUserSettingsPanel.missingSolrSettingsError=You must provide settings for both host and port +MultiUserSettingsPanel.invalidPortNumber=Invalid port number +MultiUserSettingsPanel.missingDatabaseSettingsError=You must fill in all values +MultiUserSettingsPanel.invalidDatabaseSettings=Invalid database settings +MultiUserSettingsPanel.lbSolrMsg.text= From a2c78156a90990d89e21dc6ef607280e5d87891c Mon Sep 17 00:00:00 2001 From: Eamonn Saunders Date: Wed, 15 Apr 2015 14:58:19 -0400 Subject: [PATCH 8/9] Added Solr settings to Multi User options panel. --- .../MultiUserSettingsPanel.form | 84 ++++++++- .../MultiUserSettingsPanel.java | 173 +++++++++++++++--- 2 files changed, 226 insertions(+), 31 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/MultiUserSettingsPanel.form b/Core/src/org/sleuthkit/autopsy/corecomponents/MultiUserSettingsPanel.form index 1dc807c2c3..242b271878 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/MultiUserSettingsPanel.form +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/MultiUserSettingsPanel.form @@ -16,7 +16,7 @@ - + @@ -39,7 +39,7 @@ - + @@ -51,10 +51,10 @@ - - + + - + @@ -126,6 +126,9 @@ + + + @@ -205,10 +208,18 @@ - + + + + + + + + + + + - - @@ -216,8 +227,15 @@ - - + + + + + + + + + @@ -233,6 +251,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/MultiUserSettingsPanel.java b/Core/src/org/sleuthkit/autopsy/corecomponents/MultiUserSettingsPanel.java index 663785e516..324496b5b0 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/MultiUserSettingsPanel.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/MultiUserSettingsPanel.java @@ -6,8 +6,14 @@ package org.sleuthkit.autopsy.corecomponents; import java.awt.Color; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.InputVerifier; +import javax.swing.JComponent; +import javax.swing.JTextField; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; +import org.openide.util.NbBundle; import org.sleuthkit.datamodel.CaseDbConnectionInfo; import org.sleuthkit.datamodel.CaseDbConnectionInfo.DbType; import org.sleuthkit.autopsy.core.UserPreferences; @@ -28,19 +34,26 @@ public class MultiUserSettingsPanel extends javax.swing.JPanel { TextPrompt tpPortNumber = new TextPrompt("Port Number", tbPortNumber); TextPrompt tpUsername = new TextPrompt("User Name", tbUsername); TextPrompt tpPassword = new TextPrompt("Password", tbPassword); + TextPrompt tpIndexingServerHost = new TextPrompt("Hostname or IP Address", tbIndexingServerHost); + TextPrompt tpIndexingServerPort = new TextPrompt("Port Number", tbIndexingServerPort); + tpHostnameOrIp.setForeground(Color.LIGHT_GRAY); tpPortNumber.setForeground(Color.LIGHT_GRAY); tpUsername.setForeground(Color.LIGHT_GRAY); tpPassword.setForeground(Color.LIGHT_GRAY); + tpIndexingServerHost.setForeground(Color.LIGHT_GRAY); + tpIndexingServerPort.setForeground(Color.LIGHT_GRAY); float alpha = 0.9f; // Mostly opaque tpHostnameOrIp.changeAlpha(alpha); tpPortNumber.changeAlpha(alpha); tpUsername.changeAlpha(alpha); tpPassword.changeAlpha(alpha); + tpIndexingServerHost.changeAlpha(alpha); + tpIndexingServerPort.changeAlpha(alpha); - setNetworkDbEnabled(cbEnableMultiUser.isSelected()); + enableNetworkProperties(cbEnableMultiUser.isSelected()); /// Register for notifications when the text boxes get updated textBoxChangedListener = new TextBoxChangedListener(); @@ -48,6 +61,8 @@ public class MultiUserSettingsPanel extends javax.swing.JPanel { tbPortNumber.getDocument().addDocumentListener(textBoxChangedListener); tbUsername.getDocument().addDocumentListener(textBoxChangedListener); tbPassword.getDocument().addDocumentListener(textBoxChangedListener); + tbIndexingServerHost.getDocument().addDocumentListener(textBoxChangedListener); + tbIndexingServerPort.getDocument().addDocumentListener(textBoxChangedListener); } /** @@ -69,6 +84,9 @@ public class MultiUserSettingsPanel extends javax.swing.JPanel { lbDatabaseSettings = new javax.swing.JLabel(); pnSolrSettings = new javax.swing.JPanel(); lbSolrSettings = new javax.swing.JLabel(); + tbIndexingServerHost = new javax.swing.JTextField(); + tbIndexingServerPort = new javax.swing.JTextField(); + lbSolrMsg = new javax.swing.JLabel(); pnMessagingSettings = new javax.swing.JPanel(); lbMessagingSettings = new javax.swing.JLabel(); cbEnableMultiUser = new javax.swing.JCheckBox(); @@ -78,6 +96,11 @@ public class MultiUserSettingsPanel extends javax.swing.JPanel { tbHostnameOrIp.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N tbHostnameOrIp.setText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbHostnameOrIp.text")); // NOI18N tbHostnameOrIp.setToolTipText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbHostnameOrIp.toolTipText")); // NOI18N + tbHostnameOrIp.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + tbHostnameOrIpActionPerformed(evt); + } + }); tbPortNumber.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N tbPortNumber.setText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbPortNumber.text")); // NOI18N @@ -142,21 +165,56 @@ public class MultiUserSettingsPanel extends javax.swing.JPanel { lbSolrSettings.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(lbSolrSettings, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.lbSolrSettings.text")); // NOI18N + tbIndexingServerHost.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N + tbIndexingServerHost.setText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbIndexingServerHost.text")); // NOI18N + tbIndexingServerHost.setToolTipText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbIndexingServerHost.toolTipText")); // NOI18N + tbIndexingServerHost.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + tbIndexingServerHostActionPerformed(evt); + } + }); + + tbIndexingServerPort.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N + tbIndexingServerPort.setText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbIndexingServerPort.text")); // NOI18N + tbIndexingServerPort.setToolTipText(org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.tbIndexingServerPort.toolTipText")); // NOI18N + tbIndexingServerPort.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + tbIndexingServerPortActionPerformed(evt); + } + }); + + lbSolrMsg.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N + lbSolrMsg.setForeground(new java.awt.Color(255, 0, 0)); + org.openide.awt.Mnemonics.setLocalizedText(lbSolrMsg, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.lbSolrMsg.text")); // NOI18N + lbSolrMsg.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM); + javax.swing.GroupLayout pnSolrSettingsLayout = new javax.swing.GroupLayout(pnSolrSettings); pnSolrSettings.setLayout(pnSolrSettingsLayout); pnSolrSettingsLayout.setHorizontalGroup( pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pnSolrSettingsLayout.createSequentialGroup() .addContainerGap() - .addComponent(lbSolrSettings) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGroup(pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(pnSolrSettingsLayout.createSequentialGroup() + .addComponent(lbSolrSettings) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(lbSolrMsg, javax.swing.GroupLayout.PREFERRED_SIZE, 320, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(tbIndexingServerHost, javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(tbIndexingServerPort, javax.swing.GroupLayout.Alignment.TRAILING)) + .addContainerGap()) ); pnSolrSettingsLayout.setVerticalGroup( pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pnSolrSettingsLayout.createSequentialGroup() .addContainerGap() - .addComponent(lbSolrSettings) - .addContainerGap(75, Short.MAX_VALUE)) + .addGroup(pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(lbSolrSettings) + .addComponent(lbSolrMsg, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(tbIndexingServerHost, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(tbIndexingServerPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(45, 45, 45)) ); pnMessagingSettings.setBorder(javax.swing.BorderFactory.createEtchedBorder()); @@ -199,7 +257,7 @@ public class MultiUserSettingsPanel extends javax.swing.JPanel { .addComponent(pnSolrSettings, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(pnDatabaseSettings, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(pnMessagingSettings, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap(21, Short.MAX_VALUE)) ); pnOverallPanelLayout.setVerticalGroup( pnOverallPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -209,17 +267,17 @@ public class MultiUserSettingsPanel extends javax.swing.JPanel { .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(pnDatabaseSettings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(pnSolrSettings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(pnSolrSettings, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(pnMessagingSettings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addContainerGap(143, Short.MAX_VALUE)) + .addContainerGap(137, Short.MAX_VALUE)) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(pnOverallPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 481, Short.MAX_VALUE) + .addComponent(pnOverallPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -232,18 +290,33 @@ public class MultiUserSettingsPanel extends javax.swing.JPanel { * * @param enabled true means enable, false means disable */ - private void setNetworkDbEnabled(boolean enabled) { + private void enableNetworkProperties(boolean enabled) { tbHostnameOrIp.setEnabled(enabled); tbPortNumber.setEnabled(enabled); tbUsername.setEnabled(enabled); tbPassword.setEnabled(enabled); + tbIndexingServerHost.setEnabled(enabled); + tbIndexingServerPort.setEnabled(enabled); } private void cbEnableMultiUserItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbEnableMultiUserItemStateChanged - setNetworkDbEnabled(cbEnableMultiUser.isSelected()); + enableNetworkProperties(cbEnableMultiUser.isSelected()); controller.changed(); }//GEN-LAST:event_cbEnableMultiUserItemStateChanged + private void tbHostnameOrIpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tbHostnameOrIpActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_tbHostnameOrIpActionPerformed + + private void tbIndexingServerHostActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tbIndexingServerHostActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_tbIndexingServerHostActionPerformed + + private void tbIndexingServerPortActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tbIndexingServerPortActionPerformed + // TODO add your handling code here: + tbIndexingServerPort.dispatchEvent(evt); + }//GEN-LAST:event_tbIndexingServerPortActionPerformed + void load() { CaseDbConnectionInfo info = UserPreferences.getDatabaseConnectionInfo(); tbHostnameOrIp.setText(info.getHost()); @@ -256,6 +329,11 @@ public class MultiUserSettingsPanel extends javax.swing.JPanel { cbEnableMultiUser.setSelected(true); } + tbIndexingServerHost.setText(UserPreferences.getIndexingServerHost()); + int indexingServerPort = UserPreferences.getIndexingServerPort(); + if (isPortValid(indexingServerPort)) { + tbIndexingServerPort.setText(Integer.toString(indexingServerPort)); + } } void store() { @@ -274,6 +352,8 @@ public class MultiUserSettingsPanel extends javax.swing.JPanel { dbType); UserPreferences.setDatabaseConnectionInfo(info); + UserPreferences.setIndexingServerHost(tbIndexingServerHost.getText()); + UserPreferences.setIndexingServerPort(Integer.parseInt(tbIndexingServerPort.getText())); } /** @@ -282,6 +362,10 @@ public class MultiUserSettingsPanel extends javax.swing.JPanel { * @return true if it's okay, false otherwise. */ boolean valid() { + return validateDatabaseSettings() && validateSolrSettings(); + } + + private boolean validateDatabaseSettings() { boolean result = false; String text = ""; if (cbEnableMultiUser.isSelected()) { @@ -291,38 +375,85 @@ public class MultiUserSettingsPanel extends javax.swing.JPanel { || tbUsername.getText().isEmpty() || tbPassword.getPassword().length == 0) { // We don't even have everything filled out - result = false; - text = "Fill in all values"; + text = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.missingDatabaseSettingsError"); } else { int value = Integer.parseInt(tbPortNumber.getText()); - if (value < 0 || value > 65535) { // valid port numbers - result = false; /// port number is invalid - text = "Invalid port number"; + if (!isPortValid(value)) { + text = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.missingSolrSettingsError"); } else { result = true; } - } + } } catch (Exception ex) { - result = false; - text = "Invalid port number"; + text = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.invalidDatabaseSettings"); } - } else { + } + else{ result = true; } + lbOops.setText(text); return result; } + + private boolean validateSolrSettings() { + if (cbEnableMultiUser.isSelected()) { + // If both Solr server settings are empty that's ok but if + // either one is set you must set the other one. + if (tbIndexingServerHost.getText().isEmpty() && + tbIndexingServerPort.getText().isEmpty()) { + return true; + } + + if (tbIndexingServerHost.getText().isEmpty() || + tbIndexingServerPort.getText().isEmpty()) { + lbSolrMsg.setText(NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.missingSolrSettingsError")); + return false; + } + + try { + int port = Integer.parseInt(tbIndexingServerPort.getText()); + if (!isPortValid(port)) { + lbSolrMsg.setText(NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.invalidPortNumber")); + } + } + catch (NumberFormatException ex) { + lbSolrMsg.setText(NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.invalidPortNumber")); + return false; + } + } + + lbSolrMsg.setText(NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.lbSolrMsg.text")); + return true; + } + + /** + * Checks the given port number against the range of valid values. + * @param port + * @return + */ + private boolean isPortValid(int port) { + if (port < 1 || port > 65535) { + return false; + } + + return true; + } + // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JCheckBox cbEnableMultiUser; private javax.swing.JLabel lbDatabaseSettings; private javax.swing.JLabel lbMessagingSettings; private javax.swing.JLabel lbOops; + private javax.swing.JLabel lbSolrMsg; private javax.swing.JLabel lbSolrSettings; private javax.swing.JPanel pnDatabaseSettings; private javax.swing.JPanel pnMessagingSettings; private javax.swing.JPanel pnOverallPanel; private javax.swing.JPanel pnSolrSettings; private javax.swing.JTextField tbHostnameOrIp; + private javax.swing.JTextField tbIndexingServerHost; + private javax.swing.JTextField tbIndexingServerPort; private javax.swing.JPasswordField tbPassword; private javax.swing.JTextField tbPortNumber; private javax.swing.JTextField tbUsername; @@ -348,6 +479,6 @@ public class MultiUserSettingsPanel extends javax.swing.JPanel { public void removeUpdate(DocumentEvent e) { controller.changed(); - } + } } } From ad5a11386c3b6b1975c235ab0c2544c5d4006a15 Mon Sep 17 00:00:00 2001 From: Eamonn Saunders Date: Wed, 15 Apr 2015 20:31:38 -0400 Subject: [PATCH 9/9] Added Solr settings to Multi User options panel...again. --- .../autopsy/core/UserPreferences.java | 4 +- .../autopsy/corecomponents/Bundle.properties | 5 ++ .../MultiUserSettingsPanel.form | 26 ++------- .../MultiUserSettingsPanel.java | 54 +++++++++++++------ .../autopsy/keywordsearch/Server.java | 2 +- 5 files changed, 51 insertions(+), 40 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/core/UserPreferences.java b/Core/src/org/sleuthkit/autopsy/core/UserPreferences.java index 3042043d4a..92385abf1a 100755 --- a/Core/src/org/sleuthkit/autopsy/core/UserPreferences.java +++ b/Core/src/org/sleuthkit/autopsy/core/UserPreferences.java @@ -143,8 +143,8 @@ public final class UserPreferences { preferences.put(INDEXING_SERVER_HOST, hostName); } - public static int getIndexingServerPort() { - return preferences.getInt(INDEXING_SERVER_PORT, 0); + public static String getIndexingServerPort() { + return preferences.get(INDEXING_SERVER_PORT, ""); } public static void setIndexingServerPort(int port) { diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/Bundle.properties b/Core/src/org/sleuthkit/autopsy/corecomponents/Bundle.properties index c2a7d818e4..c5089ca52c 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/Bundle.properties @@ -165,6 +165,7 @@ MultiUserSettingsPanel.lbDatabaseSettings.text=Database Settings MultiUserSettingsPanel.validationErrMsg.incomplete=Fill in all values MultiUserSettingsPanel.validationErrMsg.invalidDatabasePort=Invalid database port number MultiUserSettingsPanel.validationErrMsg.invalidMessageServicePort=Invalid message service port number +MultiUserSettingsPanel.validationErrMsg.invalidIndexingServerPort=Invalid Solr server port number MultiUserSettingsPanel.validationErrMsg.invalidMessgeServiceURI=Message service host and/or port not valid MultiUserSettingsPanel.msgHostTextField.text= MultiUserSettingsPanel.msgHostTextField.toolTipText=Hostname or IP Address @@ -174,3 +175,7 @@ MultiUserSettingsPanel.msgPasswordField.toolTipText=Password MultiUserSettingsPanel.msgPasswordField.text= MultiUserSettingsPanel.msgPortTextField.toolTipText=Hostname or IP Address MultiUserSettingsPanel.msgPortTextField.text= +MultiUserSettingsPanel.tbIndexingServerHost.text=localhost +MultiUserSettingsPanel.tbIndexingServerPort.text=23232 +MultiUserSettingsPanel.tbIndexingServerHost.toolTipText=Hostname or IP Address +MultiUserSettingsPanel.tbIndexingServerPort.toolTipText=Port Number diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/MultiUserSettingsPanel.form b/Core/src/org/sleuthkit/autopsy/corecomponents/MultiUserSettingsPanel.form index fe25367070..723f7b999b 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/MultiUserSettingsPanel.form +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/MultiUserSettingsPanel.form @@ -16,7 +16,7 @@ - + @@ -55,7 +55,7 @@ - + @@ -199,8 +199,7 @@ - - + @@ -213,10 +212,7 @@ - - - - + @@ -269,20 +265,6 @@ - - - - - - - - - - - - - - diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/MultiUserSettingsPanel.java b/Core/src/org/sleuthkit/autopsy/corecomponents/MultiUserSettingsPanel.java index a656616449..b5bc13392f 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/MultiUserSettingsPanel.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/MultiUserSettingsPanel.java @@ -27,6 +27,7 @@ public final class MultiUserSettingsPanel extends javax.swing.JPanel { private static final String INCOMPLETE_SETTINGS_MSG = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.validationErrMsg.incomplete"); private static final String INVALID_DB_PORT_MSG = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.validationErrMsg.invalidDatabasePort"); private static final String INVALID_MESSAGE_SERVICE_PORT_MSG = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.validationErrMsg.invalidMessageServicePort"); + private static final String INVALID_INDEXING_SERVER_PORT_MSG = NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.validationErrMsg.invalidIndexingServerPort"); private final MultiUserSettingsPanelController controller; private final Collection textBoxes = new ArrayList<>(); private final TextBoxChangedListener textBoxChangedListener; @@ -51,6 +52,8 @@ public final class MultiUserSettingsPanel extends javax.swing.JPanel { textPrompts.add(new TextPrompt(PORT_PROMPT, msgPortTextField)); textPrompts.add(new TextPrompt(USER_NAME_PROMPT, msgUserNameTextField)); textPrompts.add(new TextPrompt(PASSWORD_PROMPT, msgPasswordField)); + textPrompts.add(new TextPrompt(HOST_NAME_OR_IP_PROMPT, tbIndexingServerHost)); + textPrompts.add(new TextPrompt(PORT_PROMPT, tbIndexingServerPort)); configureTextPrompts(textPrompts); /// Register for notifications when the text boxes get updated. @@ -63,6 +66,8 @@ public final class MultiUserSettingsPanel extends javax.swing.JPanel { textBoxes.add(msgPortTextField); textBoxes.add(msgUserNameTextField); textBoxes.add(msgPasswordField); + textBoxes.add(tbIndexingServerHost); + textBoxes.add(tbIndexingServerPort); addDocumentListeners(textBoxes, textBoxChangedListener); enableMultiUserComponents(textBoxes, cbEnableMultiUser.isSelected()); @@ -112,6 +117,8 @@ public final class MultiUserSettingsPanel extends javax.swing.JPanel { lbDatabaseSettings = new javax.swing.JLabel(); pnSolrSettings = new javax.swing.JPanel(); lbSolrSettings = new javax.swing.JLabel(); + tbIndexingServerHost = new javax.swing.JTextField(); + tbIndexingServerPort = new javax.swing.JTextField(); lbOops = new javax.swing.JLabel(); pnMessagingSettings = new javax.swing.JPanel(); lbMessagingSettings = new javax.swing.JLabel(); @@ -203,11 +210,6 @@ public final class MultiUserSettingsPanel extends javax.swing.JPanel { } }); - lbSolrMsg.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N - lbSolrMsg.setForeground(new java.awt.Color(255, 0, 0)); - org.openide.awt.Mnemonics.setLocalizedText(lbSolrMsg, org.openide.util.NbBundle.getMessage(MultiUserSettingsPanel.class, "MultiUserSettingsPanel.lbSolrMsg.text")); // NOI18N - lbSolrMsg.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM); - javax.swing.GroupLayout pnSolrSettingsLayout = new javax.swing.GroupLayout(pnSolrSettings); pnSolrSettings.setLayout(pnSolrSettingsLayout); pnSolrSettingsLayout.setHorizontalGroup( @@ -217,8 +219,7 @@ public final class MultiUserSettingsPanel extends javax.swing.JPanel { .addGroup(pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pnSolrSettingsLayout.createSequentialGroup() .addComponent(lbSolrSettings) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(lbSolrMsg, javax.swing.GroupLayout.PREFERRED_SIZE, 320, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(0, 0, Short.MAX_VALUE)) .addComponent(tbIndexingServerHost, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(tbIndexingServerPort, javax.swing.GroupLayout.Alignment.TRAILING)) .addContainerGap()) @@ -227,9 +228,7 @@ public final class MultiUserSettingsPanel extends javax.swing.JPanel { pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(pnSolrSettingsLayout.createSequentialGroup() .addContainerGap() - .addGroup(pnSolrSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(lbSolrSettings) - .addComponent(lbSolrMsg, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addComponent(lbSolrSettings) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(tbIndexingServerHost, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) @@ -325,7 +324,7 @@ public final class MultiUserSettingsPanel extends javax.swing.JPanel { .addGroup(pnOverallPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(cbEnableMultiUser) .addComponent(lbOops)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 6, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(pnDatabaseSettings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(pnSolrSettings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) @@ -338,7 +337,7 @@ public final class MultiUserSettingsPanel extends javax.swing.JPanel { this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(pnOverallPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 511, Short.MAX_VALUE) + .addComponent(pnOverallPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -375,7 +374,6 @@ public final class MultiUserSettingsPanel extends javax.swing.JPanel { private void tbIndexingServerPortActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tbIndexingServerPortActionPerformed // TODO add your handling code here: - tbIndexingServerPort.dispatchEvent(evt); }//GEN-LAST:event_tbIndexingServerPortActionPerformed void load() { @@ -391,6 +389,15 @@ public final class MultiUserSettingsPanel extends javax.swing.JPanel { msgUserNameTextField.setText(msgServiceInfo.getUserName()); msgPasswordField.setText(msgServiceInfo.getPassword()); + String indexingServerHost = UserPreferences.getIndexingServerHost(); + if (!indexingServerHost.isEmpty()) { + tbIndexingServerHost.setText(indexingServerHost); + } + String indexingServerPort = UserPreferences.getIndexingServerPort(); + if (portNumberIsValid(indexingServerPort)) { + tbIndexingServerPort.setText(indexingServerPort); + } + if (dbInfo.getDbType() == DbType.UNKNOWN) { cbEnableMultiUser.setSelected(false); } else { @@ -434,6 +441,10 @@ public final class MultiUserSettingsPanel extends javax.swing.JPanel { msgHostTextField.getText(), msgPortTextField.getText()); UserPreferences.setMessageServiceConnectionInfo(msgServiceInfo); + + UserPreferences.setIndexingServerHost(tbIndexingServerHost.getText()); + UserPreferences.setIndexingServerPort(Integer.parseInt(tbIndexingServerPort.getText())); + } /** @@ -444,7 +455,7 @@ public final class MultiUserSettingsPanel extends javax.swing.JPanel { boolean valid() { lbOops.setText(""); if (cbEnableMultiUser.isSelected()) { - return settingsAreComplete() && databaseSettingsAreValid() && messageServiceSettingsAreValid(); + return settingsAreComplete() && databaseSettingsAreValid() && indexingServerSettingsAreValid() && messageServiceSettingsAreValid(); } else { return true; } @@ -497,6 +508,20 @@ public final class MultiUserSettingsPanel extends javax.swing.JPanel { return true; } + /** + * Tests whether or not the indexing server settings are valid. + * + * @return True or false. + */ + boolean indexingServerSettingsAreValid() { + if (!portNumberIsValid(tbIndexingServerPort.getText())) { + lbOops.setText(INVALID_INDEXING_SERVER_PORT_MSG); + return false; + } + + return true; + } + /** * Determines whether or not a port number is within the range of valid port * numbers. @@ -521,7 +546,6 @@ public final class MultiUserSettingsPanel extends javax.swing.JPanel { private javax.swing.JLabel lbDatabaseSettings; private javax.swing.JLabel lbMessagingSettings; private javax.swing.JLabel lbOops; - private javax.swing.JLabel lbSolrMsg; private javax.swing.JLabel lbSolrSettings; private javax.swing.JTextField msgHostTextField; private javax.swing.JPasswordField msgPasswordField; diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Server.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Server.java index 2fbb45f79c..ac80816888 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Server.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Server.java @@ -1001,7 +1001,7 @@ public class Server { private HttpSolrServer connectToRemoteSolrServer() { String host = UserPreferences.getIndexingServerHost(); - String port = Integer.toString(UserPreferences.getIndexingServerPort()); + String port = UserPreferences.getIndexingServerPort(); return new HttpSolrServer("http://" + host + ":" + port + "/solr"); }