private static void addHL7DeviceExtension(Device device, boolean sampleConfig) {
    HL7DeviceExtension ext = new HL7DeviceExtension();
    device.addDeviceExtension(ext);

    HL7Application hl7App = new HL7Application("*");
    ArchiveHL7ApplicationExtension hl7AppExt = new ArchiveHL7ApplicationExtension();
    hl7App.addHL7ApplicationExtension(hl7AppExt);
    hl7App.setAcceptedMessageTypes(HL7_MESSAGE_TYPES);
    hl7App.setHL7DefaultCharacterSet("8859/1");
    ext.addHL7Application(hl7App);

    Connection hl7 = new Connection("hl7", "localhost", 2575);
    hl7.setBindAddress("0.0.0.0");
    hl7.setClientBindAddress("0.0.0.0");
    hl7.setProtocol(Connection.Protocol.HL7);
    device.addConnection(hl7);
    hl7App.addConnection(hl7);

    if (sampleConfig) {
      Connection hl7TLS = new Connection("hl7-tls", "localhost", 12575);
      hl7TLS.setBindAddress("0.0.0.0");
      hl7TLS.setClientBindAddress("0.0.0.0");
      hl7TLS.setProtocol(Connection.Protocol.HL7);
      hl7TLS.setTlsCipherSuites(
          Connection.TLS_RSA_WITH_AES_128_CBC_SHA, Connection.TLS_RSA_WITH_3DES_EDE_CBC_SHA);
      device.addConnection(hl7TLS);
      hl7App.addConnection(hl7TLS);
    }
  }
 public Device createHL7Device(
     String name,
     Issuer issuer,
     Code institutionCode,
     String appName,
     String host,
     int port,
     int tlsPort)
     throws Exception {
   Device device = new Device(name);
   HL7DeviceExtension hl7Device = new HL7DeviceExtension();
   device.addDeviceExtension(hl7Device);
   init(device, issuer, institutionCode);
   HL7Application hl7app = new HL7Application(appName);
   hl7Device.addHL7Application(hl7app);
   Connection hl7 = new Connection("hl7", host, port);
   hl7.setProtocol(Connection.Protocol.HL7);
   device.addConnection(hl7);
   hl7app.addConnection(hl7);
   Connection hl7TLS = new Connection("hl7-tls", host, tlsPort);
   hl7TLS.setProtocol(Connection.Protocol.HL7);
   hl7TLS.setTlsCipherSuites(
       Connection.TLS_RSA_WITH_AES_128_CBC_SHA, Connection.TLS_RSA_WITH_3DES_EDE_CBC_SHA);
   device.addConnection(hl7TLS);
   hl7app.addConnection(hl7TLS);
   return device;
 }
 public Device createDevice(
     String name,
     Issuer issuer,
     Code institutionCode,
     String aet,
     String host,
     int port,
     int tlsPort)
     throws Exception {
   Device device = init(new Device(name), issuer, institutionCode);
   ApplicationEntity ae = new ApplicationEntity(aet);
   ae.setAssociationAcceptor(true);
   device.addApplicationEntity(ae);
   Connection dicom = new Connection("dicom", host, port);
   device.addConnection(dicom);
   ae.addConnection(dicom);
   Connection dicomTLS = new Connection("dicom-tls", host, tlsPort);
   dicomTLS.setTlsCipherSuites(
       Connection.TLS_RSA_WITH_AES_128_CBC_SHA, Connection.TLS_RSA_WITH_3DES_EDE_CBC_SHA);
   device.addConnection(dicomTLS);
   ae.addConnection(dicomTLS);
   return device;
 }
  public Device createArchiveDevice(String name, Device arrDevice, boolean sampleConfig)
      throws Exception {
    Device device = new Device(name);

    Connection dicom = new Connection("dicom", "localhost", 11112);
    dicom.setBindAddress("0.0.0.0");
    dicom.setClientBindAddress("0.0.0.0");
    dicom.setMaxOpsInvoked(0);
    dicom.setMaxOpsPerformed(0);
    device.addConnection(dicom);

    Connection dicomTLS = null;
    if (sampleConfig) {
      dicomTLS = new Connection("dicom-tls", "localhost", 2762);
      dicomTLS.setBindAddress("0.0.0.0");
      dicomTLS.setClientBindAddress("0.0.0.0");
      dicomTLS.setMaxOpsInvoked(0);
      dicomTLS.setMaxOpsPerformed(0);
      dicomTLS.setTlsCipherSuites(
          Connection.TLS_RSA_WITH_AES_128_CBC_SHA, Connection.TLS_RSA_WITH_3DES_EDE_CBC_SHA);
      device.addConnection(dicomTLS);
    }

    addArchiveDeviceExtension(device, sampleConfig);
    addHL7DeviceExtension(device, sampleConfig);
    addAuditLogger(device, arrDevice);
    device.addDeviceExtension(new ImageReaderExtension(ImageReaderFactory.getDefault()));
    device.addDeviceExtension(new ImageWriterExtension(ImageWriterFactory.getDefault()));

    device.setManufacturer("dcm4che.org");
    device.setManufacturerModelName("dcm4chee-arc");
    device.setSoftwareVersions("5.0.1");
    device.setKeyStoreURL(DCM4CHEE_ARC_KEY_JKS);
    device.setKeyStoreType("JKS");
    device.setKeyStorePin("secret");
    device.setThisNodeCertificates(
        config.deviceRef(name), (X509Certificate) keyStore.getCertificate(name));
    if (sampleConfig)
      for (String other : OTHER_DEVICES)
        device.setAuthorizedNodeCertificates(
            config.deviceRef(other), (X509Certificate) keyStore.getCertificate(other));

    device.addApplicationEntity(
        createAE(
            "DCM4CHEE",
            "Hide instances rejected for Quality Reasons",
            dicom,
            dicomTLS,
            HIDE_REJECTED_VIEW,
            true,
            true));
    device.addApplicationEntity(
        createAE(
            "DCM4CHEE_ADMIN",
            "Show instances rejected for Quality Reasons",
            dicom,
            dicomTLS,
            REGULAR_USE_VIEW,
            false,
            true));
    device.addApplicationEntity(
        createAE(
            "DCM4CHEE_TRASH",
            "Show rejected instances only",
            dicom,
            dicomTLS,
            TRASH_VIEW,
            false,
            false));

    return device;
  }