mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 18:17:43 +00:00
Exception handling
This commit is contained in:
parent
95ef28b8a4
commit
09c0f5dfc2
@ -108,6 +108,7 @@ AddImageWizardIterator.stepXofN=Step {0} of {1}
|
||||
AddLocalFilesTask.localFileAdd.progress.text=Adding\: {0}/{1}
|
||||
Case.getCurCase.exception.noneOpen=Cannot get the current case; there is no case open\!
|
||||
Case.create.exception.msg=Error creating a case\: {0} in dir {1}
|
||||
Case.databaseConnectionInfo.error.msg=Error accessing case database connection info
|
||||
Case.open.exception.blankCase.msg=Case name is blank.
|
||||
Case.open.msgDlg.updated.msg=Updated case database schema.\nA backup copy of the database with the following path has been made\:\n {0}
|
||||
Case.open.msgDlg.updated.title=Case Database Schema Update
|
||||
|
@ -28,6 +28,7 @@ import java.io.IOException;
|
||||
import java.nio.file.InvalidPathException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
@ -455,6 +456,10 @@ public class Case implements SleuthkitCase.ErrorObserver {
|
||||
logger.log(Level.SEVERE, "Error creating a case: " + caseName + " in dir " + caseDir, ex); //NON-NLS
|
||||
throw new CaseActionException(
|
||||
NbBundle.getMessage(Case.class, "Case.create.exception.msg", caseName, caseDir), ex);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
logger.log(Level.SEVERE, "Error accessing case database connection info", ex); //NON-NLS
|
||||
throw new CaseActionException(
|
||||
NbBundle.getMessage(Case.class, "Case.databaseConnectionInfo.error.msg"), ex);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -566,7 +571,13 @@ public class Case implements SleuthkitCase.ErrorObserver {
|
||||
if (!UserPreferences.getIsMultiUserModeEnabled()) {
|
||||
throw new CaseActionException(NbBundle.getMessage(Case.class, "Case.open.exception.multiUserCaseNotEnabled"));
|
||||
}
|
||||
db = SleuthkitCase.openCase(metadata.getCaseDatabaseName(), UserPreferences.getDatabaseConnectionInfo(), caseDir);
|
||||
try {
|
||||
db = SleuthkitCase.openCase(metadata.getCaseDatabaseName(), UserPreferences.getDatabaseConnectionInfo(), caseDir);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
logger.log(Level.SEVERE, "Error accessing case database connection info", ex); //NON-NLS
|
||||
throw new CaseActionException(
|
||||
NbBundle.getMessage(Case.class, "Case.databaseConnectionInfo.error.msg"), ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -20,4 +20,6 @@ ServicesMonitor.statusChange.notify.title=Service Status Update
|
||||
ServicesMonitor.statusChange.notify.msg=Status for {0} is {1}
|
||||
ServicesMonitor.nullServiceName.excepton.txt=Requested service name is null
|
||||
ServicesMonitor.nullStatusOrDetails.excepton.txt=Status or details string is null
|
||||
ServicesMonitor.unknownServiceName.excepton.txt=Requested service name {0} is unknown
|
||||
ServicesMonitor.unknownServiceName.excepton.txt=Requested service name {0} is unknown
|
||||
TextConverter.convert.exception.txt=Unable to convert text {0} to hex text
|
||||
TextConverter.convertFromHex.exception.txt=Unable to convert hex text to text
|
@ -266,6 +266,8 @@ public class ServicesMonitor {
|
||||
} else {
|
||||
setServiceStatus(Service.REMOTE_CASE_DATABASE.toString(), ServiceStatus.DOWN.toString(), "");
|
||||
}
|
||||
} catch (IllegalArgumentException ex) {
|
||||
logger.log(Level.SEVERE, "Error accessing case database connection info", ex); //NON-NLS
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, "Exception while checking database connection status", ex); //NON-NLS
|
||||
}
|
||||
@ -297,6 +299,8 @@ public class ServicesMonitor {
|
||||
} else {
|
||||
setServiceStatus(Service.MESSAGING.toString(), ServiceStatus.DOWN.toString(), "");
|
||||
}
|
||||
} catch (IllegalArgumentException ex) {
|
||||
logger.log(Level.SEVERE, "Error accessing messaging service connection info", ex); //NON-NLS
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, "Exception while checking messaging server connection status", ex); //NON-NLS
|
||||
}
|
||||
|
@ -28,13 +28,14 @@ import javax.crypto.SecretKey;
|
||||
import javax.crypto.SecretKeyFactory;
|
||||
import javax.crypto.spec.PBEKeySpec;
|
||||
import javax.crypto.spec.PBEParameterSpec;
|
||||
import org.openide.util.NbBundle;
|
||||
|
||||
/**
|
||||
* Provides ability to convert text to hex text.
|
||||
*/
|
||||
class TextConverter {
|
||||
|
||||
private static final char[] LOOK_AWAY = "dontlookhere".toCharArray();
|
||||
private static final char[] TMP = "dontlookhere".toCharArray();
|
||||
private static final byte[] SALT = {
|
||||
(byte) 0xde, (byte) 0x33, (byte) 0x10, (byte) 0x12,
|
||||
(byte) 0xde, (byte) 0x33, (byte) 0x10, (byte) 0x12,
|
||||
@ -44,15 +45,19 @@ class TextConverter {
|
||||
* Convert text to hex text.
|
||||
* @param property Input text string.
|
||||
* @return Converted hex string.
|
||||
* @throws GeneralSecurityException
|
||||
* @throws UnsupportedEncodingException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
static String convertTextToHexText(String property) throws GeneralSecurityException, UnsupportedEncodingException {
|
||||
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
|
||||
SecretKey key = keyFactory.generateSecret(new PBEKeySpec(LOOK_AWAY));
|
||||
Cipher pbeCipher = Cipher.getInstance("PBEWithMD5AndDES");
|
||||
pbeCipher.init(Cipher.ENCRYPT_MODE, key, new PBEParameterSpec(SALT, 20));
|
||||
return base64Encode(pbeCipher.doFinal(property.getBytes("UTF-8")));
|
||||
static String convertTextToHexText(String property) throws IllegalArgumentException {
|
||||
try {
|
||||
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
|
||||
SecretKey key = keyFactory.generateSecret(new PBEKeySpec(TMP));
|
||||
Cipher pbeCipher = Cipher.getInstance("PBEWithMD5AndDES");
|
||||
pbeCipher.init(Cipher.ENCRYPT_MODE, key, new PBEParameterSpec(SALT, 20));
|
||||
return base64Encode(pbeCipher.doFinal(property.getBytes("UTF-8")));
|
||||
} catch (Exception ex) {
|
||||
throw new IllegalArgumentException(
|
||||
NbBundle.getMessage(TextConverter.class, "TextConverter.convert.exception.txt"));
|
||||
}
|
||||
}
|
||||
|
||||
private static String base64Encode(byte[] bytes) {
|
||||
@ -63,15 +68,19 @@ class TextConverter {
|
||||
* Convert hex text back to text.
|
||||
* @param property Input hex text string.
|
||||
* @return Converted text string.
|
||||
* @throws GeneralSecurityException
|
||||
* @throws IOException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
static String convertHexTextToText(String property) throws GeneralSecurityException, IOException {
|
||||
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
|
||||
SecretKey key = keyFactory.generateSecret(new PBEKeySpec(LOOK_AWAY));
|
||||
Cipher pbeCipher = Cipher.getInstance("PBEWithMD5AndDES");
|
||||
pbeCipher.init(Cipher.DECRYPT_MODE, key, new PBEParameterSpec(SALT, 20));
|
||||
return new String(pbeCipher.doFinal(base64Decode(property)), "UTF-8");
|
||||
static String convertHexTextToText(String property) throws IllegalArgumentException {
|
||||
try {
|
||||
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
|
||||
SecretKey key = keyFactory.generateSecret(new PBEKeySpec(TMP));
|
||||
Cipher pbeCipher = Cipher.getInstance("PBEWithMD5AndDES");
|
||||
pbeCipher.init(Cipher.DECRYPT_MODE, key, new PBEParameterSpec(SALT, 20));
|
||||
return new String(pbeCipher.doFinal(base64Decode(property)), "UTF-8");
|
||||
} catch (Exception ex) {
|
||||
throw new IllegalArgumentException(
|
||||
NbBundle.getMessage(TextConverter.class, "TextConverter.convertFromHex.exception.txt"));
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[] base64Decode(String property) {
|
||||
|
@ -134,10 +134,9 @@ public final class UserPreferences {
|
||||
/**
|
||||
* Reads persisted case database connection info.
|
||||
* @return An object encapsulating the database connection info.
|
||||
* @throws GeneralSecurityException
|
||||
* @throws IOException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
public static CaseDbConnectionInfo getDatabaseConnectionInfo() throws GeneralSecurityException, IOException {
|
||||
public static CaseDbConnectionInfo getDatabaseConnectionInfo() throws IllegalArgumentException {
|
||||
DbType dbType;
|
||||
try {
|
||||
dbType = DbType.valueOf(preferences.get(EXTERNAL_DATABASE_TYPE, "SQLITE"));
|
||||
@ -155,11 +154,13 @@ public final class UserPreferences {
|
||||
|
||||
/**
|
||||
* Persists case database connection info.
|
||||
* @param connectionInfo An object encapsulating the database connection info.
|
||||
* @throws GeneralSecurityException
|
||||
* @throws UnsupportedEncodingException
|
||||
*
|
||||
* @param connectionInfo An object encapsulating the database connection
|
||||
* info.
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
public static void setDatabaseConnectionInfo(CaseDbConnectionInfo connectionInfo) throws GeneralSecurityException, UnsupportedEncodingException {
|
||||
public static void setDatabaseConnectionInfo(CaseDbConnectionInfo connectionInfo) throws IllegalArgumentException {
|
||||
preferences.put(EXTERNAL_DATABASE_HOSTNAME_OR_IP, connectionInfo.getHost());
|
||||
preferences.put(EXTERNAL_DATABASE_PORTNUMBER, connectionInfo.getPort());
|
||||
preferences.put(EXTERNAL_DATABASE_USER, connectionInfo.getUserName());
|
||||
@ -196,10 +197,9 @@ public final class UserPreferences {
|
||||
* Persists message service connection info.
|
||||
*
|
||||
* @param info An object encapsulating the message service info.
|
||||
* @throws java.security.GeneralSecurityException
|
||||
* @throws java.io.UnsupportedEncodingException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
public static void setMessageServiceConnectionInfo(MessageServiceConnectionInfo info) throws GeneralSecurityException, UnsupportedEncodingException {
|
||||
public static void setMessageServiceConnectionInfo(MessageServiceConnectionInfo info) throws IllegalArgumentException {
|
||||
preferences.put(MESSAGE_SERVICE_USER, info.getUserName());
|
||||
preferences.put(MESSAGE_SERVICE_PASSWORD, TextConverter.convertTextToHexText(info.getPassword()));
|
||||
preferences.put(MESSAGE_SERVICE_HOST, info.getHost());
|
||||
@ -210,10 +210,9 @@ public final class UserPreferences {
|
||||
* Reads persisted message service connection info.
|
||||
*
|
||||
* @return An object encapsulating the message service info.
|
||||
* @throws java.security.GeneralSecurityException
|
||||
* @throws java.io.IOException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
public static MessageServiceConnectionInfo getMessageServiceConnectionInfo() throws GeneralSecurityException, IOException {
|
||||
public static MessageServiceConnectionInfo getMessageServiceConnectionInfo() throws IllegalArgumentException {
|
||||
return new MessageServiceConnectionInfo(preferences.get(MESSAGE_SERVICE_USER, ""),
|
||||
TextConverter.convertHexTextToText(preferences.get(MESSAGE_SERVICE_PASSWORD, "")),
|
||||
preferences.get(MESSAGE_SERVICE_HOST, ""),
|
||||
|
@ -18,8 +18,12 @@ import org.sleuthkit.autopsy.core.UserPreferences;
|
||||
import org.sleuthkit.autopsy.events.MessageServiceConnectionInfo;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import java.awt.Cursor;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.util.logging.Level;
|
||||
import javax.swing.ImageIcon;
|
||||
import org.openide.util.Exceptions;
|
||||
import org.openide.util.ImageUtilities;
|
||||
import org.openide.util.Lookup;
|
||||
import org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchService;
|
||||
@ -484,17 +488,25 @@ public final class MultiUserSettingsPanel extends javax.swing.JPanel {
|
||||
}//GEN-LAST:event_bnTestSolrActionPerformed
|
||||
|
||||
void load() {
|
||||
CaseDbConnectionInfo dbInfo = UserPreferences.getDatabaseConnectionInfo();
|
||||
tbDbHostname.setText(dbInfo.getHost().trim());
|
||||
tbDbPort.setText(dbInfo.getPort().trim());
|
||||
tbDbUsername.setText(dbInfo.getUserName().trim());
|
||||
tbDbPassword.setText(dbInfo.getPassword());
|
||||
try {
|
||||
CaseDbConnectionInfo dbInfo = UserPreferences.getDatabaseConnectionInfo();
|
||||
tbDbHostname.setText(dbInfo.getHost().trim());
|
||||
tbDbPort.setText(dbInfo.getPort().trim());
|
||||
tbDbUsername.setText(dbInfo.getUserName().trim());
|
||||
tbDbPassword.setText(dbInfo.getPassword());
|
||||
} catch (IllegalArgumentException ex) {
|
||||
logger.log(Level.SEVERE, "Error accessing case database connection info", ex); //NON-NLS
|
||||
}
|
||||
|
||||
MessageServiceConnectionInfo msgServiceInfo = UserPreferences.getMessageServiceConnectionInfo();
|
||||
tbMsgHostname.setText(msgServiceInfo.getHost().trim());
|
||||
tbMsgPort.setText(msgServiceInfo.getPort().trim());
|
||||
tbMsgUsername.setText(msgServiceInfo.getUserName().trim());
|
||||
tbMsgPassword.setText(msgServiceInfo.getPassword());
|
||||
try {
|
||||
MessageServiceConnectionInfo msgServiceInfo = UserPreferences.getMessageServiceConnectionInfo();
|
||||
tbMsgHostname.setText(msgServiceInfo.getHost().trim());
|
||||
tbMsgPort.setText(msgServiceInfo.getPort().trim());
|
||||
tbMsgUsername.setText(msgServiceInfo.getUserName().trim());
|
||||
tbMsgPassword.setText(msgServiceInfo.getPassword());
|
||||
} catch (IllegalArgumentException ex) {
|
||||
logger.log(Level.SEVERE, "Error accessing case database connection info", ex); //NON-NLS
|
||||
}
|
||||
|
||||
String indexingServerHost = UserPreferences.getIndexingServerHost().trim();
|
||||
if (!indexingServerHost.isEmpty()) {
|
||||
@ -570,14 +582,22 @@ public final class MultiUserSettingsPanel extends javax.swing.JPanel {
|
||||
new String(tbDbPassword.getPassword()),
|
||||
dbType);
|
||||
|
||||
UserPreferences.setDatabaseConnectionInfo(info);
|
||||
try {
|
||||
UserPreferences.setDatabaseConnectionInfo(info);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
logger.log(Level.SEVERE, "Error accessing case database connection info", ex); //NON-NLS
|
||||
}
|
||||
|
||||
MessageServiceConnectionInfo msgServiceInfo = new MessageServiceConnectionInfo(
|
||||
tbMsgUsername.getText().trim(),
|
||||
new String(tbMsgPassword.getPassword()),
|
||||
tbMsgHostname.getText().trim(),
|
||||
tbMsgPort.getText().trim());
|
||||
UserPreferences.setMessageServiceConnectionInfo(msgServiceInfo);
|
||||
try {
|
||||
UserPreferences.setMessageServiceConnectionInfo(msgServiceInfo);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
logger.log(Level.SEVERE, "Error accessing messaging service connection info", ex); //NON-NLS
|
||||
}
|
||||
|
||||
UserPreferences.setIndexingServerHost(tbSolrHostname.getText().trim());
|
||||
UserPreferences.setIndexingServerPort(Integer.parseInt(tbSolrPort.getText().trim()));
|
||||
|
@ -19,7 +19,9 @@
|
||||
package org.sleuthkit.autopsy.events;
|
||||
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import javax.jms.JMSException;
|
||||
@ -70,6 +72,10 @@ public final class AutopsyEventPublisher {
|
||||
String message = "Failed to open remote event channel"; //NON-NLS
|
||||
logger.log(Level.SEVERE, message, ex);
|
||||
throw new AutopsyEventException(message, ex);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
String message = "Error accessing messaging service connection info"; //NON-NLS
|
||||
logger.log(Level.SEVERE, message, ex);
|
||||
throw new AutopsyEventException(message, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user