diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeNormalizer.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeNormalizer.java index 11a8e2249b..651c07f74c 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeNormalizer.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeNormalizer.java @@ -52,27 +52,29 @@ final public class CorrelationAttributeNormalizer { throw new CorrelationAttributeNormalizationException("Data was null."); } + String trimmedData = data.trim(); + switch(attributeType.getId()){ case CorrelationAttributeInstance.FILES_TYPE_ID: - return normalizeMd5(data); + return normalizeMd5(trimmedData); case CorrelationAttributeInstance.DOMAIN_TYPE_ID: - return normalizeDomain(data); + return normalizeDomain(trimmedData); case CorrelationAttributeInstance.EMAIL_TYPE_ID: - return normalizeEmail(data); + return normalizeEmail(trimmedData); case CorrelationAttributeInstance.PHONE_TYPE_ID: - return normalizePhone(data); + return normalizePhone(trimmedData); case CorrelationAttributeInstance.USBID_TYPE_ID: - return normalizeUsbId(data); + return normalizeUsbId(trimmedData); case CorrelationAttributeInstance.SSID_TYPE_ID: - return data; + return trimmedData; case CorrelationAttributeInstance.MAC_TYPE_ID: - return data; + return trimmedData; case CorrelationAttributeInstance.IMEI_TYPE_ID: - return data; + return trimmedData; case CorrelationAttributeInstance.IMSI_TYPE_ID: - return data; + return trimmedData; case CorrelationAttributeInstance.ICCID_TYPE_ID: - return data; + return trimmedData; default: final String errorMessage = String.format( "Validator function not found for attribute type: %s", diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/HashsetHits.java b/Core/src/org/sleuthkit/autopsy/datamodel/HashsetHits.java index 8ff6645562..3262087487 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/HashsetHits.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/HashsetHits.java @@ -411,11 +411,15 @@ public class HashsetHits implements AutopsyVisitableItem { BlackboardArtifact art = skCase.getBlackboardArtifact(id); artifactHits.put(id, art); } - list.add(id); } catch (TskException ex) { logger.log(Level.SEVERE, "TSK Exception occurred", ex); //NON-NLS } }); + + // Adding all keys at once is more efficient than adding one at a + // time because Netbeans triggers internal processing each time an + // element is added to the list. + list.addAll(artifactHits.keySet()); return true; } diff --git a/Core/src/org/sleuthkit/autopsy/othercasessearch/Bundle.properties b/Core/src/org/sleuthkit/autopsy/othercasessearch/Bundle.properties index 17ea13ee0b..95951884a2 100755 --- a/Core/src/org/sleuthkit/autopsy/othercasessearch/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/othercasessearch/Bundle.properties @@ -4,7 +4,7 @@ OtherCasesSearchDialog.searchButton.AccessibleContext.accessibleName=Search OtherCasesSearchDialog.searchButton.text=Search OtherCasesSearchDialog.correlationValueTextField.text= OtherCasesSearchDialog.correlationValueLabel.text=Correlation Property Value: -OtherCasesSearchDialog.descriptionLabel.text=Search data in the Central Repository from other cases. +OtherCasesSearchDialog.descriptionLabel.text=Search the Central Repository for correlation properties with a specified value. The search is case insensitive. OtherCasesSearchDialog.errorLabel.text=\ OtherCasesSearchDialog.correlationTypeLabel.text=Correlation Property Type: OtherCasesSearchDialog.casesLabel.text=\ diff --git a/Core/src/org/sleuthkit/autopsy/othercasessearch/OtherCasesSearchDialog.form b/Core/src/org/sleuthkit/autopsy/othercasessearch/OtherCasesSearchDialog.form index 00eb862b4a..cd033f994d 100755 --- a/Core/src/org/sleuthkit/autopsy/othercasessearch/OtherCasesSearchDialog.form +++ b/Core/src/org/sleuthkit/autopsy/othercasessearch/OtherCasesSearchDialog.form @@ -24,18 +24,10 @@ - + - - - - - - - - - + @@ -43,11 +35,16 @@ - + + + + + + @@ -57,25 +54,25 @@ - + - + - + - + - + @@ -149,7 +146,7 @@ - + diff --git a/Core/src/org/sleuthkit/autopsy/othercasessearch/OtherCasesSearchDialog.java b/Core/src/org/sleuthkit/autopsy/othercasessearch/OtherCasesSearchDialog.java index 51e21631d2..6fe9ec8ce3 100755 --- a/Core/src/org/sleuthkit/autopsy/othercasessearch/OtherCasesSearchDialog.java +++ b/Core/src/org/sleuthkit/autopsy/othercasessearch/OtherCasesSearchDialog.java @@ -26,19 +26,17 @@ import java.util.Collection; import java.util.List; import java.util.concurrent.ExecutionException; import java.util.logging.Level; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import javax.swing.JFrame; import javax.swing.SwingWorker; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import org.openide.nodes.Node; -import org.openide.util.Exceptions; import org.openide.util.NbBundle.Messages; import org.openide.windows.TopComponent; import org.openide.windows.WindowManager; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeNormalizationException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeNormalizer; import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; import org.sleuthkit.autopsy.corecomponentinterfaces.DataResultViewer; @@ -55,6 +53,10 @@ import org.sleuthkit.autopsy.datamodel.EmptyNode; "OtherCasesSearchDialog.resultsDescription.text=Other Cases Search", "OtherCasesSearchDialog.emptyNode.text=No results found.", "OtherCasesSearchDialog.validation.invalidHash=The supplied value is not a valid MD5 hash.", + "OtherCasesSearchDialog.validation.invalidEmail=The supplied value is not a valid e-mail address.", + "OtherCasesSearchDialog.validation.invalidDomain=The supplied value is not a valid domain.", + "OtherCasesSearchDialog.validation.invalidPhone=The supplied value is not a valid phone number.", + "OtherCasesSearchDialog.validation.genericMessage=The supplied value is not valid.", "# {0} - number of cases", "OtherCasesSearchDialog.caseLabel.text=The current Central Repository contains {0} case(s)." }) @@ -67,9 +69,8 @@ final class OtherCasesSearchDialog extends javax.swing.JDialog { private static final Logger logger = Logger.getLogger(OtherCasesSearchDialog.class.getName()); private static final long serialVersionUID = 1L; - private static final String FILES_CORRELATION_TYPE = "Files"; - private final List correlationTypes; + private CorrelationAttributeInstance.Type selectedCorrelationType; private TextPrompt correlationValueTextFieldPrompt; /** @@ -84,23 +85,19 @@ final class OtherCasesSearchDialog extends javax.swing.JDialog { /** * Perform the other cases search. + * + * @param type The correlation type. + * @param value The value to be matched. */ - private void search() { + private void search(CorrelationAttributeInstance.Type type, String value) { new SwingWorker, Void>() { @Override protected List doInBackground() { - List correlationTypes; List correlationInstances = new ArrayList<>(); try { - correlationTypes = EamDb.getInstance().getDefinedCorrelationTypes(); - for (CorrelationAttributeInstance.Type type : correlationTypes) { - if (type.getDisplayName().equals((String) correlationTypeComboBox.getSelectedItem())) { - correlationInstances = EamDb.getInstance().getArtifactInstancesByTypeValue(type, correlationValueTextField.getText()); - break; - } - } + correlationInstances = EamDb.getInstance().getArtifactInstancesByTypeValue(type, value); } catch (EamDbException ex) { logger.log(Level.SEVERE, "Unable to connect to the Central Repository database.", ex); } catch (CorrelationAttributeNormalizationException ex) { @@ -123,9 +120,7 @@ final class OtherCasesSearchDialog extends javax.swing.JDialog { TableFilterNode tableFilterNode = new TableFilterNode(searchNode, true, searchNode.getName()); String resultsText = String.format("%s (%s; \"%s\")", - Bundle.OtherCasesSearchDialog_resultsTitle_text(), - (String) correlationTypeComboBox.getSelectedItem(), - correlationValueTextField.getText()); + Bundle.OtherCasesSearchDialog_resultsTitle_text(), type.getDisplayName(), value); final TopComponent searchResultWin; if (correlationInstances.isEmpty()) { Node emptyNode = new TableFilterNode( @@ -183,7 +178,7 @@ final class OtherCasesSearchDialog extends javax.swing.JDialog { org.openide.awt.Mnemonics.setLocalizedText(descriptionLabel, org.openide.util.NbBundle.getMessage(OtherCasesSearchDialog.class, "OtherCasesSearchDialog.descriptionLabel.text")); // NOI18N - casesLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + casesLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); org.openide.awt.Mnemonics.setLocalizedText(casesLabel, org.openide.util.NbBundle.getMessage(OtherCasesSearchDialog.class, "OtherCasesSearchDialog.casesLabel.text")); // NOI18N javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); @@ -193,44 +188,42 @@ final class OtherCasesSearchDialog extends javax.swing.JDialog { .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addComponent(casesLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGap(18, 18, 18) - .addComponent(searchButton)) - .addGroup(layout.createSequentialGroup() - .addComponent(descriptionLabel) - .addGap(0, 0, Short.MAX_VALUE)) + .addComponent(descriptionLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 430, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(correlationValueLabel) .addComponent(correlationTypeLabel)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(correlationTypeComboBox, 0, 289, Short.MAX_VALUE) + .addComponent(correlationTypeComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(correlationValueTextField) - .addComponent(errorLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) + .addComponent(errorLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addComponent(casesLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGap(18, 18, 18) + .addComponent(searchButton))) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap() - .addComponent(descriptionLabel) + .addComponent(descriptionLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(correlationTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(correlationTypeLabel)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGap(15, 15, 15) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(correlationValueLabel) - .addComponent(correlationValueTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(correlationValueTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(correlationValueLabel)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(errorLabel) - .addGap(11, 11, 11) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 20, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(searchButton) .addComponent(casesLabel)) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap()) ); searchButton.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(OtherCasesSearchDialog.class, "OtherCasesSearchDialog.searchButton.AccessibleContext.accessibleName")); // NOI18N @@ -240,23 +233,57 @@ final class OtherCasesSearchDialog extends javax.swing.JDialog { }// //GEN-END:initComponents private void searchButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchButtonActionPerformed - if (validateInputs()) { - /* - * Just in case, we'll lock down the type and value components to - * avoid the possibly of a race condition. - */ - correlationTypeComboBox.setEnabled(false); - correlationValueTextField.setEnabled(false); - - search(); + CorrelationAttributeInstance.Type correlationType = selectedCorrelationType; + String correlationValue = correlationValueTextField.getText().trim(); + + if (validateInputs(correlationType, correlationValue)) { + search(correlationType, correlationValue); dispose(); } else { + String validationMessage; + switch (correlationType.getId()) { + case CorrelationAttributeInstance.FILES_TYPE_ID: + validationMessage = Bundle.OtherCasesSearchDialog_validation_invalidHash(); + break; + case CorrelationAttributeInstance.DOMAIN_TYPE_ID: + validationMessage = Bundle.OtherCasesSearchDialog_validation_invalidDomain(); + break; + case CorrelationAttributeInstance.EMAIL_TYPE_ID: + validationMessage = Bundle.OtherCasesSearchDialog_validation_invalidEmail(); + break; + case CorrelationAttributeInstance.PHONE_TYPE_ID: + validationMessage = Bundle.OtherCasesSearchDialog_validation_invalidPhone(); + break; + default: + validationMessage = Bundle.OtherCasesSearchDialog_validation_genericMessage(); + break; + + } + errorLabel.setText(validationMessage); searchButton.setEnabled(false); - errorLabel.setText(Bundle.OtherCasesSearchDialog_validation_invalidHash()); correlationValueTextField.grabFocus(); } }//GEN-LAST:event_searchButtonActionPerformed - + + /** + * Validate the supplied input. + * + * @param type The correlation type. + * @param value The value to be validated. + * + * @return True if the input is valid for the given type; otherwise false. + */ + private boolean validateInputs(CorrelationAttributeInstance.Type type, String value) { + try { + CorrelationAttributeNormalizer.normalize(type, value); + } catch (CorrelationAttributeNormalizationException ex) { + // No need to log this. + return false; + } + + return true; + } + /** * Further customize the components beyond the standard initialization. */ @@ -277,20 +304,21 @@ final class OtherCasesSearchDialog extends javax.swing.JDialog { } for (CorrelationAttributeInstance.Type type : correlationTypes) { - // We only support the "Files" type for now. - if (type.getDisplayName().equals(FILES_CORRELATION_TYPE)) { - correlationTypeComboBox.addItem(type.getDisplayName()); - } + correlationTypeComboBox.addItem(type.getDisplayName()); } correlationTypeComboBox.setSelectedIndex(0); correlationTypeComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { + updateSelectedType(); + updateCorrelationValueTextFieldPrompt(); updateSearchButton(); } }); + updateSelectedType(); + /* * Create listener for text input. */ @@ -315,7 +343,12 @@ final class OtherCasesSearchDialog extends javax.swing.JDialog { } @Messages({ - "OtherCasesSearchDialog.correlationValueTextField.filesExample=Example: \"f0e1d2c3b4a5968778695a4b3c2d1e0f\"" + "OtherCasesSearchDialog.correlationValueTextField.filesExample=Example: \"f0e1d2c3b4a5968778695a4b3c2d1e0f\"", + "OtherCasesSearchDialog.correlationValueTextField.domainExample=Example: \"domain.com\"", + "OtherCasesSearchDialog.correlationValueTextField.emailExample=Example: \"user@host.com\"", + "OtherCasesSearchDialog.correlationValueTextField.phoneExample=Example: \"(800)123-4567\"", + "OtherCasesSearchDialog.correlationValueTextField.usbExample=Example: \"4&1234567&0\"", + "OtherCasesSearchDialog.correlationValueTextField.ssidExample=Example: \"WirelessNetwork-5G\"" }) /** * Update the text prompt of the name text field based on the input type @@ -325,7 +358,30 @@ final class OtherCasesSearchDialog extends javax.swing.JDialog { /** * Add text prompt to the text field. */ - String text = Bundle.OtherCasesSearchDialog_correlationValueTextField_filesExample(); + String text; + switch(selectedCorrelationType.getId()) { + case CorrelationAttributeInstance.FILES_TYPE_ID: + text = Bundle.OtherCasesSearchDialog_correlationValueTextField_filesExample(); + break; + case CorrelationAttributeInstance.DOMAIN_TYPE_ID: + text = Bundle.OtherCasesSearchDialog_correlationValueTextField_domainExample(); + break; + case CorrelationAttributeInstance.EMAIL_TYPE_ID: + text = Bundle.OtherCasesSearchDialog_correlationValueTextField_emailExample(); + break; + case CorrelationAttributeInstance.PHONE_TYPE_ID: + text = Bundle.OtherCasesSearchDialog_correlationValueTextField_phoneExample(); + break; + case CorrelationAttributeInstance.USBID_TYPE_ID: + text = Bundle.OtherCasesSearchDialog_correlationValueTextField_usbExample(); + break; + case CorrelationAttributeInstance.SSID_TYPE_ID: + text = Bundle.OtherCasesSearchDialog_correlationValueTextField_ssidExample(); + break; + default: + text = ""; + break; + } correlationValueTextFieldPrompt = new TextPrompt(text, correlationValueTextField); /** @@ -338,6 +394,19 @@ final class OtherCasesSearchDialog extends javax.swing.JDialog { repaint(); } + /** + * Update the 'selectedCorrelationType' value to match the selected type + * from the combo-box. + */ + private void updateSelectedType() { + for (CorrelationAttributeInstance.Type type : correlationTypes) { + if (type.getDisplayName().equals((String) correlationTypeComboBox.getSelectedItem())) { + selectedCorrelationType = type; + break; + } + } + } + /** * Enable or disable the Search button depending on whether or not text has * been provided for the correlation property value. @@ -345,20 +414,6 @@ final class OtherCasesSearchDialog extends javax.swing.JDialog { private void updateSearchButton() { searchButton.setEnabled(correlationValueTextField.getText().isEmpty() == false); } - - /** - * Validate the value input. - * - * @return True if the input is valid for the selected type; otherwise false. - */ - private boolean validateInputs() { - Pattern md5Pattern = Pattern.compile("^[a-fA-F0-9]{32}$"); // NON-NLS - Matcher matcher = md5Pattern.matcher(correlationValueTextField.getText().trim()); - if (matcher.find()) { - return true; - } - return false; - } /** * Display the Search Other Cases dialog. @@ -378,4 +433,4 @@ final class OtherCasesSearchDialog extends javax.swing.JDialog { private javax.swing.JLabel errorLabel; private javax.swing.JButton searchButton; // End of variables declaration//GEN-END:variables -} +} \ No newline at end of file diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestManager.java b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestManager.java index e8500e6ba2..d2a9c40dc0 100644 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestManager.java +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestManager.java @@ -3106,27 +3106,6 @@ final class AutoIngestManager extends Observable implements PropertyChangeListen updateCoordinationServiceManifestNode(currentJob); eventPublisher.publishRemotely(new AutoIngestJobStatusEvent(currentJob)); } - - if (AutoIngestUserPreferences.getStatusDatabaseLoggingEnabled()) { - String message; - boolean isError = false; - if (getErrorState().equals(ErrorState.NONE)) { - if (currentJob != null) { - message = "Processing " + currentJob.getManifest().getDataSourceFileName() - + " for case " + currentJob.getManifest().getCaseName(); - } else { - message = "Paused or waiting for next case"; - } - } else { - message = getErrorState().toString(); - isError = true; - } - try { - StatusDatabaseLogger.logToStatusDatabase(message, isError); - } catch (SQLException | UserPreferencesException ex) { - sysLogger.log(Level.WARNING, "Failed to update status database", ex); - } - } } // check whether any remote nodes have timed out diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/StatusDatabaseLogger.java b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/StatusDatabaseLogger.java deleted file mode 100644 index f8921e112d..0000000000 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/StatusDatabaseLogger.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Autopsy Forensic Browser - * - * Copyright 2015-2018 Basis Technology Corp. - * Contact: carrier sleuthkit org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.sleuthkit.autopsy.experimental.autoingest; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.logging.Level; -import org.sleuthkit.autopsy.core.UserPreferences; -import org.sleuthkit.autopsy.core.UserPreferencesException; -import org.sleuthkit.autopsy.coreutils.Logger; -import org.sleuthkit.autopsy.coreutils.NetworkUtils; -import org.sleuthkit.autopsy.experimental.configuration.AutoIngestUserPreferences; - -/** - * Write auto-ingest status updates to a database. - */ -public class StatusDatabaseLogger { - - /** - * Log the current status to the database using the database parameters - * saved in AutoIngestUserPreferences. - * - * @param message Current status message - * @param isError true if we're in an error state, false otherwise - * - * @throws SQLException If a SQL data access error occurs. - * @throws UserPreferencesException If there's an issue reading the user - * preferences. - */ - public static void logToStatusDatabase(String message, boolean isError) throws SQLException, UserPreferencesException { - - try { - Class.forName("org.postgresql.Driver"); - } catch (ClassNotFoundException ex) { - Logger sysLogger = AutoIngestSystemLogger.getLogger(); - sysLogger.log(Level.WARNING, "Error loading postgresql driver", ex); - } - try (Connection connection = DriverManager.getConnection("jdbc:postgresql://" - + AutoIngestUserPreferences.getLoggingDatabaseHostnameOrIP() - + ":" + AutoIngestUserPreferences.getLoggingPort() - + "/" + AutoIngestUserPreferences.getLoggingDatabaseName(), - AutoIngestUserPreferences.getLoggingUsername(), - AutoIngestUserPreferences.getLoggingPassword()); - Statement statement = connection.createStatement();) { - - logToStatusDatabase(statement, message, isError); - } - } - - /** - * Log the current status to the database using an already configured - * Statement. - * - * @param statement SQL statement (must have already been created) - * @param message Current status message - * @param isError true if we're in an error state, false otherwise - * - * @throws SQLException - */ - public static void logToStatusDatabase(Statement statement, String message, boolean isError) throws SQLException { - if ((statement == null) || statement.isClosed()) { - throw new SQLException("SQL Statement is null/closed"); - } - - int status; - if (isError) { - status = 1; - } else { - status = 0; - } - String timestamp = new java.text.SimpleDate‌​Format("yyyy-MM-dd HH:mm:ss").format( ne‌​w java.util.Date()); - - String checkForPreviousEntry = "SELECT * FROM statusUpdates WHERE tool='" + UserPreferences.getAppName() + "' AND " - + "node='" + NetworkUtils.getLocalHostName() + "'"; - - ResultSet resultSet = statement.executeQuery(checkForPreviousEntry); - String logMessage; - if (resultSet.next()) { - logMessage = "UPDATE statusUpdates SET reportTime='" + timestamp - + "', message='" + message + "', status=" + status - + " WHERE tool='" + UserPreferences.getAppName() + "' AND node='" + NetworkUtils.getLocalHostName() + "'"; - } else { - logMessage = "INSERT INTO statusUpdates (tool, node, reportTime, message, status) " - + "VALUES ('" + UserPreferences.getAppName() - + "', '" + NetworkUtils.getLocalHostName() - + "', '" - + timestamp + "', '" + message + "', '" + status + "')"; - - } - statement.execute(logMessage); - } - -} diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/configuration/AutoIngestSettingsPanel.form b/Experimental/src/org/sleuthkit/autopsy/experimental/configuration/AutoIngestSettingsPanel.form index ffc1b8820b..9bb5abd0e1 100644 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/configuration/AutoIngestSettingsPanel.form +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/configuration/AutoIngestSettingsPanel.form @@ -85,8 +85,6 @@ - - @@ -162,7 +160,6 @@ - @@ -248,16 +245,6 @@ - - - - - - - - - - diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/configuration/AutoIngestSettingsPanel.java b/Experimental/src/org/sleuthkit/autopsy/experimental/configuration/AutoIngestSettingsPanel.java index d88ece8ddd..7e4608ae2e 100644 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/configuration/AutoIngestSettingsPanel.java +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/configuration/AutoIngestSettingsPanel.java @@ -565,7 +565,6 @@ public class AutoIngestSettingsPanel extends javax.swing.JPanel { bnEditIngestSettings.setEnabled(mode == OptionsUiMode.AIM && !nonMasterSharedConfig); bnAdvancedSettings.setEnabled(mode == OptionsUiMode.AIM && !nonMasterSharedConfig); - bnLogging.setEnabled(mode == OptionsUiMode.AIM && !nonMasterSharedConfig); sharedConfigCheckbox.setEnabled(mode == OptionsUiMode.AIM); masterNodeCheckBox.setEnabled(mode == OptionsUiMode.AIM && sharedConfigCheckbox.isSelected()); bnFileExport.setEnabled(mode == OptionsUiMode.AIM); @@ -603,7 +602,6 @@ public class AutoIngestSettingsPanel extends javax.swing.JPanel { bnEditIngestSettings = new javax.swing.JButton(); bnAdvancedSettings = new javax.swing.JButton(); bnFileExport = new javax.swing.JButton(); - bnLogging = new javax.swing.JButton(); browseOutputFolderButton = new javax.swing.JButton(); browseInputFolderButton = new javax.swing.JButton(); inputPathTextField = new javax.swing.JTextField(); @@ -658,13 +656,6 @@ public class AutoIngestSettingsPanel extends javax.swing.JPanel { } }); - org.openide.awt.Mnemonics.setLocalizedText(bnLogging, org.openide.util.NbBundle.getMessage(AutoIngestSettingsPanel.class, "AutoIngestSettingsPanel.bnLogging.text")); // NOI18N - bnLogging.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - bnLoggingActionPerformed(evt); - } - }); - org.openide.awt.Mnemonics.setLocalizedText(browseOutputFolderButton, org.openide.util.NbBundle.getMessage(AutoIngestSettingsPanel.class, "AutoIngestSettingsPanel.browseOutputFolderButton.text")); // NOI18N browseOutputFolderButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { @@ -805,9 +796,7 @@ public class AutoIngestSettingsPanel extends javax.swing.JPanel { .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(bnAdvancedSettings, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(bnFileExport, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(bnLogging, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(bnFileExport, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(nodePanelLayout.createSequentialGroup() .addComponent(jLabelSelectOutputFolder) .addGap(18, 18, 18) @@ -863,8 +852,7 @@ public class AutoIngestSettingsPanel extends javax.swing.JPanel { .addGroup(nodePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(bnEditIngestSettings) .addComponent(bnFileExport) - .addComponent(bnAdvancedSettings) - .addComponent(bnLogging)) + .addComponent(bnAdvancedSettings)) .addGap(18, 18, 18) .addGroup(nodePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(sharedConfigCheckbox, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE) @@ -1042,23 +1030,6 @@ public class AutoIngestSettingsPanel extends javax.swing.JPanel { } }//GEN-LAST:event_browseInputFolderButtonActionPerformed - private void bnLoggingActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnLoggingActionPerformed - JDialog jDialog = new JDialog(); - NodeStatusLogPanel loggingPanel = new NodeStatusLogPanel(jDialog); - - JScrollPane jScrollPane = new JScrollPane(loggingPanel); - jScrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); - jScrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); - jScrollPane.setMinimumSize(new Dimension(100, 100)); - jDialog.add(jScrollPane); - jDialog.setTitle(NbBundle.getMessage(AutoIngestSettingsPanel.class, "AutoIngestSettingsPanel.NodeStatusLogging.text")); - jDialog.setIconImage(ImageUtilities.loadImage("org/sleuthkit/autopsy/experimental/images/frame32.gif")); - jDialog.setModalityType(java.awt.Dialog.ModalityType.APPLICATION_MODAL); - jDialog.pack(); - jDialog.setLocationRelativeTo(this); - jDialog.setVisible(true); - }//GEN-LAST:event_bnLoggingActionPerformed - private void bnFileExportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnFileExportActionPerformed JDialog jDialog = new JDialog(); FileExporterSettingsPanel fileExporterSettingsPanel = new FileExporterSettingsPanel(jDialog); @@ -1210,7 +1181,6 @@ public class AutoIngestSettingsPanel extends javax.swing.JPanel { bnAdvancedSettings.setEnabled(enabled); bnEditIngestSettings.setEnabled(enabled); bnFileExport.setEnabled(enabled); - bnLogging.setEnabled(enabled); browseInputFolderButton.setEnabled(enabled); browseOutputFolderButton.setEnabled(enabled); browseSharedSettingsButton.setEnabled(sharedConfigCheckbox.isSelected() && autoIngestModeRadioButton.isSelected()); @@ -1228,7 +1198,6 @@ public class AutoIngestSettingsPanel extends javax.swing.JPanel { private javax.swing.JButton bnAdvancedSettings; private javax.swing.JButton bnEditIngestSettings; private javax.swing.JButton bnFileExport; - private javax.swing.JButton bnLogging; private javax.swing.JButton browseInputFolderButton; private javax.swing.JButton browseOutputFolderButton; private javax.swing.JButton browseSharedSettingsButton; diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/configuration/AutoIngestUserPreferences.java b/Experimental/src/org/sleuthkit/autopsy/experimental/configuration/AutoIngestUserPreferences.java index 9696947535..72a06bbdab 100644 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/configuration/AutoIngestUserPreferences.java +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/configuration/AutoIngestUserPreferences.java @@ -281,125 +281,6 @@ public final class AutoIngestUserPreferences { ModuleSettings.setConfigSetting(UserPreferences.SETTINGS_PROPERTIES, MAX_CONCURRENT_NODES_FOR_ONE_CASE, Integer.toString(numberOfNodes)); } - /** - * Get status database logging checkbox state for automated ingest mode from - * persistent storage. - * - * @return Boolean true if database logging is enabled. - */ - public static Boolean getStatusDatabaseLoggingEnabled() { - return Boolean.parseBoolean(getPreferenceValue(STATUS_DATABASE_LOGGING_ENABLED)); - } - - /** - * Save status database logging checkbox state for automated ingest mode to - * persistent storage. - * - * @param databaseLoggingEnabled true = use database logging in auto-ingest - * mode - */ - public static void setStatusDatabaseLoggingEnabled(boolean databaseLoggingEnabled) { - ModuleSettings.setConfigSetting(UserPreferences.SETTINGS_PROPERTIES, STATUS_DATABASE_LOGGING_ENABLED, Boolean.toString(databaseLoggingEnabled)); - } - - /** - * Get the logging database hostname from persistent storage. - * - * @return Logging database hostname or IP - */ - public static String getLoggingDatabaseHostnameOrIP() { - return getPreferenceValue(LOGGING_DB_HOSTNAME_OR_IP); - } - - /** - * Save the logging database hostname to persistent storage. - * - * @param hostname Logging database hostname or IP - */ - public static void setLoggingDatabaseHostnameOrIP(String hostname) { - ModuleSettings.setConfigSetting(UserPreferences.SETTINGS_PROPERTIES, LOGGING_DB_HOSTNAME_OR_IP, hostname); - } - - /** - * Get the logging database port from persistent storage. - * - * @return logging database port - */ - public static String getLoggingPort() { - return getPreferenceValue(LOGGING_PORT); - } - - /** - * Save the logging database port to persistent storage. - * - * @param port Logging database port - */ - public static void setLoggingPort(String port) { - ModuleSettings.setConfigSetting(UserPreferences.SETTINGS_PROPERTIES, LOGGING_PORT, port); - } - - /** - * Get the logging database username from persistent storage. - * - * @return logging database username - */ - public static String getLoggingUsername() { - return getPreferenceValue(LOGGING_USERNAME); - } - - /** - * Save the logging database username to persistent storage. - * - * @param username Logging database username - */ - public static void setLoggingUsername(String username) { - ModuleSettings.setConfigSetting(UserPreferences.SETTINGS_PROPERTIES, LOGGING_USERNAME, username); - } - - /** - * Get the logging database password from persistent storage. - * - * @return logging database password - * - * @throws org.sleuthkit.autopsy.core.UserPreferencesException - */ - public static String getLoggingPassword() throws UserPreferencesException { - return getPreferenceValue(LOGGING_PASSWORD); - } - - /** - * Save the logging database password to persistent storage. - * - * @param password Logging database password - * - * @throws org.sleuthkit.autopsy.core.UserPreferencesException - */ - public static void setLoggingPassword(String password) throws UserPreferencesException { - try { - ModuleSettings.setConfigSetting(UserPreferences.SETTINGS_PROPERTIES, LOGGING_PASSWORD, TextConverter.convertTextToHexText(password)); - } catch (TextConverterException ex) { - throw new UserPreferencesException("Error encrypting password", ex); - } - } - - /** - * Get the logging database name from persistent storage. - * - * @return logging database name - */ - public static String getLoggingDatabaseName() { - return getPreferenceValue(LOGGING_DATABASE_NAME); - } - - /** - * Save the logging database name to persistent storage. - * - * @param name Logging database name - */ - public static void setLoggingDatabaseName(String name) { - ModuleSettings.setConfigSetting(UserPreferences.SETTINGS_PROPERTIES, LOGGING_DATABASE_NAME, name); - } - /** * Get the configured time for input scan interval * diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/configuration/Bundle.properties b/Experimental/src/org/sleuthkit/autopsy/experimental/configuration/Bundle.properties index 97a82988f2..be60569400 100644 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/configuration/Bundle.properties +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/configuration/Bundle.properties @@ -127,7 +127,6 @@ AutoIngestSettingsPanel.browseInputFolderButton.text=Browse AutoIngestSettingsPanel.inputPathTextField.toolTipText=Input folder for automated processing, i.e., the location where input case folders will be created for ingest by automated processing mode AutoIngestSettingsPanel.inputPathTextField.text= AutoIngestSettingsPanel.jLabelSelectInputFolder.text=Select shared images folder: -AutoIngestSettingsPanel.bnLogging.text=Node Status Logging AutoIngestSettingsPanel.bnFileExport.text=File Export Settings AutoIngestSettingsPanel.bnAdvancedSettings.text=Advanced Settings AutoIngestSettingsPanel.bnEditIngestSettings.toolTipText=Ingest job settings for the automated processing mode context. diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/configuration/NodeStatusLogPanel.form b/Experimental/src/org/sleuthkit/autopsy/experimental/configuration/NodeStatusLogPanel.form deleted file mode 100644 index 128044d113..0000000000 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/configuration/NodeStatusLogPanel.form +++ /dev/null @@ -1,277 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/configuration/NodeStatusLogPanel.java b/Experimental/src/org/sleuthkit/autopsy/experimental/configuration/NodeStatusLogPanel.java deleted file mode 100644 index 88163b67df..0000000000 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/configuration/NodeStatusLogPanel.java +++ /dev/null @@ -1,424 +0,0 @@ -/* - * Autopsy Forensic Browser - * - * Copyright 2015-2018 Basis Technology Corp. - * Contact: carrier sleuthkit org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.sleuthkit.autopsy.experimental.configuration; - -import java.awt.Color; -import java.util.ArrayList; -import java.util.Collection; -import org.openide.util.NbBundle; -import org.sleuthkit.autopsy.corecomponents.TextPrompt; -import java.awt.Cursor; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.logging.Level; -import javax.swing.ImageIcon; -import javax.swing.JDialog; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import org.openide.util.ImageUtilities; -import org.sleuthkit.autopsy.core.UserPreferencesException; -import org.sleuthkit.autopsy.coreutils.Logger; -import org.sleuthkit.autopsy.experimental.autoingest.StatusDatabaseLogger; - -/** - * Node status log panel. - */ -@SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives -public class NodeStatusLogPanel extends javax.swing.JPanel { - - private static final String HOST_NAME_OR_IP_PROMPT = NbBundle.getMessage(NodeStatusLogPanel.class, "NodeStatusLogPanel.tbDbHostname.toolTipText"); - private static final String PORT_PROMPT = NbBundle.getMessage(NodeStatusLogPanel.class, "NodeStatusLogPanel.tbDbPort.toolTipText"); - private static final String USER_NAME_PROMPT = NbBundle.getMessage(NodeStatusLogPanel.class, "NodeStatusLogPanel.tbDbUsername.toolTipText"); - private static final String PASSWORD_PROMPT = NbBundle.getMessage(NodeStatusLogPanel.class, "NodeStatusLogPanel.tbDbPassword.toolTipText"); - private static final String DATABASE_NAME_PROMPT = NbBundle.getMessage(NodeStatusLogPanel.class, "NodeStatusLogPanel.tbDbName.toolTipText"); - - private final ImageIcon goodIcon; - private final ImageIcon badIcon; - - JDialog jDialog; - private static final Logger logger = Logger.getLogger(NodeStatusLogPanel.class.getName()); - - /** - * Creates new form DatabaseLogPanell - * @param jDialog - */ - public NodeStatusLogPanel(JDialog jDialog) { - initComponents(); - load(); - validateSettings(); - this.jDialog = jDialog; - - tbDbHostname.getDocument().addDocumentListener(new MyDocumentListener()); - tbDbPort.getDocument().addDocumentListener(new MyDocumentListener()); - tbDbPassword.getDocument().addDocumentListener(new MyDocumentListener()); - tbDbUsername.getDocument().addDocumentListener(new MyDocumentListener()); - tbDbName.getDocument().addDocumentListener(new MyDocumentListener()); - - /** - * Add text prompts to all of the text fields. - */ - Collection textPrompts = new ArrayList<>(); - textPrompts.add(new TextPrompt(HOST_NAME_OR_IP_PROMPT, tbDbHostname)); - textPrompts.add(new TextPrompt(PORT_PROMPT, tbDbPort)); - textPrompts.add(new TextPrompt(USER_NAME_PROMPT, tbDbUsername)); - textPrompts.add(new TextPrompt(PASSWORD_PROMPT, tbDbPassword)); - textPrompts.add(new TextPrompt(DATABASE_NAME_PROMPT, tbDbName)); - configureTextPrompts(textPrompts); - - goodIcon = new ImageIcon(ImageUtilities.loadImage("org/sleuthkit/autopsy/images/good.png", false)); - badIcon = new ImageIcon(ImageUtilities.loadImage("org/sleuthkit/autopsy/images/bad.png", false)); - } - - final void validateSettings(){ - if(valid()){ - bnOk.setEnabled(true); - if(cbEnableLogging.isSelected()){ - bnTestDatabase.setEnabled(true); - } else { - bnTestDatabase.setEnabled(false); - } - } else { - bnOk.setEnabled(false); - bnTestDatabase.setEnabled(false); - } - } - - private boolean valid(){ - if(cbEnableLogging.isSelected()){ - if(tbDbHostname.getText().isEmpty() - || tbDbPort.getText().isEmpty() - || tbDbUsername.getText().isEmpty() - || (tbDbPassword.getPassword().length == 0) - || tbDbName.getText().isEmpty()){ - return false; - } - } - return true; - } - - private void enableFields(boolean enable){ - tbDbHostname.setEnabled(enable); - tbDbPort.setEnabled(enable); - tbDbUsername.setEnabled(enable); - tbDbPassword.setEnabled(enable); - tbDbName.setEnabled(enable); - } - - final void load(){ - - try{ - cbEnableLogging.setSelected(AutoIngestUserPreferences.getStatusDatabaseLoggingEnabled()); - tbDbHostname.setText(AutoIngestUserPreferences.getLoggingDatabaseHostnameOrIP()); - tbDbPort.setText(AutoIngestUserPreferences.getLoggingPort()); - tbDbUsername.setText(AutoIngestUserPreferences.getLoggingUsername()); - tbDbPassword.setText(AutoIngestUserPreferences.getLoggingPassword()); - } catch (UserPreferencesException ex) { - logger.log(Level.SEVERE, "Error accessing status database connection info", ex); //NON-NLS - } - tbDbName.setText(AutoIngestUserPreferences.getLoggingDatabaseName()); - } - - void store(){ - AutoIngestUserPreferences.setStatusDatabaseLoggingEnabled(cbEnableLogging.isSelected()); - if(cbEnableLogging.isSelected()){ - try{ - AutoIngestUserPreferences.setLoggingDatabaseHostnameOrIP(tbDbHostname.getText().trim()); - AutoIngestUserPreferences.setLoggingPort(tbDbPort.getText().trim()); - AutoIngestUserPreferences.setLoggingUsername(tbDbUsername.getText().trim()); - AutoIngestUserPreferences.setLoggingPassword(new String(tbDbPassword.getPassword())); - AutoIngestUserPreferences.setLoggingDatabaseName(tbDbName.getText().trim()); - } catch (UserPreferencesException ex) { - logger.log(Level.SEVERE, "Error saving database connection info", ex); //NON-NLS - } - - } - } - - /** - * Sets the foreground color and transparency of a collection of text - * prompts. - * - * @param textPrompts The text prompts to configure. - */ - private static void configureTextPrompts(Collection textPrompts) { - float alpha = 0.9f; // Mostly opaque - for (TextPrompt textPrompt : textPrompts) { - textPrompt.setForeground(Color.LIGHT_GRAY); - textPrompt.changeAlpha(alpha); - } - } - - private void testDatabase(){ - String host = tbDbHostname.getText(); - String port = tbDbPort.getText(); - String username = tbDbUsername.getText(); - String password = new String(tbDbPassword.getPassword()); - String dbName = tbDbName.getText(); - - lbTestDatabase.setIcon(null); - lbTestDbWarning.setText(""); - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - - // First test whether we can connect to the database - try{ - Class.forName("org.postgresql.Driver"); - } catch (ClassNotFoundException ex){ - // Continue on even if this fails - } - try (Connection connection = DriverManager.getConnection("jdbc:postgresql://" + host + ":" + port + "/" + dbName, - username, password); - Statement statement = connection.createStatement();) { - // Now make sure the database is set up for logging - try{ - StatusDatabaseLogger.logToStatusDatabase(statement, "Testing configuration", false); - lbTestDatabase.setIcon(goodIcon); - lbTestDbWarning.setText(""); - } catch (SQLException ex){ - lbTestDatabase.setIcon(badIcon); - lbTestDbWarning.setText("Database is not correctly initialized - " + ex.getMessage()); - } - } catch (SQLException ex) { - lbTestDatabase.setIcon(badIcon); - lbTestDbWarning.setText(ex.getMessage()); - } finally { - setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - } - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - pnDatabaseSettings = new javax.swing.JPanel(); - tbDbHostname = new javax.swing.JTextField(); - tbDbPort = new javax.swing.JTextField(); - tbDbUsername = new javax.swing.JTextField(); - tbDbPassword = new javax.swing.JPasswordField(); - lbDatabaseSettings = new javax.swing.JLabel(); - bnTestDatabase = new javax.swing.JButton(); - lbTestDatabase = new javax.swing.JLabel(); - lbTestDbWarning = new javax.swing.JLabel(); - tbDbName = new javax.swing.JTextField(); - cbEnableLogging = new javax.swing.JCheckBox(); - bnOk = new javax.swing.JButton(); - bnCancel = new javax.swing.JButton(); - - pnDatabaseSettings.setBorder(javax.swing.BorderFactory.createEtchedBorder()); - - tbDbHostname.setFont(tbDbHostname.getFont().deriveFont(tbDbHostname.getFont().getStyle() & ~java.awt.Font.BOLD, 12)); - tbDbHostname.setText(org.openide.util.NbBundle.getMessage(NodeStatusLogPanel.class, "NodeStatusLogPanel.tbDbHostname.text")); // NOI18N - tbDbHostname.setToolTipText(org.openide.util.NbBundle.getMessage(NodeStatusLogPanel.class, "NodeStatusLogPanel.tbDbHostname.toolTipText")); // NOI18N - - tbDbPort.setFont(tbDbPort.getFont().deriveFont(tbDbPort.getFont().getStyle() & ~java.awt.Font.BOLD, 12)); - tbDbPort.setText(org.openide.util.NbBundle.getMessage(NodeStatusLogPanel.class, "NodeStatusLogPanel.tbDbPort.text")); // NOI18N - tbDbPort.setToolTipText(org.openide.util.NbBundle.getMessage(NodeStatusLogPanel.class, "NodeStatusLogPanel.tbDbPort.toolTipText")); // NOI18N - - tbDbUsername.setFont(tbDbUsername.getFont().deriveFont(tbDbUsername.getFont().getStyle() & ~java.awt.Font.BOLD, 12)); - tbDbUsername.setText(org.openide.util.NbBundle.getMessage(NodeStatusLogPanel.class, "NodeStatusLogPanel.tbDbUsername.text")); // NOI18N - tbDbUsername.setToolTipText(org.openide.util.NbBundle.getMessage(NodeStatusLogPanel.class, "NodeStatusLogPanel.tbDbUsername.toolTipText")); // NOI18N - - tbDbPassword.setFont(tbDbPassword.getFont().deriveFont(tbDbPassword.getFont().getStyle() & ~java.awt.Font.BOLD, 12)); - tbDbPassword.setText(org.openide.util.NbBundle.getMessage(NodeStatusLogPanel.class, "NodeStatusLogPanel.tbDbPassword.text")); // NOI18N - tbDbPassword.setToolTipText(org.openide.util.NbBundle.getMessage(NodeStatusLogPanel.class, "NodeStatusLogPanel.tbDbPassword.toolTipText")); // NOI18N - - lbDatabaseSettings.setFont(lbDatabaseSettings.getFont().deriveFont(lbDatabaseSettings.getFont().getStyle() & ~java.awt.Font.BOLD, 12)); - org.openide.awt.Mnemonics.setLocalizedText(lbDatabaseSettings, org.openide.util.NbBundle.getMessage(NodeStatusLogPanel.class, "NodeStatusLogPanel.lbDatabaseSettings.text")); // NOI18N - lbDatabaseSettings.setVerticalAlignment(javax.swing.SwingConstants.TOP); - - bnTestDatabase.setFont(bnTestDatabase.getFont().deriveFont(bnTestDatabase.getFont().getStyle() & ~java.awt.Font.BOLD, 11)); - org.openide.awt.Mnemonics.setLocalizedText(bnTestDatabase, org.openide.util.NbBundle.getMessage(NodeStatusLogPanel.class, "NodeStatusLogPanel.bnTestDatabase.text")); // NOI18N - bnTestDatabase.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - bnTestDatabaseActionPerformed(evt); - } - }); - - org.openide.awt.Mnemonics.setLocalizedText(lbTestDatabase, org.openide.util.NbBundle.getMessage(NodeStatusLogPanel.class, "NodeStatusLogPanel.lbTestDatabase.text")); // NOI18N - lbTestDatabase.setAutoscrolls(true); - - lbTestDbWarning.setForeground(new java.awt.Color(255, 0, 0)); - org.openide.awt.Mnemonics.setLocalizedText(lbTestDbWarning, org.openide.util.NbBundle.getMessage(NodeStatusLogPanel.class, "NodeStatusLogPanel.lbTestDbWarning.text")); // NOI18N - - tbDbName.setText(org.openide.util.NbBundle.getMessage(NodeStatusLogPanel.class, "NodeStatusLogPanel.tbDbName.text")); // NOI18N - tbDbName.setToolTipText(org.openide.util.NbBundle.getMessage(NodeStatusLogPanel.class, "NodeStatusLogPanel.tbDbName.toolTipText_1")); // NOI18N - - javax.swing.GroupLayout pnDatabaseSettingsLayout = new javax.swing.GroupLayout(pnDatabaseSettings); - pnDatabaseSettings.setLayout(pnDatabaseSettingsLayout); - pnDatabaseSettingsLayout.setHorizontalGroup( - pnDatabaseSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(pnDatabaseSettingsLayout.createSequentialGroup() - .addContainerGap() - .addGroup(pnDatabaseSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(pnDatabaseSettingsLayout.createSequentialGroup() - .addComponent(lbDatabaseSettings) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 344, Short.MAX_VALUE) - .addComponent(bnTestDatabase) - .addGap(18, 18, 18) - .addComponent(lbTestDatabase, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addComponent(tbDbHostname) - .addComponent(tbDbPort) - .addComponent(tbDbUsername) - .addComponent(tbDbPassword) - .addComponent(tbDbName) - .addComponent(lbTestDbWarning, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addContainerGap()) - ); - pnDatabaseSettingsLayout.setVerticalGroup( - pnDatabaseSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnDatabaseSettingsLayout.createSequentialGroup() - .addContainerGap() - .addGroup(pnDatabaseSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(bnTestDatabase) - .addComponent(lbTestDatabase, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(lbDatabaseSettings)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(tbDbHostname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(tbDbPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(tbDbUsername, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(tbDbPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(tbDbName, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(lbTestDbWarning, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(24, 24, 24)) - ); - - cbEnableLogging.setFont(cbEnableLogging.getFont().deriveFont(cbEnableLogging.getFont().getStyle() & ~java.awt.Font.BOLD, 11)); - org.openide.awt.Mnemonics.setLocalizedText(cbEnableLogging, org.openide.util.NbBundle.getMessage(NodeStatusLogPanel.class, "NodeStatusLogPanel.cbEnableLogging.text")); // NOI18N - cbEnableLogging.addItemListener(new java.awt.event.ItemListener() { - public void itemStateChanged(java.awt.event.ItemEvent evt) { - cbEnableLoggingItemStateChanged(evt); - } - }); - - org.openide.awt.Mnemonics.setLocalizedText(bnOk, org.openide.util.NbBundle.getMessage(NodeStatusLogPanel.class, "NodeStatusLogPanel.bnOk.text")); // NOI18N - bnOk.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - bnOkActionPerformed(evt); - } - }); - - org.openide.awt.Mnemonics.setLocalizedText(bnCancel, org.openide.util.NbBundle.getMessage(NodeStatusLogPanel.class, "NodeStatusLogPanel.bnCancel.text")); // NOI18N - bnCancel.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - bnCancelActionPerformed(evt); - } - }); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); - this.setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addContainerGap(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) - .addContainerGap()) - .addGroup(layout.createSequentialGroup() - .addGap(232, 232, 232) - .addComponent(bnOk) - .addGap(18, 18, 18) - .addComponent(bnCancel) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addComponent(cbEnableLogging) - .addContainerGap(421, Short.MAX_VALUE))) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addGap(79, 79, 79) - .addComponent(pnDatabaseSettings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(bnOk) - .addComponent(bnCancel)) - .addContainerGap(69, Short.MAX_VALUE)) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addGap(48, 48, 48) - .addComponent(cbEnableLogging) - .addContainerGap(324, Short.MAX_VALUE))) - ); - }// //GEN-END:initComponents - - private void cbEnableLoggingItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbEnableLoggingItemStateChanged - enableFields(cbEnableLogging.isSelected()); - validateSettings(); - }//GEN-LAST:event_cbEnableLoggingItemStateChanged - - private void bnTestDatabaseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnTestDatabaseActionPerformed - testDatabase(); - }//GEN-LAST:event_bnTestDatabaseActionPerformed - - private void bnOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnOkActionPerformed - store(); - jDialog.dispose(); - }//GEN-LAST:event_bnOkActionPerformed - - private void bnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnCancelActionPerformed - jDialog.dispose(); - }//GEN-LAST:event_bnCancelActionPerformed - - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JButton bnCancel; - private javax.swing.JButton bnOk; - private javax.swing.JButton bnTestDatabase; - private javax.swing.JCheckBox cbEnableLogging; - private javax.swing.JLabel lbDatabaseSettings; - private javax.swing.JLabel lbTestDatabase; - private javax.swing.JLabel lbTestDbWarning; - private javax.swing.JPanel pnDatabaseSettings; - private javax.swing.JTextField tbDbHostname; - private javax.swing.JTextField tbDbName; - private javax.swing.JPasswordField tbDbPassword; - private javax.swing.JTextField tbDbPort; - private javax.swing.JTextField tbDbUsername; - // End of variables declaration//GEN-END:variables - - private class MyDocumentListener implements DocumentListener { - - @Override - public void changedUpdate(DocumentEvent e) { - validateSettings(); - } - - @Override - public void removeUpdate(DocumentEvent e) { - validateSettings(); - } - - @Override - public void insertUpdate(DocumentEvent e) { - validateSettings(); - } - }; -} diff --git a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/datamodel/DrawableFile.java b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/datamodel/DrawableFile.java index 4b777b387d..9c84f6d3b2 100644 --- a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/datamodel/DrawableFile.java +++ b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/datamodel/DrawableFile.java @@ -158,7 +158,7 @@ public abstract class DrawableFile { } public DataSource getDataSource() throws TskCoreException, TskDataException { - return getSleuthkitCase().getDataSource(file.getDataSource().getId()); + return getSleuthkitCase().getDataSource(file.getDataSourceObjectId()); } private Pair, Collection> makeAttributeValuePair(DrawableAttribute attribute) {