From a2144d09d399276d083abf25f659835bee1fbe5d Mon Sep 17 00:00:00 2001 From: Szymon Sasin Date: Fri, 18 Aug 2023 13:32:03 +0300 Subject: [PATCH] Remove redundant getSessionCid method --- .../kotlin/org/opencoap/ssl/transport/DtlsServer.kt | 4 ---- .../org/opencoap/ssl/transport/DtlsServerTransport.kt | 2 -- .../opencoap/ssl/transport/DtlsServerTransportTest.kt | 10 ---------- 3 files changed, 16 deletions(-) diff --git a/kotlin-mbedtls/src/main/kotlin/org/opencoap/ssl/transport/DtlsServer.kt b/kotlin-mbedtls/src/main/kotlin/org/opencoap/ssl/transport/DtlsServer.kt index a379f57b..3beff7a9 100644 --- a/kotlin-mbedtls/src/main/kotlin/org/opencoap/ssl/transport/DtlsServer.kt +++ b/kotlin-mbedtls/src/main/kotlin/org/opencoap/ssl/transport/DtlsServer.kt @@ -50,10 +50,6 @@ class DtlsServer( private val sessions = mutableMapOf() private val cidSize = sslConfig.cidSupplier.next().size val numberOfSessions get() = sessions.size - fun getSessionCid(inet: InetSocketAddress): ByteArray? { - val dtlsState = sessions[inet] as? DtlsSession - return dtlsState?.sessionContext?.cid - } fun handleReceived(adr: InetSocketAddress, buf: ByteBuffer): ReceiveResult { val cid by lazy { SslContext.peekCID(cidSize, buf) } diff --git a/kotlin-mbedtls/src/main/kotlin/org/opencoap/ssl/transport/DtlsServerTransport.kt b/kotlin-mbedtls/src/main/kotlin/org/opencoap/ssl/transport/DtlsServerTransport.kt index ab60541e..5ca80aa7 100644 --- a/kotlin-mbedtls/src/main/kotlin/org/opencoap/ssl/transport/DtlsServerTransport.kt +++ b/kotlin-mbedtls/src/main/kotlin/org/opencoap/ssl/transport/DtlsServerTransport.kt @@ -114,6 +114,4 @@ class DtlsServerTransport private constructor( executor.supply { dtlsServer.putSessionAuthenticationContext(adr, key, value) } - - fun getSessionCid(adr: InetSocketAddress) = executor.supply { dtlsServer.getSessionCid(adr) } } diff --git a/kotlin-mbedtls/src/test/kotlin/org/opencoap/ssl/transport/DtlsServerTransportTest.kt b/kotlin-mbedtls/src/test/kotlin/org/opencoap/ssl/transport/DtlsServerTransportTest.kt index 6fea7730..887db82d 100644 --- a/kotlin-mbedtls/src/test/kotlin/org/opencoap/ssl/transport/DtlsServerTransportTest.kt +++ b/kotlin-mbedtls/src/test/kotlin/org/opencoap/ssl/transport/DtlsServerTransportTest.kt @@ -24,7 +24,6 @@ import org.awaitility.kotlin.await import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertFalse -import org.junit.jupiter.api.Assertions.assertNull import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Test import org.opencoap.ssl.CertificateAuth @@ -438,15 +437,6 @@ class DtlsServerTransportTest { assertTrue(server.executor() is ScheduledThreadPoolExecutor) } - @Test - fun `should not return cid`() { - server = DtlsServerTransport.create(conf, lifecycleCallbacks = sslLifecycleCallbacks).listen(echoHandler) - val client = DtlsTransmitter.connect(server, clientConfig).await() - client.send("hello!") - val cid = server.getSessionCid(localAddress(1234)).await() - assertNull(cid) - } - @Test fun `should set and use session context`() { // given