mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-19 19:14:55 +00:00
Simplify MessageServiceConnectionInfo API, tidy Messenger
This commit is contained in:
parent
14f49ff78c
commit
10a8e731f7
@ -142,8 +142,8 @@ public final class UserPreferences {
|
|||||||
public static void setMessageServiceConnectionInfo(MessageServiceConnectionInfo info) {
|
public static void setMessageServiceConnectionInfo(MessageServiceConnectionInfo info) {
|
||||||
preferences.put(MESSAGE_SERVICE_USER, info.getUserName());
|
preferences.put(MESSAGE_SERVICE_USER, info.getUserName());
|
||||||
preferences.put(MESSAGE_SERVICE_PASSWORD, info.getPassword());
|
preferences.put(MESSAGE_SERVICE_PASSWORD, info.getPassword());
|
||||||
preferences.put(MESSAGE_SERVICE_HOST, info.getHost());
|
preferences.put(MESSAGE_SERVICE_HOST, info.getURI().getHost());
|
||||||
preferences.put(MESSAGE_SERVICE_PORT, Integer.toString(info.getPort()));
|
preferences.put(MESSAGE_SERVICE_PORT, Integer.toString(info.getURI().getPort()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,7 +36,7 @@ public final class MessageServiceConnectionInfo {
|
|||||||
* Service (JMS) provider.
|
* Service (JMS) provider.
|
||||||
*
|
*
|
||||||
* @param userName The user name to use for a message service connection.
|
* @param userName The user name to use for a message service connection.
|
||||||
* @param password the password to use for a message service connection.
|
* @param password The password to use for a message service connection.
|
||||||
* @param host The host to use for a message service connection. May be a
|
* @param host The host to use for a message service connection. May be a
|
||||||
* host name or an IP address.
|
* host name or an IP address.
|
||||||
* @param port The port number to use for a message service connection.
|
* @param port The port number to use for a message service connection.
|
||||||
@ -65,32 +65,13 @@ public final class MessageServiceConnectionInfo {
|
|||||||
public String getPassword() {
|
public String getPassword() {
|
||||||
return password;
|
return password;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the host to use for a message service connection. May be a host name
|
|
||||||
* or an IP address.
|
|
||||||
*
|
|
||||||
* @return The host as a string.
|
|
||||||
*/
|
|
||||||
public String getHost() {
|
|
||||||
return uri.getHost();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the port number to use for a message service connection.
|
|
||||||
*
|
|
||||||
* @return The port as a string.
|
|
||||||
*/
|
|
||||||
public int getPort() {
|
|
||||||
return uri.getPort();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the TCP URI to use for a message service connection.
|
* Gets the TCP URI to use for a message service connection.
|
||||||
*
|
*
|
||||||
* @return The URI.
|
* @return The URI.
|
||||||
*/
|
*/
|
||||||
URI getURI() {
|
public URI getURI() {
|
||||||
return uri;
|
return uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,11 +29,11 @@ import javax.jms.ObjectMessage;
|
|||||||
import javax.jms.Session;
|
import javax.jms.Session;
|
||||||
import javax.jms.Topic;
|
import javax.jms.Topic;
|
||||||
import org.apache.activemq.ActiveMQConnectionFactory;
|
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||||
import org.sleuthkit.autopsy.casemodule.Case;
|
|
||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
|
|
||||||
public final class Messenger implements MessageListener {
|
public final class Messenger implements MessageListener {
|
||||||
|
|
||||||
|
private static final String ALL_MESSAGE_SELECTOR = "All";
|
||||||
private static final Logger logger = Logger.getLogger(Messenger.class.getName());
|
private static final Logger logger = Logger.getLogger(Messenger.class.getName());
|
||||||
private final String caseName;
|
private final String caseName;
|
||||||
private Connection connection;
|
private Connection connection;
|
||||||
@ -52,7 +52,7 @@ public final class Messenger implements MessageListener {
|
|||||||
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||||
Topic topic = session.createTopic(caseName);
|
Topic topic = session.createTopic(caseName);
|
||||||
producer = session.createProducer(topic);
|
producer = session.createProducer(topic);
|
||||||
MessageConsumer consumer = session.createConsumer(topic, "event = '" + Case.Events.DATA_SOURCE_ADDED.toString() + "'", true);
|
MessageConsumer consumer = session.createConsumer(topic, "events = '" + ALL_MESSAGE_SELECTOR + "'", true);
|
||||||
consumer.setMessageListener(this);
|
consumer.setMessageListener(this);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
logger.log(Level.SEVERE, "Startup error", ex);
|
logger.log(Level.SEVERE, "Startup error", ex);
|
||||||
@ -71,7 +71,7 @@ public final class Messenger implements MessageListener {
|
|||||||
public void send(PropertyChangeEvent event) {
|
public void send(PropertyChangeEvent event) {
|
||||||
try {
|
try {
|
||||||
ObjectMessage message = session.createObjectMessage();
|
ObjectMessage message = session.createObjectMessage();
|
||||||
message.setStringProperty("event", Case.Events.DATA_SOURCE_ADDED.toString());
|
message.setStringProperty("events", ALL_MESSAGE_SELECTOR);
|
||||||
message.setObject(event);
|
message.setObject(event);
|
||||||
producer.send(message);
|
producer.send(message);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
@ -350,8 +350,8 @@ public final class MultiUserSettingsPanel extends javax.swing.JPanel {
|
|||||||
MessageServiceConnectionInfo msgServiceInfo = null;
|
MessageServiceConnectionInfo msgServiceInfo = null;
|
||||||
try {
|
try {
|
||||||
msgServiceInfo = UserPreferences.getMessageServiceConnectionInfo();
|
msgServiceInfo = UserPreferences.getMessageServiceConnectionInfo();
|
||||||
msgHostTextField.setText(msgServiceInfo.getHost());
|
msgHostTextField.setText(msgServiceInfo.getURI().getHost());
|
||||||
msgPortTextField.setText(Integer.toString(msgServiceInfo.getPort()));
|
msgPortTextField.setText(Integer.toString(msgServiceInfo.getURI().getPort()));
|
||||||
msgUserNameTextField.setText(msgServiceInfo.getUserName());
|
msgUserNameTextField.setText(msgServiceInfo.getUserName());
|
||||||
msgPasswordField.setText(msgServiceInfo.getPassword());
|
msgPasswordField.setText(msgServiceInfo.getPassword());
|
||||||
msgRetypePasswordField.setText(msgServiceInfo.getPassword());
|
msgRetypePasswordField.setText(msgServiceInfo.getPassword());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user