Refine search
public static void setTlsParams(Connection remote, Connection conn) { remote.setTlsProtocols(conn.getTlsProtocols()); remote.setTlsCipherSuites(conn.getTlsCipherSuites()); }
private void reconfigureConnections(Device from) { Iterator<Connection> connIter = conns.iterator(); while (connIter.hasNext()) { Connection conn = connIter.next(); if (from.connectionWithEqualsRDN(conn) == null) { connIter.remove(); conn.setDevice(null); conn.unbind(); } } for (Connection src : from.conns) { Connection conn = connectionWithEqualsRDN(src); if (conn == null) this.addConnection(conn = new Connection()); conn.reconfigure(src); } }
private static void configureBindServer(Connection conn, CommandLine cl) throws ParseException { if (!cl.hasOption("b")) throw new MissingOptionException( CLIUtils.rb.getString("missing-bind-opt")); String aeAtHostPort = cl.getOptionValue("b"); String[] hostAndPort = StringUtils.split(aeAtHostPort, ':'); int portIndex = hostAndPort.length - 1; conn.setPort(Integer.parseInt(hostAndPort[portIndex])); if (portIndex > 0) conn.setHostname(hostAndPort[0]); }
public boolean isCompatible(Connection remoteConn) { if (remoteConn.protocol != protocol) return false; if (!protocol.isTCP()) return true; if (!isTls()) return !remoteConn.isTls(); return hasCommon(remoteConn.getTlsProtocols(), getTlsProtocols()) && hasCommon(remoteConn.tlsCipherSuites, tlsCipherSuites); }
private SSLSocket createTLSSocket(Socket s, Connection remoteConn) throws GeneralSecurityException, IOException { SSLContext sslContext = device.sslContext(); SSLSocketFactory sf = sslContext.getSocketFactory(); SSLSocket ssl = (SSLSocket) sf.createSocket(s, remoteConn.getHostname(), remoteConn.getPort(), true); ssl.setEnabledProtocols( intersect(remoteConn.getTlsProtocols(), getTlsProtocols())); ssl.setEnabledCipherSuites( intersect(remoteConn.tlsCipherSuites, tlsCipherSuites)); ssl.startHandshake(); return ssl; }
private static void configureBind(Connection conn, CommandLine cl) { if (cl.hasOption("b")) conn.setHostname(cl.getOptionValue("b")); }
try { CommandLine cl = parseComandLine(args); Device device = new Device("stgcmtscu"); Connection conn = new Connection(); device.addConnection(conn); ApplicationEntity ae = new ApplicationEntity("STGCMTSCU"); device.addApplicationEntity(ae); ae.addConnection(conn); final StgCmtSCU stgcmtscu = new StgCmtSCU(ae); CLIUtils.configureBind(conn, stgcmtscu.ae, cl); CLIUtils.configure(conn, cl); stgcmtscu.remote.setTlsProtocols(conn.getTlsProtocols()); stgcmtscu.remote.setTlsCipherSuites(conn.getTlsCipherSuites()); stgcmtscu.setTransferSyntaxes(CLIUtils.transferSyntaxesOf(cl)); stgcmtscu.setStatus(CLIUtils.getIntOption(cl, "status", 0)); stgcmtscu.setSplitTag(getSplitTag(cl)); stgcmtscu.setKeepAlive(cl.hasOption("keep-alive")); stgcmtscu.setStorageDirectory(getStorageDirectory(cl)); stgcmtscu.setAttributes(new Attributes()); CLIUtils.addAttributes(stgcmtscu.attrs, cl.getOptionValues("s")); stgcmtscu.setUIDSuffix(cl.getOptionValue("uid-suffix")); List<String> argList = cl.getArgList(); boolean echo = argList.isEmpty(); } finally { stgcmtscu.close(); if (conn.isListening()) { device.waitForNoOpenConnections();
return; if (cl.hasOption("tls12")) conn.setTlsProtocols("TLSv1.2"); else if (cl.hasOption("tls11")) conn.setTlsProtocols("TLSv1.1"); else if (cl.hasOption("tls1")) conn.setTlsProtocols("TLSv1"); else if (cl.hasOption("ssl3")) conn.setTlsProtocols("SSLv3"); else if (cl.hasOption("ssl2Hello")) conn.setTlsProtocols("SSLv2Hello", "SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2"); else if (cl.hasOption("tls-protocol")) conn.setTlsProtocols(cl.getOptionValues("tls-protocol")); conn.setTlsNeedClientAuth(!cl.hasOption("tls-noauth")); String keyStoreURL = cl.getOptionValue("key-store", "resource:key.jks"); String trustStorePass = cl.getOptionValue("trust-store-pass", "secret"); Device device = conn.getDevice(); try { device.setKeyManager(SSLManagerFactory.createKeyManager( keyStoreType, keyStoreURL, keyStorePass, keyPass)); device.setTrustManager(SSLManagerFactory.createTrustManager( trustStoreType, trustStoreURL, trustStorePass)); } catch (GeneralSecurityException e) {
try { CommandLine cl = parseComandLine(args); Device device = new Device("mppsscu"); Connection conn = new Connection(); device.addConnection(conn); ApplicationEntity ae = new ApplicationEntity("MPPSSCU"); device.addApplicationEntity(ae); ae.addConnection(conn); final MppsSCU main = new MppsSCU(ae); CLIUtils.configureBind(conn, main.ae, cl); CLIUtils.configure(conn, cl); main.remote.setTlsProtocols(conn.getTlsProtocols()); main.remote.setTlsCipherSuites(conn.getTlsCipherSuites()); main.setTransferSyntaxes(CLIUtils.transferSyntaxesOf(cl)); main.setAttributes(new Attributes()); CLIUtils.addAttributes(main.attrs, cl.getOptionValues("s")); main.setUIDSuffix(cl.getOptionValue("uid-suffix")); List<String> argList = cl.getArgList(); boolean echo = argList.isEmpty(); if (!echo) {
CLIUtils.configureBind(main.conn, main.ae, cl); CLIUtils.configure(main.conn, cl); main.remote.setTlsProtocols(main.conn.getTlsProtocols()); main.remote.setTlsCipherSuites(main.conn.getTlsCipherSuites()); main.setTransferSyntaxes(CLIUtils.transferSyntaxesOf(cl)); CLIUtils.addAttributes(main.attrs, cl.getOptionValues("s")); main.setUIDSuffix(cl.getOptionValue("uid-suffix")); List<String> argList = cl.getArgList(); boolean echo = argList.isEmpty(); if (!echo) { ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); main.device.setExecutor(executorService); main.device.setScheduledExecutor(scheduledExecutorService); try { main.open();
public static boolean configureTLSCipher(Connection conn, CommandLine cl) throws ParseException { if (cl.hasOption("tls")) conn.setTlsCipherSuites( "SSL_RSA_WITH_NULL_SHA", "TLS_RSA_WITH_AES_128_CBC_SHA", "SSL_RSA_WITH_3DES_EDE_CBC_SHA"); else if (cl.hasOption("tls-null")) conn.setTlsCipherSuites("SSL_RSA_WITH_NULL_SHA"); else if (cl.hasOption("tls-3des")) conn.setTlsCipherSuites("SSL_RSA_WITH_3DES_EDE_CBC_SHA"); else if (cl.hasOption("tls-aes")) conn.setTlsCipherSuites( "TLS_RSA_WITH_AES_128_CBC_SHA", "SSL_RSA_WITH_3DES_EDE_CBC_SHA"); else if (cl.hasOption("tls-cipher")) conn.setTlsCipherSuites(cl.getOptionValues("tls-cipher")); return conn.isTls(); }
private static void configureRemoteConnections(DcmQRSCP main, CommandLine cl) throws Exception { String file = cl.getOptionValue("ae-config", "resource:ae.properties"); Properties aeConfig = CLIUtils.loadProperties(file, null); for (Map.Entry<Object, Object> entry : aeConfig.entrySet()) { String aet = (String) entry.getKey(); String value = (String) entry.getValue(); try { String[] hostPortCiphers = StringUtils.split(value, ':'); String[] ciphers = new String[hostPortCiphers.length-2]; System.arraycopy(hostPortCiphers, 2, ciphers, 0, ciphers.length); Connection remote = new Connection(); remote.setHostname(hostPortCiphers[0]); remote.setPort(Integer.parseInt(hostPortCiphers[1])); remote.setTlsCipherSuites(ciphers); main.addRemoteConnection(aet, remote); } catch (Exception e) { throw new IllegalArgumentException( "Invalid entry in " + file + ": " + aet + "=" + value); } } }
private static void configureBind(HL7Pix hl7pix, CommandLine cl) { String appAtHost = cl.getOptionValue("b"); if (appAtHost != null) { String[] appHost = HL7Segment.split(appAtHost, '@'); hl7pix.setSendingApplication(appHost[0]); if (appHost.length > 1) hl7pix.conn.setHostname(appHost[1]); } }
CLIUtils.configureBind(main.conn, main.ae, cl); CLIUtils.configure(main.conn, cl); main.remote.setTlsProtocols(main.conn.getTlsProtocols()); main.remote.setTlsCipherSuites(main.conn.getTlsCipherSuites()); configureServiceClass(main, cl); configureKeys(main, cl); ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); main.device.setExecutor(executorService); main.device.setScheduledExecutor(scheduledExecutorService); try { main.open(); List<String> argList = cl.getArgList(); if (argList.isEmpty()) main.retrieve();
void reconfigure(Connection from) { setCommonName(from.commonName); setHostname(from.hostname); setPort(from.port); setBindAddress(from.bindAddress); setClientBindAddress(from.clientBindAddress); setProtocol(from.protocol); setHttpProxy(from.httpProxy); setBacklog(from.backlog); setConnectTimeout(from.connectTimeout); setRequestTimeout(from.requestTimeout); setAcceptTimeout(from.acceptTimeout); setReleaseTimeout(from.releaseTimeout); setResponseTimeout(from.responseTimeout); setRetrieveTimeout(from.retrieveTimeout); setIdleTimeout(from.idleTimeout); setSocketCloseDelay(from.socketCloseDelay); setSendBufferSize(from.sendBufferSize); setReceiveBufferSize(from.receiveBufferSize); setSendPDULength(from.sendPDULength); setReceivePDULength(from.receivePDULength); setMaxOpsPerformed(from.maxOpsPerformed); setMaxOpsInvoked(from.maxOpsInvoked); setPackPDV(from.packPDV); setTcpNoDelay(from.tcpNoDelay); setTlsNeedClientAuth(from.tlsNeedClientAuth); setTlsCipherSuites(from.tlsCipherSuites); setTlsProtocols(from.tlsProtocols); setBlacklist(from.blacklist); setInstalled(from.installed);
private void loadConnections(Device device, String deviceDN) throws NamingException { NamingEnumeration<SearchResult> ne = search(deviceDN, "(objectclass=dicomNetworkConnection)"); try { while (ne.hasMore()) { SearchResult sr = ne.next(); Attributes attrs = sr.getAttributes(); Connection conn = new Connection(); loadFrom(conn, attrs, LdapUtils.hasObjectClass(attrs, "dcmNetworkConnection")); device.addConnection(conn); } } finally { LdapUtils.safeClose(ne); } }
private ServerSocket createTLSServerSocket(Connection conn) throws IOException, GeneralSecurityException { SSLContext sslContext = conn.getDevice().sslContext(); SSLServerSocketFactory ssf = sslContext.getServerSocketFactory(); SSLServerSocket ss = (SSLServerSocket) ssf.createServerSocket(); ss.setEnabledProtocols(conn.getTlsProtocols()); ss.setEnabledCipherSuites(conn.getTlsCipherSuites()); ss.setNeedClientAuth(conn.isTlsNeedClientAuth()); return ss; }
public HL7Rcv() throws IOException { conn.setProtocol(Protocol.HL7); device.addDeviceExtension(hl7Ext); device.addConnection(conn); hl7Ext.addHL7Application(hl7App); hl7App.setAcceptedMessageTypes("*"); hl7App.addConnection(conn); hl7App.setHL7MessageListener(handler); }
try { connection = new Connection(); connection.Open(); // open the connection //work with the connection, DB CRUD operations } finally { if(connection != null) connection.Close(); // close the connection in finally block // so that even if the exception occurs, connection gets closed. }
public void cstore(String cuid, String iuid, int priority, String moveOriginatorAET, int moveOriginatorMsgId, DataWriter data, String tsuid, DimseRSPHandler rspHandler) throws IOException, InterruptedException { PresentationContext pc = pcFor(cuid, tsuid); Attributes cstorerq = Commands.mkCStoreRQ(rspHandler.getMessageID(), cuid, iuid, priority, moveOriginatorAET, moveOriginatorMsgId); invoke(pc, cstorerq, data, rspHandler, conn.getResponseTimeout()); }