Merge branch 'develop' of github.com:sleuthkit/autopsy into develop

This commit is contained in:
esaunders 2018-12-04 16:12:34 -05:00
commit c0e1364f40
14 changed files with 155 additions and 1095 deletions

View File

@ -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",

View File

@ -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;
}

View File

@ -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=<html>Search the Central Repository for correlation properties with a specified value. The search is case insensitive.</html>
OtherCasesSearchDialog.errorLabel.text=\
OtherCasesSearchDialog.correlationTypeLabel.text=Correlation Property Type:
OtherCasesSearchDialog.casesLabel.text=\

View File

@ -24,18 +24,10 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="casesLabel" max="32767" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="searchButton" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="descriptionLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Component id="descriptionLabel" pref="430" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="correlationValueLabel" alignment="0" min="-2" max="-2" attributes="0"/>
@ -43,11 +35,16 @@
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="correlationTypeComboBox" pref="289" max="32767" attributes="0"/>
<Component id="correlationTypeComboBox" max="32767" attributes="0"/>
<Component id="correlationValueTextField" max="32767" attributes="0"/>
<Component id="errorLabel" alignment="0" max="32767" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="casesLabel" max="32767" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="searchButton" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
@ -57,25 +54,25 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="descriptionLabel" min="-2" max="-2" attributes="0"/>
<Component id="descriptionLabel" min="-2" pref="39" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="correlationTypeComboBox" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="correlationTypeLabel" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="15" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="correlationValueLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="correlationValueTextField" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="correlationValueLabel" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="errorLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="11" max="-2" attributes="0"/>
<EmptySpace pref="20" max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="searchButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="casesLabel" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -149,7 +146,7 @@
</Component>
<Component class="javax.swing.JLabel" name="casesLabel">
<Properties>
<Property name="horizontalAlignment" type="int" value="0"/>
<Property name="horizontalAlignment" type="int" value="2"/>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/othercasessearch/Bundle.properties" key="OtherCasesSearchDialog.casesLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>

View File

