mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-15 01:07:42 +00:00
Added new exception class for text converter + code review comments
This commit is contained in:
parent
968d3f7391
commit
34e093c2e1
@ -71,6 +71,7 @@ import org.sleuthkit.autopsy.casemodule.events.BlackBoardArtifactTagDeletedEvent
|
|||||||
import org.sleuthkit.autopsy.casemodule.events.ContentTagAddedEvent;
|
import org.sleuthkit.autopsy.casemodule.events.ContentTagAddedEvent;
|
||||||
import org.sleuthkit.autopsy.casemodule.events.ContentTagDeletedEvent;
|
import org.sleuthkit.autopsy.casemodule.events.ContentTagDeletedEvent;
|
||||||
import org.sleuthkit.autopsy.core.RuntimeProperties;
|
import org.sleuthkit.autopsy.core.RuntimeProperties;
|
||||||
|
import org.sleuthkit.autopsy.core.TextConverterException;
|
||||||
import org.sleuthkit.datamodel.BlackboardArtifactTag;
|
import org.sleuthkit.datamodel.BlackboardArtifactTag;
|
||||||
import org.sleuthkit.datamodel.Content;
|
import org.sleuthkit.datamodel.Content;
|
||||||
import org.sleuthkit.datamodel.ContentTag;
|
import org.sleuthkit.datamodel.ContentTag;
|
||||||
@ -455,7 +456,7 @@ public class Case implements SleuthkitCase.ErrorObserver {
|
|||||||
logger.log(Level.SEVERE, "Error creating a case: " + caseName + " in dir " + caseDir, ex); //NON-NLS
|
logger.log(Level.SEVERE, "Error creating a case: " + caseName + " in dir " + caseDir, ex); //NON-NLS
|
||||||
throw new CaseActionException(
|
throw new CaseActionException(
|
||||||
NbBundle.getMessage(Case.class, "Case.create.exception.msg", caseName, caseDir), ex);
|
NbBundle.getMessage(Case.class, "Case.create.exception.msg", caseName, caseDir), ex);
|
||||||
} catch (IllegalArgumentException ex) {
|
} catch (TextConverterException ex) {
|
||||||
logger.log(Level.SEVERE, "Error accessing case database connection info", ex); //NON-NLS
|
logger.log(Level.SEVERE, "Error accessing case database connection info", ex); //NON-NLS
|
||||||
throw new CaseActionException(
|
throw new CaseActionException(
|
||||||
NbBundle.getMessage(Case.class, "Case.databaseConnectionInfo.error.msg"), ex);
|
NbBundle.getMessage(Case.class, "Case.databaseConnectionInfo.error.msg"), ex);
|
||||||
@ -572,7 +573,7 @@ public class Case implements SleuthkitCase.ErrorObserver {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
db = SleuthkitCase.openCase(metadata.getCaseDatabaseName(), UserPreferences.getDatabaseConnectionInfo(), caseDir);
|
db = SleuthkitCase.openCase(metadata.getCaseDatabaseName(), UserPreferences.getDatabaseConnectionInfo(), caseDir);
|
||||||
} catch (IllegalArgumentException ex) {
|
} catch (TextConverterException ex) {
|
||||||
logger.log(Level.SEVERE, "Error accessing case database connection info", ex); //NON-NLS
|
logger.log(Level.SEVERE, "Error accessing case database connection info", ex); //NON-NLS
|
||||||
throw new CaseActionException(
|
throw new CaseActionException(
|
||||||
NbBundle.getMessage(Case.class, "Case.databaseConnectionInfo.error.msg"), ex);
|
NbBundle.getMessage(Case.class, "Case.databaseConnectionInfo.error.msg"), ex);
|
||||||
|
@ -242,7 +242,7 @@ public class ServicesMonitor {
|
|||||||
CaseDbConnectionInfo info;
|
CaseDbConnectionInfo info;
|
||||||
try {
|
try {
|
||||||
info = UserPreferences.getDatabaseConnectionInfo();
|
info = UserPreferences.getDatabaseConnectionInfo();
|
||||||
} catch (IllegalArgumentException ex) {
|
} catch (TextConverterException ex) {
|
||||||
logger.log(Level.SEVERE, "Error accessing case database connection info", ex); //NON-NLS
|
logger.log(Level.SEVERE, "Error accessing case database connection info", ex); //NON-NLS
|
||||||
setServiceStatus(Service.REMOTE_CASE_DATABASE.toString(), ServiceStatus.DOWN.toString(), "Error accessing case database connection info");
|
setServiceStatus(Service.REMOTE_CASE_DATABASE.toString(), ServiceStatus.DOWN.toString(), "Error accessing case database connection info");
|
||||||
return;
|
return;
|
||||||
@ -287,7 +287,7 @@ public class ServicesMonitor {
|
|||||||
MessageServiceConnectionInfo info;
|
MessageServiceConnectionInfo info;
|
||||||
try {
|
try {
|
||||||
info = UserPreferences.getMessageServiceConnectionInfo();
|
info = UserPreferences.getMessageServiceConnectionInfo();
|
||||||
} catch (IllegalArgumentException ex) {
|
} catch (TextConverterException ex) {
|
||||||
logger.log(Level.SEVERE, "Error accessing messaging service connection info", ex); //NON-NLS
|
logger.log(Level.SEVERE, "Error accessing messaging service connection info", ex); //NON-NLS
|
||||||
setServiceStatus(Service.MESSAGING.toString(), ServiceStatus.DOWN.toString(), "Error accessing messaging service connection info");
|
setServiceStatus(Service.MESSAGING.toString(), ServiceStatus.DOWN.toString(), "Error accessing messaging service connection info");
|
||||||
return;
|
return;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Autopsy Forensic Browser
|
* Autopsy Forensic Browser
|
||||||
*
|
*
|
||||||
* Copyright 2014 Basis Technology Corp.
|
* Copyright 2015 Basis Technology Corp.
|
||||||
* Contact: carrier <at> sleuthkit <dot> org
|
* Contact: carrier <at> sleuthkit <dot> org
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -19,22 +19,19 @@
|
|||||||
package org.sleuthkit.autopsy.core;
|
package org.sleuthkit.autopsy.core;
|
||||||
|
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
import java.util.logging.Level;
|
|
||||||
import javax.crypto.Cipher;
|
import javax.crypto.Cipher;
|
||||||
import javax.crypto.SecretKey;
|
import javax.crypto.SecretKey;
|
||||||
import javax.crypto.SecretKeyFactory;
|
import javax.crypto.SecretKeyFactory;
|
||||||
import javax.crypto.spec.PBEKeySpec;
|
import javax.crypto.spec.PBEKeySpec;
|
||||||
import javax.crypto.spec.PBEParameterSpec;
|
import javax.crypto.spec.PBEParameterSpec;
|
||||||
import org.openide.util.NbBundle;
|
import org.openide.util.NbBundle;
|
||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides ability to convert text to hex text.
|
* Provides ability to convert text to hex text.
|
||||||
*/
|
*/
|
||||||
class TextConverter {
|
class TextConverter {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(TextConverter.class.getName());
|
private static final char[] TMP = "hgleri21auty84fwe".toCharArray();
|
||||||
private static final char[] TMP = "dontlookhere".toCharArray();
|
|
||||||
private static final byte[] SALT = {
|
private static final byte[] SALT = {
|
||||||
(byte) 0xde, (byte) 0x33, (byte) 0x10, (byte) 0x12,
|
(byte) 0xde, (byte) 0x33, (byte) 0x10, (byte) 0x12,
|
||||||
(byte) 0xde, (byte) 0x33, (byte) 0x10, (byte) 0x12,
|
(byte) 0xde, (byte) 0x33, (byte) 0x10, (byte) 0x12,
|
||||||
@ -44,9 +41,9 @@ class TextConverter {
|
|||||||
* Convert text to hex text.
|
* Convert text to hex text.
|
||||||
* @param property Input text string.
|
* @param property Input text string.
|
||||||
* @return Converted hex string.
|
* @return Converted hex string.
|
||||||
* @throws IllegalArgumentException
|
* @throws org.sleuthkit.autopsy.core.TextConverterException
|
||||||
*/
|
*/
|
||||||
static String convertTextToHexText(String property) throws IllegalArgumentException {
|
static String convertTextToHexText(String property) throws TextConverterException {
|
||||||
try {
|
try {
|
||||||
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
|
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
|
||||||
SecretKey key = keyFactory.generateSecret(new PBEKeySpec(TMP));
|
SecretKey key = keyFactory.generateSecret(new PBEKeySpec(TMP));
|
||||||
@ -54,8 +51,7 @@ class TextConverter {
|
|||||||
pbeCipher.init(Cipher.ENCRYPT_MODE, key, new PBEParameterSpec(SALT, 20));
|
pbeCipher.init(Cipher.ENCRYPT_MODE, key, new PBEParameterSpec(SALT, 20));
|
||||||
return base64Encode(pbeCipher.doFinal(property.getBytes("UTF-8")));
|
return base64Encode(pbeCipher.doFinal(property.getBytes("UTF-8")));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
logger.log(Level.SEVERE, "Error converting text to hex text", ex); //NON-NLS
|
throw new TextConverterException(
|
||||||
throw new IllegalArgumentException(
|
|
||||||
NbBundle.getMessage(TextConverter.class, "TextConverter.convert.exception.txt"));
|
NbBundle.getMessage(TextConverter.class, "TextConverter.convert.exception.txt"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -68,9 +64,9 @@ class TextConverter {
|
|||||||
* Convert hex text back to text.
|
* Convert hex text back to text.
|
||||||
* @param property Input hex text string.
|
* @param property Input hex text string.
|
||||||
* @return Converted text string.
|
* @return Converted text string.
|
||||||
* @throws IllegalArgumentException
|
* @throws org.sleuthkit.autopsy.core.TextConverterException
|
||||||
*/
|
*/
|
||||||
static String convertHexTextToText(String property) throws IllegalArgumentException {
|
static String convertHexTextToText(String property) throws TextConverterException {
|
||||||
try {
|
try {
|
||||||
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
|
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
|
||||||
SecretKey key = keyFactory.generateSecret(new PBEKeySpec(TMP));
|
SecretKey key = keyFactory.generateSecret(new PBEKeySpec(TMP));
|
||||||
@ -78,8 +74,7 @@ class TextConverter {
|
|||||||
pbeCipher.init(Cipher.DECRYPT_MODE, key, new PBEParameterSpec(SALT, 20));
|
pbeCipher.init(Cipher.DECRYPT_MODE, key, new PBEParameterSpec(SALT, 20));
|
||||||
return new String(pbeCipher.doFinal(base64Decode(property)), "UTF-8");
|
return new String(pbeCipher.doFinal(base64Decode(property)), "UTF-8");
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
logger.log(Level.SEVERE, "Error converting hex text to text", ex); //NON-NLS
|
throw new TextConverterException(
|
||||||
throw new IllegalArgumentException(
|
|
||||||
NbBundle.getMessage(TextConverter.class, "TextConverter.convertFromHex.exception.txt"));
|
NbBundle.getMessage(TextConverter.class, "TextConverter.convertFromHex.exception.txt"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* Autopsy Forensic Browser
|
||||||
|
*
|
||||||
|
* Copyright 2015 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.core;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exception thrown when text conversion (such as from text to hex text or vice versa) resulted in
|
||||||
|
* an error
|
||||||
|
*/
|
||||||
|
public class TextConverterException extends Exception {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public TextConverterException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextConverterException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
}
|
@ -133,9 +133,9 @@ public final class UserPreferences {
|
|||||||
/**
|
/**
|
||||||
* Reads persisted case database connection info.
|
* Reads persisted case database connection info.
|
||||||
* @return An object encapsulating the database connection info.
|
* @return An object encapsulating the database connection info.
|
||||||
* @throws IllegalArgumentException
|
* @throws org.sleuthkit.autopsy.core.TextConverterException
|
||||||
*/
|
*/
|
||||||
public static CaseDbConnectionInfo getDatabaseConnectionInfo() throws IllegalArgumentException {
|
public static CaseDbConnectionInfo getDatabaseConnectionInfo() throws TextConverterException {
|
||||||
DbType dbType;
|
DbType dbType;
|
||||||
try {
|
try {
|
||||||
dbType = DbType.valueOf(preferences.get(EXTERNAL_DATABASE_TYPE, "POSTGRESQL"));
|
dbType = DbType.valueOf(preferences.get(EXTERNAL_DATABASE_TYPE, "POSTGRESQL"));
|
||||||
@ -155,10 +155,9 @@ public final class UserPreferences {
|
|||||||
*
|
*
|
||||||
* @param connectionInfo An object encapsulating the database connection
|
* @param connectionInfo An object encapsulating the database connection
|
||||||
* info.
|
* info.
|
||||||
*
|
* @throws org.sleuthkit.autopsy.core.TextConverterException
|
||||||
* @throws IllegalArgumentException
|
|
||||||
*/
|
*/
|
||||||
public static void setDatabaseConnectionInfo(CaseDbConnectionInfo connectionInfo) throws IllegalArgumentException {
|
public static void setDatabaseConnectionInfo(CaseDbConnectionInfo connectionInfo) throws TextConverterException {
|
||||||
preferences.put(EXTERNAL_DATABASE_HOSTNAME_OR_IP, connectionInfo.getHost());
|
preferences.put(EXTERNAL_DATABASE_HOSTNAME_OR_IP, connectionInfo.getHost());
|
||||||
preferences.put(EXTERNAL_DATABASE_PORTNUMBER, connectionInfo.getPort());
|
preferences.put(EXTERNAL_DATABASE_PORTNUMBER, connectionInfo.getPort());
|
||||||
preferences.put(EXTERNAL_DATABASE_USER, connectionInfo.getUserName());
|
preferences.put(EXTERNAL_DATABASE_USER, connectionInfo.getUserName());
|
||||||
@ -194,9 +193,9 @@ public final class UserPreferences {
|
|||||||
* Persists message service connection info.
|
* Persists message service connection info.
|
||||||
*
|
*
|
||||||
* @param info An object encapsulating the message service info.
|
* @param info An object encapsulating the message service info.
|
||||||
* @throws IllegalArgumentException
|
* @throws org.sleuthkit.autopsy.core.TextConverterException
|
||||||
*/
|
*/
|
||||||
public static void setMessageServiceConnectionInfo(MessageServiceConnectionInfo info) throws IllegalArgumentException {
|
public static void setMessageServiceConnectionInfo(MessageServiceConnectionInfo info) throws TextConverterException {
|
||||||
preferences.put(MESSAGE_SERVICE_HOST, info.getHost());
|
preferences.put(MESSAGE_SERVICE_HOST, info.getHost());
|
||||||
preferences.put(MESSAGE_SERVICE_PORT, Integer.toString(info.getPort()));
|
preferences.put(MESSAGE_SERVICE_PORT, Integer.toString(info.getPort()));
|
||||||
preferences.put(MESSAGE_SERVICE_USER, info.getUserName());
|
preferences.put(MESSAGE_SERVICE_USER, info.getUserName());
|
||||||
@ -207,9 +206,9 @@ public final class UserPreferences {
|
|||||||
* Reads persisted message service connection info.
|
* Reads persisted message service connection info.
|
||||||
*
|
*
|
||||||
* @return An object encapsulating the message service info.
|
* @return An object encapsulating the message service info.
|
||||||
* @throws IllegalArgumentException
|
* @throws org.sleuthkit.autopsy.core.TextConverterException
|
||||||
*/
|
*/
|
||||||
public static MessageServiceConnectionInfo getMessageServiceConnectionInfo() throws IllegalArgumentException {
|
public static MessageServiceConnectionInfo getMessageServiceConnectionInfo() throws TextConverterException {
|
||||||
int port;
|
int port;
|
||||||
try {
|
try {
|
||||||
port = Integer.parseInt(preferences.get(MESSAGE_SERVICE_PORT, DEFAULT_PORT_STRING));
|
port = Integer.parseInt(preferences.get(MESSAGE_SERVICE_PORT, DEFAULT_PORT_STRING));
|
||||||
|
@ -22,6 +22,7 @@ import java.util.logging.Level;
|
|||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
import org.openide.util.ImageUtilities;
|
import org.openide.util.ImageUtilities;
|
||||||
import org.openide.util.Lookup;
|
import org.openide.util.Lookup;
|
||||||
|
import org.sleuthkit.autopsy.core.TextConverterException;
|
||||||
import org.sleuthkit.autopsy.events.MessageServiceException;
|
import org.sleuthkit.autopsy.events.MessageServiceException;
|
||||||
import org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchService;
|
import org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchService;
|
||||||
import org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchServiceException;
|
import org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchServiceException;
|
||||||
@ -566,7 +567,7 @@ public final class MultiUserSettingsPanel extends javax.swing.JPanel {
|
|||||||
tbDbPort.setText(dbInfo.getPort().trim());
|
tbDbPort.setText(dbInfo.getPort().trim());
|
||||||
tbDbUsername.setText(dbInfo.getUserName().trim());
|
tbDbUsername.setText(dbInfo.getUserName().trim());
|
||||||
tbDbPassword.setText(dbInfo.getPassword());
|
tbDbPassword.setText(dbInfo.getPassword());
|
||||||
} catch (IllegalArgumentException ex) {
|
} catch (TextConverterException ex) {
|
||||||
logger.log(Level.SEVERE, "Error accessing case database connection info", ex); //NON-NLS
|
logger.log(Level.SEVERE, "Error accessing case database connection info", ex); //NON-NLS
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -576,7 +577,7 @@ public final class MultiUserSettingsPanel extends javax.swing.JPanel {
|
|||||||
tbMsgPort.setText(Integer.toString(msgServiceInfo.getPort()));
|
tbMsgPort.setText(Integer.toString(msgServiceInfo.getPort()));
|
||||||
tbMsgUsername.setText(msgServiceInfo.getUserName().trim());
|
tbMsgUsername.setText(msgServiceInfo.getUserName().trim());
|
||||||
tbMsgPassword.setText(msgServiceInfo.getPassword());
|
tbMsgPassword.setText(msgServiceInfo.getPassword());
|
||||||
} catch (IllegalArgumentException ex) {
|
} catch (TextConverterException ex) {
|
||||||
logger.log(Level.SEVERE, "Error accessing case database connection info", ex); //NON-NLS
|
logger.log(Level.SEVERE, "Error accessing case database connection info", ex); //NON-NLS
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -656,7 +657,7 @@ public final class MultiUserSettingsPanel extends javax.swing.JPanel {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
UserPreferences.setDatabaseConnectionInfo(info);
|
UserPreferences.setDatabaseConnectionInfo(info);
|
||||||
} catch (IllegalArgumentException ex) {
|
} catch (TextConverterException ex) {
|
||||||
logger.log(Level.SEVERE, "Error accessing case database connection info", ex); //NON-NLS
|
logger.log(Level.SEVERE, "Error accessing case database connection info", ex); //NON-NLS
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -675,7 +676,7 @@ public final class MultiUserSettingsPanel extends javax.swing.JPanel {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
UserPreferences.setMessageServiceConnectionInfo(msgServiceInfo);
|
UserPreferences.setMessageServiceConnectionInfo(msgServiceInfo);
|
||||||
} catch (IllegalArgumentException ex) {
|
} catch (TextConverterException ex) {
|
||||||
logger.log(Level.SEVERE, "Error accessing messaging service connection info", ex); //NON-NLS
|
logger.log(Level.SEVERE, "Error accessing messaging service connection info", ex); //NON-NLS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ import java.net.URISyntaxException;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import javax.jms.JMSException;
|
import javax.jms.JMSException;
|
||||||
|
import org.sleuthkit.autopsy.core.TextConverterException;
|
||||||
import org.sleuthkit.autopsy.core.UserPreferences;
|
import org.sleuthkit.autopsy.core.UserPreferences;
|
||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
|
|
||||||
@ -70,7 +71,7 @@ public final class AutopsyEventPublisher {
|
|||||||
String message = "Failed to open remote event channel"; //NON-NLS
|
String message = "Failed to open remote event channel"; //NON-NLS
|
||||||
logger.log(Level.SEVERE, message, ex);
|
logger.log(Level.SEVERE, message, ex);
|
||||||
throw new AutopsyEventException(message, ex);
|
throw new AutopsyEventException(message, ex);
|
||||||
} catch (IllegalArgumentException ex) {
|
} catch (TextConverterException ex) {
|
||||||
String message = "Error accessing messaging service connection info"; //NON-NLS
|
String message = "Error accessing messaging service connection info"; //NON-NLS
|
||||||
logger.log(Level.SEVERE, message, ex);
|
logger.log(Level.SEVERE, message, ex);
|
||||||
throw new AutopsyEventException(message, ex);
|
throw new AutopsyEventException(message, ex);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user