public class Connection extends Object implements Serializable
NetworkConnection
encapsulates the properties associated with a connection to a TCP/IP network.
The network connection describes one TCP port on one network device. This can be used for a TCP connection over which a DICOM association can be negotiated with one or more Network AEs. It specifies 8 the hostname and TCP port number. A network connection may support multiple Network AEs. The Network AE selection takes place during association negotiation based on the called and calling AE-titles.
Modifier and Type | Class and Description |
---|---|
static class |
Connection.Protocol |
Constructor and Description |
---|
Connection() |
Connection(String commonName,
String hostname) |
Connection(String commonName,
String hostname,
int port) |
Connection(String commonName,
String hostname,
int port,
int timeout) |
Modifier and Type | Method and Description |
---|---|
void |
addExtension(ConnectionExtension connectionExtension) |
boolean |
bind()
Bind this network connection to a TCP port and start a server socket
accept loop.
|
private InetAddress |
bindAddr() |
private List<InetAddress> |
blacklistAddrs() |
private void |
checkCompatible(Connection remoteConn) |
private void |
checkInstalled() |
private InetAddress |
clientBindAddr() |
void |
close(Socket s) |
Socket |
connect(Connection remoteConn) |
DatagramSocket |
createDatagramSocket() |
private SSLSocket |
createTLSSocket(Socket s,
Connection remoteConn) |
(package private) boolean |
equalsRDN(Connection other) |
int |
getAcceptTimeout() |
int |
getBacklog() |
String |
getBindAddress()
Bind address of listening socket or
null . |
InetSocketAddress |
getBindPoint() |
String[] |
getBlacklist()
Get a list of IP addresses from which we should ignore connections.
|
String |
getClientBindAddress()
Bind address of outgoing connections,
"0.0.0.0" or null . |
InetSocketAddress |
getClientBindPoint() |
String |
getCommonName()
An arbitrary name for the Network Connections object.
|
Boolean |
getConnectionInstalled() |
int |
getConnectTimeout() |
Device |
getDevice()
Get the
Device object that this Network Connection belongs
to. |
InetSocketAddress |
getEndPoint() |
<T> T |
getExtension(Class<T> clazz) |
Map<Class<? extends ConnectionExtension>,ConnectionExtension> |
getExtensions() |
String |
getHostname()
This is the DNS name for this particular connection.
|
String |
getHttpProxy() |
String |
getHttpProxyProviderName() |
String |
getHttpProxyProviderVersion() |
int |
getIdleTimeout() |
Listener |
getListener() |
int |
getMaxOpsInvoked() |
int |
getMaxOpsPerformed() |
String |
getOlockHash() |
int |
getPort()
The TCP port that the AE is listening on or
-1 for a
network connection that only initiates associations. |
Connection.Protocol |
getProtocol() |
ProxyManager |
getProxyManager() |
int |
getReceiveBufferSize()
Get the SO_RCVBUF socket value in KB.
|
int |
getReceivePDULength() |
int |
getReleaseTimeout()
Timeout in ms for receiving A-RELEASE-RP, 5000 by default.
|
int |
getRequestTimeout()
Timeout in ms for receiving A-ASSOCIATE-RQ, 5000 by default
|
int |
getResponseTimeout() |
int |
getRetrieveTimeout() |
int |
getSendBufferSize()
Get the SO_SNDBUF socket option value in KB,
|
int |
getSendPDULength() |
int |
getSocketCloseDelay()
Delay in ms for Socket close after sending A-ABORT, 50ms by default.
|
int |
getSocketTimeout() |
String[] |
getTlsCipherSuites()
The TLS CipherSuites that are supported on this particular connection.
|
String[] |
getTlsProtocols() |
String |
getUuid() |
private boolean |
hasCommon(String[] ss1,
String[] ss2) |
private InetAddress |
hostAddr() |
private static String[] |
intersect(String[] ss1,
String[] ss2) |
boolean |
isBlackListed(InetAddress ia) |
boolean |
isCompatible(Connection remoteConn) |
boolean |
isInstalled()
True if the Network Connection is installed on the network.
|
boolean |
isListening() |
boolean |
isPackPDV() |
(package private) boolean |
isRebindNeeded() |
boolean |
isServer() |
boolean |
isTcpNoDelay()
Determine if this network connection is using Nagle's algorithm as part
of its network communication.
|
boolean |
isTls() |
boolean |
isTlsNeedClientAuth() |
(package private) void |
needRebind() |
StringBuilder |
promptTo(StringBuilder sb,
String indent) |
(package private) void |
rebind() |
(package private) void |
reconfigure(Connection from) |
private void |
reconfigureExtensions(Connection from) |
static TCPProtocolHandler |
registerTCPProtocolHandler(Connection.Protocol protocol,
TCPProtocolHandler handler) |
static UDPProtocolHandler |
registerUDPProtocolHandler(Connection.Protocol protocol,
UDPProtocolHandler handler) |
void |
setAcceptTimeout(int timeout) |
void |
setBacklog(int backlog) |
void |
setBindAddress(String bindAddress)
Bind address of listening socket or
null . |
void |
setBlacklist(String[] blacklist)
Set a list of IP addresses from which we should ignore connections.
|
void |
setClientBindAddress(String bindAddress)
Bind address of outgoing connections,
"0.0.0.0" or null . |
void |
setCommonName(String name)
An arbitrary name for the Network Connections object.
|
void |
setConnectionInstalled(Boolean installed)
True if the Network Connection is installed on the network.
|
void |
setConnectTimeout(int timeout) |
void |
setDevice(Device device)
Set the
Device object that this Network Connection belongs
to. |
void |
setExtensions(Map<Class<? extends ConnectionExtension>,ConnectionExtension> extensions) |
void |
setHostname(String hostname)
This is the DNS name for this particular connection.
|
void |
setHttpProxy(String proxy) |
void |
setHttpProxyProviderName(String httpProxyProviderName) |
void |
setHttpProxyProviderVersion(String httpProxyProviderVersion) |
void |
setIdleTimeout(int idleTimeout) |
void |
setMaxOpsInvoked(int maxOpsInvoked) |
void |
setMaxOpsPerformed(int maxOpsPerformed) |
void |
setOlockHash(String olockHash) |
void |
setPackPDV(boolean packPDV) |
void |
setPort(int port)
The TCP port that the AE is listening on or
0 for a
network connection that only initiates associations. |
void |
setProtocol(Connection.Protocol protocol) |
void |
setReceiveBufferSize(DatagramSocket ds) |
void |
setReceiveBufferSize(int size)
Set the SO_RCVBUF socket option to specified value in KB.
|
(package private) void |
setReceiveBufferSize(ServerSocket ss) |
private void |
setReceiveBufferSize(Socket s) |
void |
setReceivePDULength(int receivePDULength) |
void |
setReleaseTimeout(int timeout)
Timeout in ms for receiving A-RELEASE-RP, 5000 by default.
|
void |
setRequestTimeout(int timeout)
Timeout in ms for receiving A-ASSOCIATE-RQ, 5000 by default
|
void |
setResponseTimeout(int timeout) |
void |
setRetrieveTimeout(int timeout) |
void |
setSendBufferSize(int size)
Set the SO_SNDBUF socket option to specified value in KB,
|
void |
setSendPDULength(int sendPDULength) |
void |
setSocketCloseDelay(int delay)
Delay in ms for Socket close after sending A-ABORT, 50ms by default.
|
(package private) void |
setSocketSendOptions(Socket s) |
void |
setSocketTimeout(int socketTimeout) |
void |
setTcpNoDelay(boolean tcpNoDelay)
Set whether or not this network connection should use Nagle's algorithm
as part of its network communication.
|
void |
setTlsCipherSuites(String... tlsCipherSuites)
The TLS CipherSuites that are supported on this particular connection.
|
void |
setTlsNeedClientAuth(boolean tlsNeedClientAuth) |
void |
setTlsProtocols(String... tlsProtocols) |
void |
setUuid(String uuid) |
String[] |
tlsProtocols() |
String |
toString() |
void |
unbind() |
static TCPProtocolHandler |
unregisterTCPProtocolHandler(Connection.Protocol protocol) |
static UDPProtocolHandler |
unregisterUDPProtocolHandler(Connection.Protocol protocol) |
boolean |
useHttpProxy() |
private static final long serialVersionUID
public static final String NO_TIMEOUT_STR
public static final int NO_TIMEOUT
public static final int SYNCHRONOUS_MODE
public static final int NOT_LISTENING
public static final int DEF_BACKLOG
public static final int DEF_SOCKETDELAY
public static final String DEF_BUFFERSIZE_STR
public static final int DEF_BUFFERSIZE
public static final int DEF_MAX_PDU_LENGTH
public static final String TLS_RSA_WITH_NULL_SHA
public static final String TLS_RSA_WITH_3DES_EDE_CBC_SHA
public static final String TLS_RSA_WITH_AES_128_CBC_SHA
private static final String[] DEFAULT_TLS_PROTOCOLS
private String commonName
private String bindAddress
private String clientBindAddress
private int port
private int backlog
private int connectTimeout
private int requestTimeout
private int acceptTimeout
private int releaseTimeout
private int responseTimeout
private int retrieveTimeout
private int idleTimeout
private int socketTimeout
private int socketCloseDelay
private int sendBufferSize
private int receiveBufferSize
private int sendPDULength
private int receivePDULength
private int maxOpsPerformed
private int maxOpsInvoked
private boolean packPDV
private boolean tcpNoDelay
private boolean tlsNeedClientAuth
private String[] tlsCipherSuites
private String httpProxyProviderName
private String httpProxyProviderVersion
private String[] tlsProtocols
private Boolean connectionInstalled
private Map<Class<? extends ConnectionExtension>,ConnectionExtension> extensions
private Connection.Protocol protocol
private static final EnumMap<Connection.Protocol,TCPProtocolHandler> tcpHandlers
private static final EnumMap<Connection.Protocol,UDPProtocolHandler> udpHandlers
private transient List<InetAddress> blacklistAddrs
private transient InetAddress hostAddr
private transient InetAddress bindAddr
private transient InetAddress clientBindAddr
private transient boolean rebindNeeded
public Connection()
public Connection(String commonName, String hostname)
public Connection(String commonName, String hostname, int port)
public Connection(String commonName, String hostname, int port, int timeout)
commonName
- hostname
- port
- timeout
- value in seconds to assign to all timeoutspublic static TCPProtocolHandler registerTCPProtocolHandler(Connection.Protocol protocol, TCPProtocolHandler handler)
public static TCPProtocolHandler unregisterTCPProtocolHandler(Connection.Protocol protocol)
public static UDPProtocolHandler registerUDPProtocolHandler(Connection.Protocol protocol, UDPProtocolHandler handler)
public static UDPProtocolHandler unregisterUDPProtocolHandler(Connection.Protocol protocol)
public Device getDevice()
Device
object that this Network Connection belongs
to.public void setDevice(Device device)
Device
object that this Network Connection belongs
to.device
- The owning Device
object.public final String getHostname()
public String getHttpProxyProviderName()
public String getHttpProxyProviderVersion()
public final void setHostname(String hostname)
hostname
- A String containing the host name.public final String getBindAddress()
null
. If null
, bind
listening socket to getHostname()
. This is the default.
The bind address can also include system properties with the ${system.property} syntax, that need to be resolved.
null
public final void setBindAddress(String bindAddress)
null
. If null
, bind
listening socket to getHostname()
.
The bind address can also include system properties with the ${system.property} syntax, that will be resolved.
bindAddress
- Bind address of listening socket or null
public String getClientBindAddress()
"0.0.0.0"
or null
.
If "0.0.0.0"
the system pick up any local ip for outgoing
connections. If null
, bind outgoing connections to
getHostname()
. This is the default.0.0.0.0
or
null
public ProxyManager getProxyManager()
public void setClientBindAddress(String bindAddress)
"0.0.0.0"
or null
.
If "0.0.0.0"
the system pick up any local ip for outgoing
connections. If null
, bind outgoing connections to
getHostname()
.bindAddress
- Bind address of outgoing connection or null
public Connection.Protocol getProtocol()
public void setProtocol(Connection.Protocol protocol)
boolean isRebindNeeded()
void needRebind()
public final String getCommonName()
public final void setCommonName(String name)
name
- A String containing the name.public final int getPort()
-1
for a
network connection that only initiates associations.-1
.public final void setPort(int port)
0
for a
network connection that only initiates associations.
A valid port value is between 0 and 65535.
port
- The port number or -1
.public Map<Class<? extends ConnectionExtension>,ConnectionExtension> getExtensions()
public void setExtensions(Map<Class<? extends ConnectionExtension>,ConnectionExtension> extensions)
public <T> T getExtension(Class<T> clazz)
public void addExtension(ConnectionExtension connectionExtension)
public void setHttpProxyProviderName(String httpProxyProviderName)
public void setHttpProxyProviderVersion(String httpProxyProviderVersion)
private void reconfigureExtensions(Connection from)
public final String getHttpProxy()
public final void setHttpProxy(String proxy)
public final boolean useHttpProxy()
public final boolean isServer()
public final int getBacklog()
public final void setBacklog(int backlog)
public final int getConnectTimeout()
public final void setConnectTimeout(int timeout)
public final int getRequestTimeout()
public final void setRequestTimeout(int timeout)
timeout
- An int value containing the milliseconds.public final int getAcceptTimeout()
public final void setAcceptTimeout(int timeout)
public final int getReleaseTimeout()
public final void setReleaseTimeout(int timeout)
timeout
- An int value containing the milliseconds.public final int getSocketCloseDelay()
public final void setSocketCloseDelay(int delay)
delay
- An int value containing the milliseconds.public final void setResponseTimeout(int timeout)
public final int getResponseTimeout()
public final int getRetrieveTimeout()
public final void setRetrieveTimeout(int timeout)
public final int getIdleTimeout()
public final void setIdleTimeout(int idleTimeout)
public final int getSocketTimeout()
public final void setSocketTimeout(int socketTimeout)
public String[] getTlsCipherSuites()
public void setTlsCipherSuites(String... tlsCipherSuites)
tlsCipherSuites
- A String array containing the supported cipher suitespublic final boolean isTls()
public final String[] tlsProtocols()
public final String[] getTlsProtocols()
public final void setTlsProtocols(String... tlsProtocols)
public final boolean isTlsNeedClientAuth()
public final void setTlsNeedClientAuth(boolean tlsNeedClientAuth)
public final int getReceiveBufferSize()
public final void setReceiveBufferSize(int size)
size
- An int value containing the buffer size in KB.public final int getSendBufferSize()
public final void setSendBufferSize(int size)
size
- An int value containing the buffer size in KB.public final int getSendPDULength()
public final void setSendPDULength(int sendPDULength)
public final int getReceivePDULength()
public final void setReceivePDULength(int receivePDULength)
public final int getMaxOpsPerformed()
public final void setMaxOpsPerformed(int maxOpsPerformed)
public final int getMaxOpsInvoked()
public final void setMaxOpsInvoked(int maxOpsInvoked)
public final boolean isPackPDV()
public final void setPackPDV(boolean packPDV)
public final boolean isTcpNoDelay()
public final void setTcpNoDelay(boolean tcpNoDelay)
tcpNoDelay
- boolean True if TCP no delay (disable Nagle's algorithm)
should be used.public boolean isInstalled()
public Boolean getConnectionInstalled()
public void setConnectionInstalled(Boolean installed)
installed
- True if the NetworkConnection is installed on the network.GeneralSecurityException
void rebind() throws IOException, GeneralSecurityException
IOException
GeneralSecurityException
public final String[] getBlacklist()
public final void setBlacklist(String[] blacklist)
blacklist
- the list of IP addresses which should be ignored.public StringBuilder promptTo(StringBuilder sb, String indent)
void setSocketSendOptions(Socket s) throws SocketException
SocketException
private void setReceiveBufferSize(Socket s) throws SocketException
SocketException
void setReceiveBufferSize(ServerSocket ss) throws SocketException
SocketException
public void setReceiveBufferSize(DatagramSocket ds) throws SocketException
SocketException
private InetAddress hostAddr() throws UnknownHostException
UnknownHostException
private InetAddress bindAddr() throws UnknownHostException
UnknownHostException
private InetAddress clientBindAddr() throws UnknownHostException
UnknownHostException
private List<InetAddress> blacklistAddrs()
public InetSocketAddress getEndPoint() throws UnknownHostException
UnknownHostException
public InetSocketAddress getBindPoint() throws UnknownHostException
UnknownHostException
public InetSocketAddress getClientBindPoint() throws UnknownHostException
UnknownHostException
private void checkInstalled()
private void checkCompatible(Connection remoteConn) throws IncompatibleConnectionException
IncompatibleConnectionException
public boolean bind() throws IOException, GeneralSecurityException
IOException
- If there is a problem with the network interaction.GeneralSecurityException
public final boolean isListening()
public boolean isBlackListed(InetAddress ia)
public void unbind()
public Socket connect(Connection remoteConn) throws IOException, IncompatibleConnectionException, GeneralSecurityException
public DatagramSocket createDatagramSocket() throws IOException
IOException
public Listener getListener()
private SSLSocket createTLSSocket(Socket s, Connection remoteConn) throws GeneralSecurityException, IOException
GeneralSecurityException
IOException
public boolean isCompatible(Connection remoteConn)
boolean equalsRDN(Connection other)
public String getOlockHash()
public void setOlockHash(String olockHash)
void reconfigure(Connection from)
Copyright © 2017 dcm4che.org. All rights reserved.