@ -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<CorrelationAttributeInstance.Type> 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<List<CorrelationAttributeInstance>, Void>() {
@Override
protected List<CorrelationAttributeInstance> doInBackground() {
List<CorrelationAttributeInstance.Type> correlationTypes;
List<CorrelationAttributeInstance> 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 {
}// </editor-fold>//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);
CorrelationAttributeInstance.Type correlationType = selectedCorrelationType;
String correlationValue = correlationValueTextField.getText().trim();
search();
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.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.
@ -346,20 +415,6 @@ final class OtherCasesSearchDialog extends javax.swing.JDialog {
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.
*/

View File

@ -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

View File

@ -1,112 +0,0 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2015-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> 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.SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format( new 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);
}
}

View File

@ -85,8 +85,6 @@
<Component id="bnAdvancedSettings" min="-2" pref="155" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="bnFileExport" min="-2" pref="155" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="bnLogging" min="-2" pref="155" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabelSelectOutputFolder" min="-2" max="-2" attributes="0"/>
@ -162,7 +160,6 @@
<Component id="bnEditIngestSettings" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="bnFileExport" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="bnAdvancedSettings" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="bnLogging" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
@ -248,16 +245,6 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="bnFileExportActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="bnLogging">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/experimental/configuration/Bundle.properties" key="AutoIngestSettingsPanel.bnLogging.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="bnLoggingActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="browseOutputFolderButton">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">

View File

@ -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;

View File

@ -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
*

View File

@ -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.

View File

@ -1,277 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Component id="pnDatabaseSettings" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="232" max="-2" attributes="0"/>
<Component id="bnOk" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="bnCancel" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="cbEnableLogging" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="421" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="79" max="-2" attributes="0"/>
<Component id="pnDatabaseSettings" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="bnOk" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="bnCancel" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="69" max="32767" attributes="0"/>
</Group>
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="48" max="-2" attributes="0"/>
<Component id="cbEnableLogging" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="324" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JPanel" name="pnDatabaseSettings">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
<EtchetBorder/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="lbDatabaseSettings" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="344" max="32767" attributes="0"/>
<Component id="bnTestDatabase" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="lbTestDatabase" min="-2" pref="16" max="-2" attributes="0"/>
</Group>
<Component id="tbDbHostname" alignment="0" max="32767" attributes="0"/>
<Component id="tbDbPort" alignment="0" max="32767" attributes="0"/>
<Component id="tbDbUsername" alignment="0" max="32767" attributes="0"/>
<Component id="tbDbPassword" max="32767" attributes="0"/>
<Component id="tbDbName" max="32767" attributes="0"/>
<Component id="lbTestDbWarning" alignment="0" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="bnTestDatabase" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="lbTestDatabase" alignment="0" min="-2" pref="23" max="-2" attributes="0"/>
<Component id="lbDatabaseSettings" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="tbDbHostname" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="tbDbPort" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="tbDbUsername" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="tbDbPassword" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="tbDbName" min="-2" pref="20" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="lbTestDbWarning" min="-2" pref="16" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="24" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JTextField" name="tbDbHostname">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor">
<FontInfo relative="true">
<Font bold="false" component="tbDbHostname" property="font" relativeSize="false" size="12"/>
</FontInfo>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="experimental/configuration/Bundle.properties" key="NodeStatusLogPanel.tbDbHostname.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="experimental/configuration/Bundle.properties" key="NodeStatusLogPanel.tbDbHostname.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="tbDbPort">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor">
<FontInfo relative="true">
<Font bold="false" component="tbDbPort" property="font" relativeSize="false" size="12"/>
</FontInfo>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="experimental/configuration/Bundle.properties" key="NodeStatusLogPanel.tbDbPort.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="experimental/configuration/Bundle.properties" key="NodeStatusLogPanel.tbDbPort.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="tbDbUsername">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor">
<FontInfo relative="true">
<Font bold="false" component="tbDbUsername" property="font" relativeSize="false" size="12"/>
</FontInfo>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="experimental/configuration/Bundle.properties" key="NodeStatusLogPanel.tbDbUsername.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="experimental/configuration/Bundle.properties" key="NodeStatusLogPanel.tbDbUsername.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JPasswordField" name="tbDbPassword">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor">
<FontInfo relative="true">
<Font bold="false" component="tbDbPassword" property="font" relativeSize="false" size="12"/>
</FontInfo>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="experimental/configuration/Bundle.properties" key="NodeStatusLogPanel.tbDbPassword.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="experimental/configuration/Bundle.properties" key="NodeStatusLogPanel.tbDbPassword.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lbDatabaseSettings">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor">
<FontInfo relative="true">
<Font bold="false" component="lbDatabaseSettings" property="font" relativeSize="false" size="12"/>
</FontInfo>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="experimental/configuration/Bundle.properties" key="NodeStatusLogPanel.lbDatabaseSettings.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="verticalAlignment" type="int" value="1"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="bnTestDatabase">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor">
<FontInfo relative="true">
<Font bold="false" component="bnTestDatabase" property="font" relativeSize="false" size="11"/>
</FontInfo>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="experimental/configuration/Bundle.properties" key="NodeStatusLogPanel.bnTestDatabase.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="bnTestDatabaseActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="lbTestDatabase">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="experimental/configuration/Bundle.properties" key="NodeStatusLogPanel.lbTestDatabase.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="autoscrolls" type="boolean" value="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lbTestDbWarning">
<Properties>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="0" red="ff" type="rgb"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="experimental/configuration/Bundle.properties" key="NodeStatusLogPanel.lbTestDbWarning.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="tbDbName">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="experimental/configuration/Bundle.properties" key="NodeStatusLogPanel.tbDbName.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/experimental/configuration/Bundle.properties" key="NodeStatusLogPanel.tbDbName.toolTipText_1" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JCheckBox" name="cbEnableLogging">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor">
<FontInfo relative="true">
<Font bold="false" component="cbEnableLogging" property="font" relativeSize="false" size="11"/>
</FontInfo>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="experimental/configuration/Bundle.properties" key="NodeStatusLogPanel.cbEnableLogging.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
<EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="cbEnableLoggingItemStateChanged"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="bnOk">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="experimental/configuration/Bundle.properties" key="NodeStatusLogPanel.bnOk.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="bnOkActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="bnCancel">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="experimental/configuration/Bundle.properties" key="NodeStatusLogPanel.bnCancel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="bnCancelActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

View File

@ -1,424 +0,0 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2015-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> 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<TextPrompt> 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<TextPrompt> 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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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)))
);
}// </editor-fold>//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();
}
};
}

View File

@ -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<DrawableAttribute<?>, Collection<?>> makeAttributeValuePair(DrawableAttribute<?> attribute) {