private Device createArchiveDevice(String name) throws Exception {
   ArchiveDevice device = new ArchiveDevice(name);
   device.setFuzzyAlgorithmClass("org.dcm4che.soundex.ESoundex");
   device.setConfigurationStaleTimeout(CONFIGURATION_STALE_TIMEOUT);
   setAttributeFilters(device);
   device.setKeyStoreURL("resource:dcm4chee-arc-key.jks");
   device.setKeyStoreType("JKS");
   device.setKeyStorePin("secret");
   device.setThisNodeCertificates(
       config.deviceRef(name), (X509Certificate) keystore.getCertificate(name));
   for (String other : OTHER_DEVICES)
     device.setAuthorizedNodeCertificates(
         config.deviceRef(other), (X509Certificate) keystore.getCertificate(other));
   Connection dicom = createConnection("dicom", "localhost", 11112);
   dicom.setMaxOpsInvoked(0);
   dicom.setMaxOpsPerformed(0);
   device.addConnection(dicom);
   Connection dicomTLS = new Connection("dicom-tls", "localhost", 2762);
   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);
   ArchiveApplicationEntity ae =
       createAE("DCM4CHEE", IMAGE_TSUIDS, VIDEO_TSUIDS, OTHER_TSUIDS, null, PIX_MANAGER);
   device.addApplicationEntity(ae);
   ae.addConnection(dicom);
   ae.addConnection(dicomTLS);
   ArchiveApplicationEntity adminAE =
       createAdminAE(
           "DCM4CHEE_ADMIN", IMAGE_TSUIDS, VIDEO_TSUIDS, OTHER_TSUIDS, null, PIX_MANAGER);
   device.addApplicationEntity(adminAE);
   adminAE.addConnection(dicom);
   adminAE.addConnection(dicomTLS);
   ArchiveHL7Application hl7App = new ArchiveHL7Application("*");
   hl7App.setAcceptedMessageTypes(HL7_MESSAGE_TYPES);
   hl7App.setHL7DefaultCharacterSet("8859/1");
   hl7App.addTemplatesURI("adt2dcm", "resource:dcm4chee-arc-hl7-adt2dcm.xsl");
   device.addHL7Application(hl7App);
   Connection hl7 = new Connection("hl7", "localhost", 2575);
   device.addConnection(hl7);
   hl7App.addConnection(hl7);
   Connection hl7TLS = new Connection("hl7-tls", "localhost", 12575);
   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;
 }
  @Override
  protected void loadFrom(Connection conn, Attributes attrs) throws NamingException {
    super.loadFrom(conn, attrs);
    if (!hasObjectClass(attrs, "dcmNetworkConnection")) return;

    conn.setProtocol(Protocol.valueOf(stringValue(attrs.get("dcmProtocol"), "DICOM")));
    conn.setHttpProxy(stringValue(attrs.get("dcmHTTPProxy"), null));
    conn.setBlacklist(stringArray(attrs.get("dcmBlacklistedHostname")));
    conn.setBacklog(intValue(attrs.get("dcmTCPBacklog"), Connection.DEF_BACKLOG));
    conn.setConnectTimeout(intValue(attrs.get("dcmTCPConnectTimeout"), Connection.NO_TIMEOUT));
    conn.setRequestTimeout(intValue(attrs.get("dcmAARQTimeout"), Connection.NO_TIMEOUT));
    conn.setAcceptTimeout(intValue(attrs.get("dcmAAACTimeout"), Connection.NO_TIMEOUT));
    conn.setReleaseTimeout(intValue(attrs.get("dcmARRPTimeout"), Connection.NO_TIMEOUT));
    conn.setResponseTimeout(intValue(attrs.get("dcmResponseTimeout"), Connection.NO_TIMEOUT));
    conn.setRetrieveTimeout(intValue(attrs.get("dcmRetrieveTimeout"), Connection.NO_TIMEOUT));
    conn.setIdleTimeout(intValue(attrs.get("dcmIdleTimeout"), Connection.NO_TIMEOUT));
    conn.setSocketCloseDelay(intValue(attrs.get("dcmTCPCloseDelay"), Connection.DEF_SOCKETDELAY));
    conn.setSendBufferSize(intValue(attrs.get("dcmTCPSendBufferSize"), Connection.DEF_BUFFERSIZE));
    conn.setReceiveBufferSize(
        intValue(attrs.get("dcmTCPReceiveBufferSize"), Connection.DEF_BUFFERSIZE));
    conn.setTcpNoDelay(booleanValue(attrs.get("dcmTCPNoDelay"), true));
    conn.setTlsNeedClientAuth(booleanValue(attrs.get("dcmTLSNeedClientAuth"), true));
    String[] tlsProtocols = stringArray(attrs.get("dcmTLSProtocol"));
    if (tlsProtocols.length > 0) conn.setTlsProtocols(tlsProtocols);
    conn.setSendPDULength(intValue(attrs.get("dcmSendPDULength"), Connection.DEF_MAX_PDU_LENGTH));
    conn.setReceivePDULength(
        intValue(attrs.get("dcmReceivePDULength"), Connection.DEF_MAX_PDU_LENGTH));
    conn.setMaxOpsPerformed(intValue(attrs.get("dcmMaxOpsPerformed"), Connection.SYNCHRONOUS_MODE));
    conn.setMaxOpsInvoked(intValue(attrs.get("dcmMaxOpsInvoked"), Connection.SYNCHRONOUS_MODE));
    conn.setPackPDV(booleanValue(attrs.get("dcmPackPDV"), true));
  }