19 package org.sleuthkit.autopsy.events;
 
   22 import java.net.URISyntaxException;
 
   23 import javax.annotation.concurrent.Immutable;
 
   24 import javax.jms.Connection;
 
   25 import javax.jms.JMSException;
 
   26 import org.apache.activemq.ActiveMQConnectionFactory;
 
   27 import java.io.IOException;
 
   28 import java.net.InetAddress;
 
   29 import java.util.MissingResourceException;
 
   30 import org.openide.util.NbBundle;
 
  113     URI getURI() throws URISyntaxException {
 
  114         return new URI(String.format(MESSAGE_SERVICE_URI, 
getHost(), Integer.toString(
getPort())));
 
  129         if (host == null || host.isEmpty()) {
 
  130             throw new MessageServiceException(NbBundle.getMessage(
MessageServiceConnectionInfo.class, 
"MessageServiceConnectionInfo.MissingHostname")); 
 
  131         } 
else if (userName == null) {
 
  132             throw new MessageServiceException(NbBundle.getMessage(
MessageServiceConnectionInfo.class, 
"MessageServiceConnectionInfo.MissingUsername")); 
 
  133         } 
else if (password == null) {
 
  134             throw new MessageServiceException(NbBundle.getMessage(
MessageServiceConnectionInfo.class, 
"MessageServiceConnectionInfo.MissingPassword")); 
 
  137             ActiveMQConnectionFactory connectionFactory = 
new ActiveMQConnectionFactory(
getUserName(), 
getPassword(), getURI());
 
  141         } 
catch (URISyntaxException ex) {
 
  143             throw new MessageServiceException(NbBundle.getMessage(
MessageServiceConnectionInfo.class, 
"MessageServiceConnectionInfo.ConnectionCheck.HostnameOrPort")); 
 
  144         } 
catch (JMSException ex) {
 
  146             Throwable cause = ex.getCause();
 
  147             if (null != cause && null != cause.getMessage()) {
 
  149                 String msg = cause.getMessage();
 
  150                 if (msg.startsWith(CONNECTION_TIMED_OUT)) {
 
  153                 } 
else if (msg.toLowerCase().startsWith(CONNECTION_REFUSED)) {
 
  156                 } 
else if (msg.toLowerCase().startsWith(PASSWORD_OR_USERNAME_BAD)) {
 
  166                     if (InetAddress.getByName(
getHost()).isReachable(IS_REACHABLE_TIMEOUT_MS)) {
 
  172                 } 
catch (IOException | MissingResourceException any) {
 
  177             throw new MessageServiceException(result);
 
static final String CONNECTION_TIMED_OUT
static final String MESSAGE_SERVICE_URI
static final String PASSWORD_OR_USERNAME_BAD
static final String CONNECTION_REFUSED
static final int IS_REACHABLE_TIMEOUT_MS
MessageServiceConnectionInfo(String host, int port, String userName, String password)