- java.lang.Object
-
- org.snmp4j.transport.AbstractTransportMapping<TcpAddress>
-
- org.snmp4j.transport.TcpTransportMapping<TLSTM.SocketEntry>
-
- org.snmp4j.transport.TLSTM
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,ConnectionOrientedTransportMapping<TcpAddress>,TlsTransportMappingConfig<java.security.cert.X509Certificate>,X509TlsTransportMappingConfig,TransportMapping<TcpAddress>
public class TLSTM extends TcpTransportMapping<TLSTM.SocketEntry> implements X509TlsTransportMappingConfig
TheTLSTMimplements the Transport Layer Security Transport Mapping (TLS-TM) as defined by RFC 5953 with the new IO API andSSLEngine.It uses a single thread for processing incoming and outgoing messages. The thread is started when the
listenmethod is called, or when an outgoing request is sent using thesendMessagemethod.- Since:
- 2.0
- Version:
- 3.5.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classTLSTM.DefaultTLSTMTrustManagerFactory(package private) classTLSTM.ServerThread(package private) classTLSTM.SocketEntry
-
Field Summary
Fields Modifier and Type Field Description private longconnectionTimeoutprivate CounterSupportcounterSupportstatic java.lang.StringDEFAULT_TLSTM_PROTOCOLSThe default supported TLS protocol versions.private java.lang.StringkeyStoreprivate java.lang.StringkeyStorePasswordprivate java.lang.StringlocalCertificateAliasprivate static LogAdapterloggerstatic intMAX_TLS_PAYLOAD_SIZEprivate longnextSessionIDprivate java.security.cert.PKIXRevocationCheckerpkixRevocationCheckerBy default no revocation checksprivate TlsTmSecurityCallbackProxy<java.security.cert.X509Certificate>securityCallbackprivate WorkerTaskserverprivate TLSTM.ServerThreadserverThreadprivate CommonTimersocketCleanerprivate SSLEngineConfiguratorsslEngineConfiguratorstatic intTLS_MAX_FRAGMENT_SIZEprivate inttlsMaxFragmentSizeprivate java.lang.String[]tlsProtocolsprivate TLSTMTrustManagerFactorytrustManagerFactoryprivate java.lang.StringtrustStoreprivate java.lang.StringtrustStorePasswordprivate java.lang.Stringx509CertificateRevocationListURI-
Fields inherited from class org.snmp4j.transport.TcpTransportMapping
openSocketOnSending, serverEnabled, sockets, tcpAddress
-
Fields inherited from class org.snmp4j.transport.AbstractTransportMapping
asyncMsgProcessingSupported, listenWorkerTask, maxInboundMessageSize, suspendedAddresses, transportListener
-
-
Constructor Summary
Constructors Constructor Description TLSTM()Creates a default TCP transport mapping with the server for incoming messages disabled.TLSTM(TlsAddress address)Creates a TLS transport mapping with the server for incoming messages bind to the given address.TLSTM(TlsAddress address, boolean serverEnabled)Creates a TLS transport mapping with the server for incoming messages bind to the given address.TLSTM(TlsTmSecurityCallback<java.security.cert.X509Certificate> securityCallback, TlsAddress serverAddress)Creates a TLS transport mapping that binds to the given address (interface) on the local host.TLSTM(TlsTmSecurityCallback<java.security.cert.X509Certificate> securityCallback, TlsAddress serverAddress, CounterSupport counterSupport)Creates a TLS transport mapping that binds to the given address (interface) on the local host.TLSTM(TlsTmSecurityCallback<java.security.cert.X509Certificate> securityCallback, TlsAddress serverAddress, CounterSupport counterSupport, boolean serverEnabled)Creates a TLS transport mapping that binds to the given address (interface) on the local host.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private voidadjustInNetBuffer(TLSTM.SocketEntry entry, javax.net.ssl.SSLEngineResult result)voidclose()Closes all open sockets and stops the internal server thread that processes messages.protected TlsAddresscreateIncomingAddress(java.net.Socket s)protected SSLEngineConfiguratorensureSslEngineConfigurator()Returns the configuredsetSslEngineConfigurator(SSLEngineConfigurator)or theDefaultSSLEngineConfigurationwhich will then become the configured SSL engine configurator.longgetConnectionTimeout()Gets the connection timeout.CounterSupportgetCounterSupport()java.lang.StringgetKeyStore()java.lang.StringgetKeyStorePassword()TcpAddressgetListenAddress()Returns the address that represents the actual incoming address this transport mapping uses to listen for incoming packets.protected WorkerTaskgetListenerWorkerTask()Gets theWorkerTaskthat is responsible for receiving new messages.java.lang.StringgetLocalCertificateAlias()Gets the certificate alias used for client and server authentication.intgetMaxInboundMessageSize()Gets the inbound buffer size for incoming requests.MessageLengthDecodergetMessageLengthDecoder()Returns theMessageLengthDecoderused by this transport mapping.java.security.cert.PKIXRevocationCheckergetPKIXRevocationChecker()Gets the (optional and possiblynull) revocation checker for the cert path validation of X509 certificates.java.lang.StringgetProtocolVersionPropertyName()Returns the property name that is used by this transport mapping to determine the protocol versions from system properties.java.lang.String[]getProtocolVersions()Return the (D)TLS protocol versions used by this transport mapping.TlsTmSecurityCallback<java.security.cert.X509Certificate>getSecurityCallback()Gets theTlsTmSecurityCallbackassociated with thisTransportMappinghook which is called by the transport mapping to lookup TLS security parameters from external configuration.CommonTimergetSocketCleaner()Gets theCommonTimerthat controls socket cleanup operations.SSLEngineConfiguratorgetSslEngineConfigurator()java.lang.Class<? extends Address>getSupportedAddressClass()Gets the primaryAddressclass that is supported by this transport mapping.TransportTypegetSupportedTransportType()Gets theTransportTypethisTransportMappingsupports depending onTcpTransportMapping.isServerEnabled().intgetTlsMaxFragmentSize()Gets the maximum fragment size of supported for this transport mapping when acting as TLS server.java.lang.String[]getTlsProtocols()Deprecated.UsegetProtocolVersions()instead.TLSTMTrustManagerFactorygetTrustManagerFactory()java.lang.StringgetTrustStore()java.lang.StringgetTrustStorePassword()java.lang.StringgetX509CertificateRevocationListURI()Gets the X509 certificate revocation list (CRL) URI, if defined.protected static booleanisEngineClosed(javax.net.ssl.SSLEngine engine)Check if aSSLEngineis fully closed.booleanisListening()Returnstrueif the transport mapping is listening for incoming messages.voidlisten()Listen for incoming and outgoing requests.private booleanmatchingStateReferences(TransportStateReference tmStateReferenceNew, TransportStateReference tmStateReferenceExisting)voidsendMessage(TcpAddress address, byte[] message, TransportStateReference tmStateReference, long timeoutMillis, int maxRetries)Sends an SNMP message to the supplied address.private javax.net.ssl.SSLEngineResultsendNetMessage(TLSTM.SocketEntry entry)voidsetConnectionTimeout(long connectionTimeout)Sets the connection timeout.voidsetKeyStore(java.lang.String keyStore)voidsetKeyStorePassword(java.lang.String keyStorePassword)voidsetLocalCertificateAlias(java.lang.String localCertificateAlias)Sets the certificate alias used for client and server authentication by this TLSTM.voidsetMaxInboundMessageSize(int maxInboundMessageSize)Sets the maximum buffer size for incoming requests.voidsetMessageLengthDecoder(MessageLengthDecoder messageLengthDecoder)Sets theMessageLengthDecoderthat decodes the total message length from the header of a message.voidsetPKIXRevocationChecker(java.security.cert.PKIXRevocationChecker pkixRevocationChecker)Sets the (optional and possiblynull) revocation checker for the cert path validation of X509 certificates.voidsetProtocolVersions(java.lang.String[] protocolVersions)Sets the TLS protocols/versions that TLSTM should use during handshake.voidsetSecurityCallback(TlsTmSecurityCallback<java.security.cert.X509Certificate> securityCallback)Sets theTlsTmSecurityCallbackassociated with thisTransportMappinghook.voidsetSslEngineConfigurator(SSLEngineConfigurator sslEngineConfigurator)Sets the configurator for theSSLEngineinternally used to run the TLS communication.voidsetTlsMaxFragmentSize(int tlsMaxFragmentSize)Sets the maximum TLS fragment size that this transport mapping should support as server.voidsetTlsProtocols(java.lang.String[] tlsProtocols)Deprecated.UsesetProtocolVersions(String[])instead.voidsetTrustManagerFactory(TLSTMTrustManagerFactory trustManagerFactory)Set the TLSTM trust manager factory.voidsetTrustStore(java.lang.String trustStore)voidsetTrustStorePassword(java.lang.String trustStorePassword)private voidsetupTrustManagerFactory()voidsetX09CertificateRevocationListURI(java.lang.String crlURI)Sets the X509 certificate revocation list (CRL) URI, to enable CRL checking.private voidtimeoutSocket(TLSTM.SocketEntry entry)(package private) voidwriteNetBuffer(TLSTM.SocketEntry entry, java.nio.channels.SocketChannel sc)-
Methods inherited from class org.snmp4j.transport.TcpTransportMapping
addTransportStateListener, cancelNonServerSelectionKey, close, closeSockets, fireConnectionStateChanged, getAddress, getListenWorkerTask, isOpenSocketOnSending, isServerEnabled, removeTransportStateListener, setOpenSocketOnSending, setServerEnabled, setSocketOptions, timeoutSocket
-
Methods inherited from class org.snmp4j.transport.AbstractTransportMapping
addTransportListener, fireProcessMessage, getPriority, getThreadName, handleDroppedMessageToSend, isAsyncMsgProcessingSupported, removeAllTransportListeners, removeTransportListener, resumeAddress, setAsyncMsgProcessingSupported, setPriority, setThreadName, suspendAddress
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.snmp4j.transport.ConnectionOrientedTransportMapping
resumeAddress, suspendAddress
-
Methods inherited from interface org.snmp4j.TransportMapping
addTransportListener, getSupportedAddressClasses, isAddressSupported, isAddressSupported, removeTransportListener
-
-
-
-
Field Detail
-
logger
private static final LogAdapter logger
-
TLS_MAX_FRAGMENT_SIZE
public static final int TLS_MAX_FRAGMENT_SIZE
- See Also:
- Constant Field Values
-
server
private WorkerTask server
-
serverThread
private TLSTM.ServerThread serverThread
-
socketCleaner
private CommonTimer socketCleaner
-
connectionTimeout
private long connectionTimeout
-
nextSessionID
private long nextSessionID
-
sslEngineConfigurator
private SSLEngineConfigurator sslEngineConfigurator
-
securityCallback
private final TlsTmSecurityCallbackProxy<java.security.cert.X509Certificate> securityCallback
-
counterSupport
private CounterSupport counterSupport
-
DEFAULT_TLSTM_PROTOCOLS
public static final java.lang.String DEFAULT_TLSTM_PROTOCOLS
The default supported TLS protocol versions.- See Also:
- Constant Field Values
-
MAX_TLS_PAYLOAD_SIZE
public static final int MAX_TLS_PAYLOAD_SIZE
- See Also:
- Constant Field Values
-
localCertificateAlias
private java.lang.String localCertificateAlias
-
keyStore
private java.lang.String keyStore
-
keyStorePassword
private java.lang.String keyStorePassword
-
trustStore
private java.lang.String trustStore
-
trustStorePassword
private java.lang.String trustStorePassword
-
tlsProtocols
private java.lang.String[] tlsProtocols
-
trustManagerFactory
private TLSTMTrustManagerFactory trustManagerFactory
-
tlsMaxFragmentSize
private int tlsMaxFragmentSize
-
pkixRevocationChecker
private java.security.cert.PKIXRevocationChecker pkixRevocationChecker
By default no revocation checks
-
x509CertificateRevocationListURI
private java.lang.String x509CertificateRevocationListURI
-
-
Constructor Detail
-
TLSTM
public TLSTM() throws java.net.UnknownHostExceptionCreates a default TCP transport mapping with the server for incoming messages disabled.- Throws:
java.net.UnknownHostException- if the local host cannot be determined.
-
TLSTM
public TLSTM(TlsAddress address) throws java.io.IOException
Creates a TLS transport mapping with the server for incoming messages bind to the given address. ThesecurityCallbackneeds to be specified beforelisten()is called.- Parameters:
address- the address to bind for incoming requests.- Throws:
java.io.IOException- on failure of binding a local port.
-
TLSTM
public TLSTM(TlsAddress address, boolean serverEnabled) throws java.io.IOException
Creates a TLS transport mapping with the server for incoming messages bind to the given address. ThesecurityCallbackneeds to be specified beforelisten()is called.- Parameters:
address- the address to bind for incoming requests.serverEnabled- defines the role of the underlyingSSLEngine. Setting this tofalseenables theSSLEngine.setUseClientMode(boolean).- Throws:
java.io.IOException- on failure of binding a local port.- Since:
- 3.2.0
-
TLSTM
public TLSTM(TlsTmSecurityCallback<java.security.cert.X509Certificate> securityCallback, TlsAddress serverAddress) throws java.io.IOException
Creates a TLS transport mapping that binds to the given address (interface) on the local host.- Parameters:
securityCallback- a security name callback to resolve X509 certificates to tmSecurityNames.serverAddress- the TcpAddress instance that describes the server address to listen on incoming connection requests.- Throws:
java.io.IOException- if the given address cannot be bound.
-
TLSTM
public TLSTM(TlsTmSecurityCallback<java.security.cert.X509Certificate> securityCallback, TlsAddress serverAddress, CounterSupport counterSupport) throws java.io.IOException
Creates a TLS transport mapping that binds to the given address (interface) on the local host.- Parameters:
securityCallback- a security name callback to resolve X509 certificates to tmSecurityNames.serverAddress- the TcpAddress instance that describes the server address to listen on incoming connection requests.counterSupport- The CounterSupport instance to be used to count events created by this TLSTM instance. To get a default instance, useCounterSupport.getInstance().- Throws:
java.io.IOException- if the given address cannot be bound.
-
TLSTM
public TLSTM(TlsTmSecurityCallback<java.security.cert.X509Certificate> securityCallback, TlsAddress serverAddress, CounterSupport counterSupport, boolean serverEnabled) throws java.io.IOException
Creates a TLS transport mapping that binds to the given address (interface) on the local host.- Parameters:
securityCallback- a security name callback to resolve X509 certificates to tmSecurityNames.serverAddress- the TcpAddress instance that describes the server address to listen on incoming connection requests.counterSupport- The CounterSupport instance to be used to count events created by this TLSTM instance. To get a default instance, useCounterSupport.getInstance().serverEnabled- defines the role of the underlyingSSLEngine. Setting this tofalseenables theSSLEngine.setUseClientMode(boolean).- Throws:
java.io.IOException- if the given address cannot be bound.- Since:
- 3.2.0
-
-
Method Detail
-
setupTrustManagerFactory
private void setupTrustManagerFactory() throws java.io.IOException- Throws:
java.io.IOException
-
getLocalCertificateAlias
public java.lang.String getLocalCertificateAlias()
Description copied from interface:TlsTransportMappingConfigGets the certificate alias used for client and server authentication. See alsoTlsTransportMappingConfig.setLocalCertificateAlias(java.lang.String)- Specified by:
getLocalCertificateAliasin interfaceTlsTransportMappingConfig<java.security.cert.X509Certificate>- Returns:
- the certificate alias selecting the local certificate.
-
getSupportedTransportType
public TransportType getSupportedTransportType()
Gets theTransportTypethisTransportMappingsupports depending onTcpTransportMapping.isServerEnabled().- Specified by:
getSupportedTransportTypein interfaceTransportMapping<TcpAddress>- Returns:
TransportType.anyifTcpTransportMapping.isServerEnabled()istrueandTransportType.senderotherwise.- Since:
- 3.2.0
-
getTlsMaxFragmentSize
public int getTlsMaxFragmentSize()
Gets the maximum fragment size of supported for this transport mapping when acting as TLS server.- Returns:
- the maximum TLS fragment size as defined by RFC 6066 section 4.
-
setTlsMaxFragmentSize
public void setTlsMaxFragmentSize(int tlsMaxFragmentSize)
Sets the maximum TLS fragment size that this transport mapping should support as server. There is no need to change that from the defaultTLS_MAX_FRAGMENT_SIZEunless, a new Java version allows to set the maximum fragment size to a lower value.- Parameters:
tlsMaxFragmentSize- a value as defined by RFC 6066 section 4.- Since:
- 3.0.5
-
getTlsProtocols
@Deprecated public java.lang.String[] getTlsProtocols()
Deprecated.UsegetProtocolVersions()instead.Gets the TLS protocols supported by this transport mapping.- Returns:
- an array of TLS protocol (version) names supported by the SunJSSE provider.
-
setTlsProtocols
@Deprecated public void setTlsProtocols(java.lang.String[] tlsProtocols)
Deprecated.UsesetProtocolVersions(String[])instead.Sets the TLS protocols/versions that TLSTM should use during handshake. The default is defined byDEFAULT_TLSTM_PROTOCOLS.- Parameters:
tlsProtocols- an array of TLS protocol (version) names supported by the SunJSSE provider. The order in the array defines which protocol is tried during handshake first.- Since:
- 2.0.3
-
setProtocolVersions
public void setProtocolVersions(java.lang.String[] protocolVersions)
Sets the TLS protocols/versions that TLSTM should use during handshake. The default is defined byDEFAULT_TLSTM_PROTOCOLS.- Specified by:
setProtocolVersionsin interfaceTlsTransportMappingConfig<java.security.cert.X509Certificate>- Parameters:
protocolVersions- an array of TLS protocol (version) names supported by the SunJSSE provider. The order in the array defines which protocol is tried during handshake first.- Since:
- 3.0
-
getProtocolVersions
public java.lang.String[] getProtocolVersions()
Description copied from interface:TlsTransportMappingConfigReturn the (D)TLS protocol versions used by this transport mapping.- Specified by:
getProtocolVersionsin interfaceTlsTransportMappingConfig<java.security.cert.X509Certificate>- Returns:
- an array of SunJSSE TLS/DTLS provider (depending on the transport mapping type).
-
getProtocolVersionPropertyName
public java.lang.String getProtocolVersionPropertyName()
Returns the property name that is used by this transport mapping to determine the protocol versions from system properties.- Specified by:
getProtocolVersionPropertyNamein interfaceTlsTransportMappingConfig<java.security.cert.X509Certificate>- Returns:
- a property name like
SnmpConfigurator.P_TLS_VERSIONorSnmpConfigurator.P_DTLS_VERSION. - Since:
- 3.0
-
getKeyStore
public java.lang.String getKeyStore()
- Specified by:
getKeyStorein interfaceTlsTransportMappingConfig<java.security.cert.X509Certificate>
-
setKeyStore
public void setKeyStore(java.lang.String keyStore)
- Specified by:
setKeyStorein interfaceTlsTransportMappingConfig<java.security.cert.X509Certificate>
-
getKeyStorePassword
public java.lang.String getKeyStorePassword()
- Specified by:
getKeyStorePasswordin interfaceTlsTransportMappingConfig<java.security.cert.X509Certificate>
-
setKeyStorePassword
public void setKeyStorePassword(java.lang.String keyStorePassword)
- Specified by:
setKeyStorePasswordin interfaceTlsTransportMappingConfig<java.security.cert.X509Certificate>
-
getTrustStore
public java.lang.String getTrustStore()
- Specified by:
getTrustStorein interfaceTlsTransportMappingConfig<java.security.cert.X509Certificate>
-
setTrustStore
public void setTrustStore(java.lang.String trustStore)
- Specified by:
setTrustStorein interfaceTlsTransportMappingConfig<java.security.cert.X509Certificate>
-
getTrustStorePassword
public java.lang.String getTrustStorePassword()
- Specified by:
getTrustStorePasswordin interfaceTlsTransportMappingConfig<java.security.cert.X509Certificate>
-
setTrustStorePassword
public void setTrustStorePassword(java.lang.String trustStorePassword)
- Specified by:
setTrustStorePasswordin interfaceTlsTransportMappingConfig<java.security.cert.X509Certificate>
-
setLocalCertificateAlias
public void setLocalCertificateAlias(java.lang.String localCertificateAlias)
Sets the certificate alias used for client and server authentication by this TLSTM. Setting this property to a value other thannullfilters out any certificates which are not in the chain of the given alias.- Specified by:
setLocalCertificateAliasin interfaceTlsTransportMappingConfig<java.security.cert.X509Certificate>- Parameters:
localCertificateAlias- a certificate alias which filters a single certification chain from thejavax.net.ssl.keyStorekey store to be used to authenticate this TLS transport mapping. Ifnullno filtering appears, which could lead to more than a single chain available for authentication by the peer, which would violate the TLSTM standard requirements.
-
getCounterSupport
public CounterSupport getCounterSupport()
-
getSupportedAddressClass
public java.lang.Class<? extends Address> getSupportedAddressClass()
Description copied from interface:TransportMappingGets the primaryAddressclass that is supported by this transport mapping.- Specified by:
getSupportedAddressClassin interfaceTransportMapping<TcpAddress>- Overrides:
getSupportedAddressClassin classTcpTransportMapping<TLSTM.SocketEntry>- Returns:
- a subclass of
Address.
-
getSecurityCallback
public TlsTmSecurityCallback<java.security.cert.X509Certificate> getSecurityCallback()
Description copied from interface:TlsTransportMappingConfigGets theTlsTmSecurityCallbackassociated with thisTransportMappinghook which is called by the transport mapping to lookup TLS security parameters from external configuration.- Specified by:
getSecurityCallbackin interfaceTlsTransportMappingConfig<java.security.cert.X509Certificate>- Returns:
- a
TlsTmSecurityCallbackinstance.
-
setSecurityCallback
public void setSecurityCallback(TlsTmSecurityCallback<java.security.cert.X509Certificate> securityCallback)
Description copied from interface:TlsTransportMappingConfigSets theTlsTmSecurityCallbackassociated with thisTransportMappinghook. This hook will be called to lookup the security name based on the TLS peer certificate, for example. SeeTlsTmSecurityCallbackfor details.- Specified by:
setSecurityCallbackin interfaceTlsTransportMappingConfig<java.security.cert.X509Certificate>- Parameters:
securityCallback- aTlsTmSecurityCallbackinstance. Setting this hook tonullwill disable incoming request processing because these request will be rejected due to an authorization error (no mathing SNMPv3 view).
-
getSslEngineConfigurator
public SSLEngineConfigurator getSslEngineConfigurator()
-
setSslEngineConfigurator
public void setSslEngineConfigurator(SSLEngineConfigurator sslEngineConfigurator)
Sets the configurator for theSSLEngineinternally used to run the TLS communication. This method should be called before any new connection is established that should use this configurator/configuration.- Parameters:
sslEngineConfigurator- aSSLEngineConfiguratorinstance likeDefaultSSLEngineConfiguration.- Since:
- 3.0.5
-
getTrustManagerFactory
public TLSTMTrustManagerFactory getTrustManagerFactory()
-
setTrustManagerFactory
public void setTrustManagerFactory(TLSTMTrustManagerFactory trustManagerFactory)
Set the TLSTM trust manager factory. Using a trust manager factory other than the default allows to add support for Java 1.7 X509ExtendedTrustManager.- Parameters:
trustManagerFactory- a X.509 trust manager factory implementing the interfaceTLSTMTrustManagerFactory.- Since:
- 2.0.3
-
listen
public void listen() throws java.io.IOExceptionListen for incoming and outgoing requests. If theserverEnabledmember isfalsethe server for incoming requests is not started. This starts the internal server thread that processes messages.- Specified by:
listenin interfaceTransportMapping<TcpAddress>- Specified by:
listenin classTcpTransportMapping<TLSTM.SocketEntry>- Throws:
java.net.SocketException- when the transport is already listening for incoming/outgoing messages.java.io.IOException- if the listen port could not be bound to the server thread.
-
getListenerWorkerTask
protected WorkerTask getListenerWorkerTask()
Description copied from class:AbstractTransportMappingGets theWorkerTaskthat is responsible for receiving new messages.- Specified by:
getListenerWorkerTaskin classAbstractTransportMapping<TcpAddress>- Returns:
- a
WorkerTaskinstance which is most likely aDefaultThreadFactory.WorkerThread.
-
close
public void close()
Closes all open sockets and stops the internal server thread that processes messages.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein interfaceTransportMapping<TcpAddress>- Specified by:
closein classTcpTransportMapping<TLSTM.SocketEntry>
-
sendMessage
public void sendMessage(TcpAddress address, byte[] message, TransportStateReference tmStateReference, long timeoutMillis, int maxRetries) throws java.io.IOException
Sends an SNMP message to the supplied address.- Specified by:
sendMessagein interfaceTransportMapping<TcpAddress>- Specified by:
sendMessagein classTcpTransportMapping<TLSTM.SocketEntry>- Parameters:
address- anTcpAddress. AClassCastExceptionis thrown ifaddressis not aTcpAddressinstance.message- byte[] the message to sent.tmStateReference- the (optional) transport model state reference as defined by RFC 5590 section 6.1.timeoutMillis- maximum number of milli seconds the connection creation might take (if connection based).maxRetries- maximum retries during connection creation.- Throws:
java.io.IOException- if an IO exception occurs while trying to send the message.
-
getConnectionTimeout
public long getConnectionTimeout()
Gets the connection timeout. This timeout specifies the time a connection may be idle before it is closed.- Specified by:
getConnectionTimeoutin interfaceConnectionOrientedTransportMapping<TcpAddress>- Overrides:
getConnectionTimeoutin classTcpTransportMapping<TLSTM.SocketEntry>- Returns:
- long the idle timeout in milliseconds.
-
setConnectionTimeout
public void setConnectionTimeout(long connectionTimeout)
Sets the connection timeout. This timeout specifies the time a connection may be idle before it is closed.- Specified by:
setConnectionTimeoutin interfaceConnectionOrientedTransportMapping<TcpAddress>- Overrides:
setConnectionTimeoutin classTcpTransportMapping<TLSTM.SocketEntry>- Parameters:
connectionTimeout- the idle timeout in milliseconds. A zero or negative value will disable any timeout and connections opened by this transport mapping will stay opened until they are explicitly closed.
-
getSocketCleaner
public CommonTimer getSocketCleaner()
Gets theCommonTimerthat controls socket cleanup operations.- Specified by:
getSocketCleanerin interfaceConnectionOrientedTransportMapping<TcpAddress>- Returns:
- a socket cleaner timer.
- Since:
- 3.0
-
getMessageLengthDecoder
public MessageLengthDecoder getMessageLengthDecoder()
Description copied from class:TcpTransportMappingReturns theMessageLengthDecoderused by this transport mapping.- Specified by:
getMessageLengthDecoderin interfaceConnectionOrientedTransportMapping<TcpAddress>- Specified by:
getMessageLengthDecoderin classTcpTransportMapping<TLSTM.SocketEntry>- Returns:
- a MessageLengthDecoder instance.
-
setMessageLengthDecoder
public void setMessageLengthDecoder(MessageLengthDecoder messageLengthDecoder)
Description copied from class:TcpTransportMappingSets theMessageLengthDecoderthat decodes the total message length from the header of a message.- Specified by:
setMessageLengthDecoderin interfaceConnectionOrientedTransportMapping<TcpAddress>- Specified by:
setMessageLengthDecoderin classTcpTransportMapping<TLSTM.SocketEntry>- Parameters:
messageLengthDecoder- a MessageLengthDecoder instance.
-
getMaxInboundMessageSize
public int getMaxInboundMessageSize()
Gets the inbound buffer size for incoming requests. When SNMP packets are received that are longer than this maximum size, the messages will be silently dropped and the connection will be closed.- Specified by:
getMaxInboundMessageSizein interfaceTransportMapping<TcpAddress>- Overrides:
getMaxInboundMessageSizein classAbstractTransportMapping<TcpAddress>- Returns:
- the maximum inbound buffer size in bytes.
-
setMaxInboundMessageSize
public void setMaxInboundMessageSize(int maxInboundMessageSize)
Sets the maximum buffer size for incoming requests. When SNMP packets are received that are longer than this maximum size, the messages will be silently dropped and the connection will be closed.- Parameters:
maxInboundMessageSize- the length of the inbound buffer in bytes.
-
getPKIXRevocationChecker
public java.security.cert.PKIXRevocationChecker getPKIXRevocationChecker()
Description copied from interface:X509TlsTransportMappingConfigGets the (optional and possiblynull) revocation checker for the cert path validation of X509 certificates.- Specified by:
getPKIXRevocationCheckerin interfaceX509TlsTransportMappingConfig- Returns:
nullto disable cert path validation with CLR checking or a properly configured cert path checker instance.
-
setPKIXRevocationChecker
public void setPKIXRevocationChecker(java.security.cert.PKIXRevocationChecker pkixRevocationChecker)
Description copied from interface:X509TlsTransportMappingConfigSets the (optional and possiblynull) revocation checker for the cert path validation of X509 certificates.- Specified by:
setPKIXRevocationCheckerin interfaceX509TlsTransportMappingConfig- Parameters:
pkixRevocationChecker-nullto disable cert path validation with CLR checking or a properly configured cert path checker instance.
-
getX509CertificateRevocationListURI
public java.lang.String getX509CertificateRevocationListURI()
Description copied from interface:X509TlsTransportMappingConfigGets the X509 certificate revocation list (CRL) URI, if defined.- Specified by:
getX509CertificateRevocationListURIin interfaceX509TlsTransportMappingConfig- Returns:
nullif there is no CRL available/necessary or a URI string that points to a CRL file.
-
setX09CertificateRevocationListURI
public void setX09CertificateRevocationListURI(java.lang.String crlURI)
Description copied from interface:X509TlsTransportMappingConfigSets the X509 certificate revocation list (CRL) URI, to enable CRL checking.- Specified by:
setX09CertificateRevocationListURIin interfaceX509TlsTransportMappingConfig- Parameters:
crlURI-nullif there is no CRL available/necessary or a URI string that points to a CRL file.
-
timeoutSocket
private void timeoutSocket(TLSTM.SocketEntry entry)
-
isListening
public boolean isListening()
Description copied from interface:TransportMappingReturnstrueif the transport mapping is listening for incoming messages. For connection oriented transport mappings this is a prerequisite to be able to send SNMP messages. For connectionless transport mappings it is a prerequisite to be able to receive responses.- Specified by:
isListeningin interfaceTransportMapping<TcpAddress>- Overrides:
isListeningin classAbstractTransportMapping<TcpAddress>- Returns:
trueif this transport mapping is listening for messages.
-
createIncomingAddress
protected TlsAddress createIncomingAddress(java.net.Socket s)
-
getListenAddress
public TcpAddress getListenAddress()
Description copied from interface:TransportMappingReturns the address that represents the actual incoming address this transport mapping uses to listen for incoming packets.- Specified by:
getListenAddressin interfaceTransportMapping<TcpAddress>- Overrides:
getListenAddressin classTcpTransportMapping<TLSTM.SocketEntry>- Returns:
- the address for incoming packets or
nullthis transport mapping is not configured to listen for incoming packets.
-
isEngineClosed
protected static boolean isEngineClosed(javax.net.ssl.SSLEngine engine)
Check if aSSLEngineis fully closed.- Parameters:
engine- an SSL engine.- Returns:
trueif inbound and outbound is done and .
-
ensureSslEngineConfigurator
protected SSLEngineConfigurator ensureSslEngineConfigurator()
Returns the configuredsetSslEngineConfigurator(SSLEngineConfigurator)or theDefaultSSLEngineConfigurationwhich will then become the configured SSL engine configurator. This method is not synchronized against concurrent execution ofsetSslEngineConfigurator(SSLEngineConfigurator).- Returns:
- a non-null
SSLEngineConfigurator. - Since:
- 3.0.5
-
writeNetBuffer
void writeNetBuffer(TLSTM.SocketEntry entry, java.nio.channels.SocketChannel sc) throws java.io.IOException
- Throws:
java.io.IOException
-
matchingStateReferences
private boolean matchingStateReferences(TransportStateReference tmStateReferenceNew, TransportStateReference tmStateReferenceExisting)
-
sendNetMessage
private javax.net.ssl.SSLEngineResult sendNetMessage(TLSTM.SocketEntry entry) throws java.io.IOException
- Throws:
java.io.IOException
-
adjustInNetBuffer
private void adjustInNetBuffer(TLSTM.SocketEntry entry, javax.net.ssl.SSLEngineResult result)
-
-