diff --git a/Core/src/org/sleuthkit/autopsy/core/ServicesMonitor.java b/Core/src/org/sleuthkit/autopsy/core/ServicesMonitor.java index 322a649a79..526a1ee274 100644 --- a/Core/src/org/sleuthkit/autopsy/core/ServicesMonitor.java +++ b/Core/src/org/sleuthkit/autopsy/core/ServicesMonitor.java @@ -204,7 +204,7 @@ public class ServicesMonitor { private String checkServiceStatus(String service) { try { if (service.equals(ServiceName.REMOTE_CASE_DATABASE.toString())) { - if (canConnectToRemoteDb()) { + if (UserPreferences.getDatabaseConnectionInfo().canConnect()) { setServiceStatus(ServiceName.REMOTE_CASE_DATABASE.toString(), ServiceStatus.UP.toString(), ""); return ServiceStatus.UP.toString(); } else { @@ -221,7 +221,7 @@ public class ServicesMonitor { return ServiceStatus.DOWN.toString(); } } else if (service.equals(ServiceName.MESSAGING.toString())) { - if (canConnectToMessagingService()) { + if (UserPreferences.getMessageServiceConnectionInfo().canConnect()) { setServiceStatus(ServiceName.MESSAGING.toString(), ServiceStatus.UP.toString(), ""); return ServiceStatus.UP.toString(); } else { @@ -297,33 +297,6 @@ public class ServicesMonitor { public void removeSubscriber(PropertyChangeListener subscriber) { eventPublisher.removeSubscriber(serviceNames, subscriber); } - - /** - * Verifies connection to remote database. - * - * @return True if connection can be established, false otherwise. - */ - private boolean canConnectToRemoteDb() { - return UserPreferences.getDatabaseConnectionInfo().canConnect(); - } - - /** - * Verifies connection to messaging service. - * - * @return True if connection can be established, false otherwise. - */ - private boolean canConnectToMessagingService() { - MessageServiceConnectionInfo msgInfo = UserPreferences.getMessageServiceConnectionInfo(); - try { - ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(msgInfo.getUserName(), msgInfo.getPassword(), msgInfo.getURI()); - Connection connection = connectionFactory.createConnection(); - connection.start(); - connection.close(); - return true; - } catch (URISyntaxException | JMSException ex) { - return false; - } - } /** * Verifies connectivity to all services. diff --git a/Core/src/org/sleuthkit/autopsy/events/MessageServiceConnectionInfo.java b/Core/src/org/sleuthkit/autopsy/events/MessageServiceConnectionInfo.java index 8bebf16f0d..2e26d3a04c 100644 --- a/Core/src/org/sleuthkit/autopsy/events/MessageServiceConnectionInfo.java +++ b/Core/src/org/sleuthkit/autopsy/events/MessageServiceConnectionInfo.java @@ -21,6 +21,10 @@ package org.sleuthkit.autopsy.events; import java.net.URI; import java.net.URISyntaxException; import javax.annotation.concurrent.Immutable; +import javax.jms.Connection; +import javax.jms.JMSException; +import org.apache.activemq.ActiveMQConnectionFactory; +import org.sleuthkit.autopsy.core.UserPreferences; /** * Connection info for a Java Message Service (JMS) provider. Thread-safe. @@ -99,4 +103,20 @@ public final class MessageServiceConnectionInfo { return new URI(String.format(MESSAGE_SERVICE_URI, host, port)); } + /** + * Verifies connection to messaging service. + * + * @return True if connection can be established, false otherwise. + */ + public boolean canConnect() { + try { + ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(getUserName(), getPassword(), getURI()); + Connection connection = connectionFactory.createConnection(); + connection.start(); + connection.close(); + return true; + } catch (URISyntaxException | JMSException ex) { + return false; + } + } }