1
1
/*
2
- * Copyright (c) 2015, 2020 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2015, 2021 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
50
50
*/
51
51
public class DTLSOverDatagram {
52
52
53
- private static int MAX_HANDSHAKE_LOOPS = 200 ;
54
- private static int MAX_APP_READ_LOOPS = 60 ;
55
- private static int SOCKET_TIMEOUT = 10 * 1000 ; // in millis
56
- private static int BUFFER_SIZE = 1024 ;
57
- private static int MAXIMUM_PACKET_SIZE = 1024 ;
53
+ private static final int MAX_HANDSHAKE_LOOPS = 200 ;
54
+ private static final int MAX_APP_READ_LOOPS = 60 ;
55
+ private static final int SOCKET_TIMEOUT = 10 * 1000 ; // in millis
56
+ private static final int BUFFER_SIZE = 1024 ;
57
+ private static final int MAXIMUM_PACKET_SIZE = 1024 ;
58
58
59
59
/*
60
60
* The following is to set up the keystores.
61
61
*/
62
- private static String pathToStores = "../etc" ;
63
- private static String keyStoreFile = "keystore" ;
64
- private static String trustStoreFile = "truststore" ;
65
-
66
- private static String keyFilename =
67
- System .getProperty ("test.src" , "." ) + "/" + pathToStores +
68
- "/" + keyStoreFile ;
69
- private static String trustFilename =
70
- System .getProperty ("test.src" , "." ) + "/" + pathToStores +
71
- "/" + trustStoreFile ;
72
- private static Exception clientException = null ;
73
- private static Exception serverException = null ;
74
-
75
- private static ByteBuffer serverApp =
62
+ private static final String PATH_TO_STORES = "../etc" ;
63
+ private static final String KEY_STORE_FILE = "keystore" ;
64
+ private static final String TRUST_STORE_FILE = "truststore" ;
65
+
66
+ private static final String KEY_FILENAME =
67
+ System .getProperty ("test.src" , "." ) + "/" + PATH_TO_STORES +
68
+ "/" + KEY_STORE_FILE ;
69
+ private static final String TRUST_FILENAME =
70
+ System .getProperty ("test.src" , "." ) + "/" + PATH_TO_STORES +
71
+ "/" + TRUST_STORE_FILE ;
72
+
73
+ private static final ByteBuffer SERVER_APP =
76
74
ByteBuffer .wrap ("Hi Client, I'm Server" .getBytes ());
77
- private static ByteBuffer clientApp =
75
+ private static final ByteBuffer CLIENT_APP =
78
76
ByteBuffer .wrap ("Hi Server, I'm Client" .getBytes ());
79
77
78
+ private static Exception clientException = null ;
79
+ private static Exception serverException = null ;
80
80
/*
81
81
* =============================================================
82
82
* The test case
@@ -91,37 +91,39 @@ public static void main(String[] args) throws Exception {
91
91
*/
92
92
void doServerSide (DatagramSocket socket , InetSocketAddress clientSocketAddr )
93
93
throws Exception {
94
+ String side = "Server" ;
94
95
95
96
// create SSLEngine
96
97
SSLEngine engine = createSSLEngine (false );
97
98
98
99
// handshaking
99
- handshake (engine , socket , clientSocketAddr , "Server" );
100
+ handshake (engine , socket , clientSocketAddr , side );
100
101
101
102
// read client application data
102
- receiveAppData (engine , socket , clientApp );
103
+ receiveAppData (engine , socket , CLIENT_APP );
103
104
104
105
// write server application data
105
- deliverAppData (engine , socket , serverApp , clientSocketAddr );
106
+ deliverAppData (engine , socket , SERVER_APP , clientSocketAddr , side );
106
107
}
107
108
108
109
/*
109
110
* Define the client side of the test.
110
111
*/
111
112
void doClientSide (DatagramSocket socket , InetSocketAddress serverSocketAddr )
112
113
throws Exception {
114
+ String side = "Client" ;
113
115
114
116
// create SSLEngine
115
117
SSLEngine engine = createSSLEngine (true );
116
118
117
119
// handshaking
118
- handshake (engine , socket , serverSocketAddr , "Client" );
120
+ handshake (engine , socket , serverSocketAddr , side );
119
121
120
122
// write client application data
121
- deliverAppData (engine , socket , clientApp , serverSocketAddr );
123
+ deliverAppData (engine , socket , CLIENT_APP , serverSocketAddr , side );
122
124
123
125
// read server application data
124
- receiveAppData (engine , socket , serverApp );
126
+ receiveAppData (engine , socket , SERVER_APP );
125
127
}
126
128
127
129
/*
@@ -153,117 +155,94 @@ void handshake(SSLEngine engine, DatagramSocket socket,
153
155
154
156
if (--loops < 0 ) {
155
157
throw new RuntimeException (
156
- "Too much loops to produce handshake packets" );
158
+ "Too many loops to produce handshake packets" );
157
159
}
158
160
159
161
SSLEngineResult .HandshakeStatus hs = engine .getHandshakeStatus ();
160
162
log (side , "=======handshake(" + loops + ", " + hs + ")=======" );
161
- if (hs == SSLEngineResult .HandshakeStatus .NEED_UNWRAP ||
162
- hs == SSLEngineResult .HandshakeStatus .NEED_UNWRAP_AGAIN ) {
163
-
164
- log (side , "Receive DTLS records, handshake status is " + hs );
165
-
166
- ByteBuffer iNet ;
167
- ByteBuffer iApp ;
168
- if (hs == SSLEngineResult .HandshakeStatus .NEED_UNWRAP ) {
169
- byte [] buf = new byte [BUFFER_SIZE ];
170
- DatagramPacket packet = new DatagramPacket (buf , buf .length );
171
- try {
172
- socket .receive (packet );
173
- } catch (SocketTimeoutException ste ) {
174
- log (side , "Warning: " + ste );
175
-
176
- List <DatagramPacket > packets = new ArrayList <>();
177
- boolean finished = onReceiveTimeout (
178
- engine , peerAddr , side , packets );
179
-
180
- log (side , "Reproduced " + packets .size () + " packets" );
181
- for (DatagramPacket p : packets ) {
182
- printHex ("Reproduced packet" ,
183
- p .getData (), p .getOffset (), p .getLength ());
184
- socket .send (p );
185
- }
186
163
187
- if (finished ) {
188
- log (side , "Handshake status is FINISHED "
189
- + "after calling onReceiveTimeout(), "
190
- + "finish the loop" );
191
- endLoops = true ;
164
+ switch (hs ) {
165
+ case NEED_UNWRAP , NEED_UNWRAP_AGAIN -> {
166
+ log (side , "Receive DTLS records, handshake status is " + hs );
167
+
168
+ ByteBuffer iNet ;
169
+ ByteBuffer iApp ;
170
+
171
+ if (hs == SSLEngineResult .HandshakeStatus .NEED_UNWRAP ) {
172
+ byte [] buf = new byte [BUFFER_SIZE ];
173
+ DatagramPacket packet = new DatagramPacket (buf , buf .length );
174
+ try {
175
+ socket .receive (packet );
176
+ } catch (SocketTimeoutException ste ) {
177
+ log (side , "Warning: " + ste );
178
+
179
+ List <DatagramPacket > packets = new ArrayList <>();
180
+ boolean finished = onReceiveTimeout (
181
+ engine , peerAddr , side , packets );
182
+
183
+ log (side , "Reproduced " + packets .size () + " packets" );
184
+ for (DatagramPacket p : packets ) {
185
+ printHex ("Reproduced packet" ,
186
+ p .getData (), p .getOffset (), p .getLength ());
187
+ socket .send (p );
188
+ }
189
+
190
+ if (finished ) {
191
+ log (side , "Handshake status is FINISHED "
192
+ + "after calling onReceiveTimeout(), "
193
+ + "finish the loop" );
194
+ endLoops = true ;
195
+ }
196
+
197
+ log (side , "New handshake status is "
198
+ + engine .getHandshakeStatus ());
199
+
200
+ continue ;
192
201
}
193
202
194
- log (side , "New handshake status is "
195
- + engine .getHandshakeStatus ());
196
-
197
- continue ;
203
+ iNet = ByteBuffer .wrap (buf , 0 , packet .getLength ());
204
+ } else {
205
+ iNet = ByteBuffer .allocate (0 );
198
206
}
199
207
200
- iNet = ByteBuffer .wrap (buf , 0 , packet .getLength ());
201
- iApp = ByteBuffer .allocate (BUFFER_SIZE );
202
- } else {
203
- iNet = ByteBuffer .allocate (0 );
204
208
iApp = ByteBuffer .allocate (BUFFER_SIZE );
205
- }
206
209
207
- SSLEngineResult r = engine .unwrap (iNet , iApp );
208
- SSLEngineResult .Status rs = r .getStatus ();
209
- hs = r .getHandshakeStatus ();
210
- if (rs == SSLEngineResult .Status .OK ) {
211
- // OK
212
- } else if (rs == SSLEngineResult .Status .BUFFER_OVERFLOW ) {
213
- log (side , "BUFFER_OVERFLOW, handshake status is " + hs );
214
-
215
- // the client maximum fragment size config does not work?
216
- throw new Exception ("Buffer overflow: " +
217
- "incorrect client maximum fragment size" );
218
- } else if (rs == SSLEngineResult .Status .BUFFER_UNDERFLOW ) {
219
- log (side , "BUFFER_UNDERFLOW, handshake status is " + hs );
210
+ SSLEngineResult r = engine .unwrap (iNet , iApp );
211
+ hs = r .getHandshakeStatus ();
220
212
221
- // bad packet, or the client maximum fragment size
222
- // config does not work?
223
- if (hs != SSLEngineResult .HandshakeStatus .NOT_HANDSHAKING ) {
224
- throw new Exception ("Buffer underflow: " +
225
- "incorrect client maximum fragment size" );
226
- } // otherwise, ignore this packet
227
- } else if (rs == SSLEngineResult .Status .CLOSED ) {
228
- throw new Exception (
229
- "SSL engine closed, handshake status is " + hs );
230
- } else {
231
- throw new Exception ("Can't reach here, result is " + rs );
213
+ verifySSLEngineResultStatus (r , side );
214
+ if (hs == SSLEngineResult .HandshakeStatus .FINISHED ) {
215
+ log (side , "Handshake status is FINISHED, finish the loop" );
216
+ endLoops = true ;
217
+ }
232
218
}
219
+ case NEED_WRAP -> {
220
+ List <DatagramPacket > packets = new ArrayList <>();
221
+ boolean finished = produceHandshakePackets (
222
+ engine , peerAddr , side , packets );
223
+
224
+ log (side , "Produced " + packets .size () + " packets" );
225
+ for (DatagramPacket p : packets ) {
226
+ socket .send (p );
227
+ }
233
228
234
- if (hs == SSLEngineResult .HandshakeStatus .FINISHED ) {
235
- log (side , "Handshake status is FINISHED, finish the loop" );
236
- endLoops = true ;
237
- }
238
- } else if (hs == SSLEngineResult .HandshakeStatus .NEED_WRAP ) {
239
- List <DatagramPacket > packets = new ArrayList <>();
240
- boolean finished = produceHandshakePackets (
241
- engine , peerAddr , side , packets );
242
-
243
- log (side , "Produced " + packets .size () + " packets" );
244
- for (DatagramPacket p : packets ) {
245
- socket .send (p );
229
+ if (finished ) {
230
+ log (side , "Handshake status is FINISHED "
231
+ + "after producing handshake packets, "
232
+ + "finish the loop" );
233
+ endLoops = true ;
234
+ }
246
235
}
247
-
248
- if (finished ) {
249
- log (side , "Handshake status is FINISHED "
250
- + "after producing handshake packets, "
251
- + "finish the loop" );
236
+ case NEED_TASK -> runDelegatedTasks (engine );
237
+ case NOT_HANDSHAKING -> {
238
+ log (side ,
239
+ "Handshake status is NOT_HANDSHAKING, finish the loop" );
252
240
endLoops = true ;
253
241
}
254
- } else if (hs == SSLEngineResult .HandshakeStatus .NEED_TASK ) {
255
- runDelegatedTasks (engine );
256
- } else if (hs == SSLEngineResult .HandshakeStatus .NOT_HANDSHAKING ) {
257
- log (side ,
258
- "Handshake status is NOT_HANDSHAKING, finish the loop" );
259
- endLoops = true ;
260
- } else if (hs == SSLEngineResult .HandshakeStatus .FINISHED ) {
261
- throw new Exception (
262
- "Unexpected status, SSLEngine.getHandshakeStatus() "
263
- + "shouldn't return FINISHED" );
264
- } else {
265
- throw new Exception (
266
- "Can't reach here, handshake status is " + hs );
242
+ case FINISHED -> throw new Exception ( "Unexpected status, " +
243
+ "SSLEngine.getHandshakeStatus() shouldn't return FINISHED" );
244
+ default -> throw new Exception ("Can't reach here, " +
245
+ "handshake status is " + hs );
267
246
}
268
247
}
269
248
@@ -291,13 +270,39 @@ void handshake(SSLEngine engine, DatagramSocket socket,
291
270
}
292
271
}
293
272
273
+ void verifySSLEngineResultStatus (SSLEngineResult r , String side ) throws Exception {
274
+ SSLEngineResult .Status rs = r .getStatus ();
275
+ SSLEngineResult .HandshakeStatus hs = r .getHandshakeStatus ();
276
+ switch (rs ) {
277
+ case OK -> log (side , "SSLEngineResult status OK" );
278
+ case BUFFER_OVERFLOW -> {
279
+ log (side , "BUFFER_OVERFLOW, handshake status is " + hs );
280
+ // the client maximum fragment size config does not work?
281
+ throw new Exception ("Buffer overflow: " +
282
+ "incorrect client maximum fragment size" );
283
+ }
284
+ case BUFFER_UNDERFLOW -> {
285
+ log (side , "BUFFER_UNDERFLOW, handshake status is " + hs );
286
+ // bad packet, or the client maximum fragment size
287
+ // config does not work?
288
+ if (hs != SSLEngineResult .HandshakeStatus .NOT_HANDSHAKING ) {
289
+ throw new Exception ("Buffer underflow: " +
290
+ "incorrect client maximum fragment size" );
291
+ } // otherwise, ignore this packet
292
+ }
293
+ case CLOSED -> throw new Exception (
294
+ "SSL engine closed, handshake status is " + hs );
295
+ default -> throw new Exception ("Can't reach here, result is " + rs );
296
+ }
297
+ }
298
+
294
299
// deliver application data
295
300
void deliverAppData (SSLEngine engine , DatagramSocket socket ,
296
- ByteBuffer appData , SocketAddress peerAddr ) throws Exception {
301
+ ByteBuffer appData , SocketAddress peerAddr , String side ) throws Exception {
297
302
298
303
// Note: have not consider the packet loses
299
304
List <DatagramPacket > packets =
300
- produceApplicationPackets (engine , appData , peerAddr );
305
+ produceApplicationPackets (engine , appData , peerAddr , side );
301
306
appData .flip ();
302
307
for (DatagramPacket p : packets ) {
303
308
socket .send (p );
@@ -344,7 +349,7 @@ boolean produceHandshakePackets(SSLEngine engine, SocketAddress socketAddr,
344
349
345
350
if (--loops < 0 ) {
346
351
throw new RuntimeException (
347
- "Too much loops to produce handshake packets" );
352
+ "Too many loops to produce handshake packets" );
348
353
}
349
354
350
355
ByteBuffer oNet = ByteBuffer .allocate (32768 );
@@ -356,30 +361,9 @@ boolean produceHandshakePackets(SSLEngine engine, SocketAddress socketAddr,
356
361
SSLEngineResult .HandshakeStatus hs = r .getHandshakeStatus ();
357
362
log (side , "----produce handshake packet(" +
358
363
loops + ", " + rs + ", " + hs + ")----" );
359
- if (rs == SSLEngineResult .Status .BUFFER_OVERFLOW ) {
360
- // the client maximum fragment size config does not work?
361
- throw new Exception ("Buffer overflow: " +
362
- "incorrect server maximum fragment size" );
363
- } else if (rs == SSLEngineResult .Status .BUFFER_UNDERFLOW ) {
364
- log (side ,
365
- "Produce handshake packets: BUFFER_UNDERFLOW occured" );
366
- log (side ,
367
- "Produce handshake packets: Handshake status: " + hs );
368
- // bad packet, or the client maximum fragment size
369
- // config does not work?
370
- if (hs != SSLEngineResult .HandshakeStatus .NOT_HANDSHAKING ) {
371
- throw new Exception ("Buffer underflow: " +
372
- "incorrect server maximum fragment size" );
373
- } // otherwise, ignore this packet
374
- } else if (rs == SSLEngineResult .Status .CLOSED ) {
375
- throw new Exception ("SSLEngine has closed" );
376
- } else if (rs == SSLEngineResult .Status .OK ) {
377
- // OK
378
- } else {
379
- throw new Exception ("Can't reach here, result is " + rs );
380
- }
381
364
382
- // SSLEngineResult.Status.OK:
365
+ verifySSLEngineResultStatus (r , side );
366
+
383
367
if (oNet .hasRemaining ()) {
384
368
byte [] ba = new byte [oNet .remaining ()];
385
369
oNet .get (ba );
@@ -396,24 +380,20 @@ boolean produceHandshakePackets(SSLEngine engine, SocketAddress socketAddr,
396
380
boolean endInnerLoop = false ;
397
381
SSLEngineResult .HandshakeStatus nhs = hs ;
398
382
while (!endInnerLoop ) {
399
- if (nhs == SSLEngineResult .HandshakeStatus .NEED_TASK ) {
400
- runDelegatedTasks (engine );
401
- } else if (nhs == SSLEngineResult .HandshakeStatus .NEED_UNWRAP ||
402
- nhs == SSLEngineResult .HandshakeStatus .NEED_UNWRAP_AGAIN ||
403
- nhs == SSLEngineResult .HandshakeStatus .NOT_HANDSHAKING ) {
404
-
405
- endInnerLoop = true ;
406
- endLoops = true ;
407
- } else if (nhs == SSLEngineResult .HandshakeStatus .NEED_WRAP ) {
408
- endInnerLoop = true ;
409
- } else if (nhs == SSLEngineResult .HandshakeStatus .FINISHED ) {
410
- throw new Exception (
383
+ switch (nhs ) {
384
+ case NEED_TASK -> runDelegatedTasks (engine );
385
+ case NEED_UNWRAP , NEED_UNWRAP_AGAIN , NOT_HANDSHAKING -> {
386
+ endInnerLoop = true ;
387
+ endLoops = true ;
388
+ }
389
+ case NEED_WRAP -> endInnerLoop = true ;
390
+ case FINISHED -> throw new Exception (
411
391
"Unexpected status, SSLEngine.getHandshakeStatus() "
412
- + "shouldn't return FINISHED" );
413
- } else {
414
- throw new Exception ("Can't reach here, handshake status is "
392
+ + "should not return FINISHED" );
393
+ default -> throw new Exception ("Can't reach here, handshake status is "
415
394
+ nhs );
416
395
}
396
+
417
397
nhs = engine .getHandshakeStatus ();
418
398
}
419
399
}
@@ -428,30 +408,15 @@ DatagramPacket createHandshakePacket(byte[] ba, SocketAddress socketAddr) {
428
408
// produce application packets
429
409
List <DatagramPacket > produceApplicationPackets (
430
410
SSLEngine engine , ByteBuffer source ,
431
- SocketAddress socketAddr ) throws Exception {
411
+ SocketAddress socketAddr , String side ) throws Exception {
432
412
433
413
List <DatagramPacket > packets = new ArrayList <>();
434
414
ByteBuffer appNet = ByteBuffer .allocate (32768 );
435
415
SSLEngineResult r = engine .wrap (source , appNet );
436
416
appNet .flip ();
437
417
438
- SSLEngineResult .Status rs = r .getStatus ();
439
- if (rs == SSLEngineResult .Status .BUFFER_OVERFLOW ) {
440
- // the client maximum fragment size config does not work?
441
- throw new Exception ("Buffer overflow: " +
442
- "incorrect server maximum fragment size" );
443
- } else if (rs == SSLEngineResult .Status .BUFFER_UNDERFLOW ) {
444
- // unlikely
445
- throw new Exception ("Buffer underflow during wraping" );
446
- } else if (rs == SSLEngineResult .Status .CLOSED ) {
447
- throw new Exception ("SSLEngine has closed" );
448
- } else if (rs == SSLEngineResult .Status .OK ) {
449
- // OK
450
- } else {
451
- throw new Exception ("Can't reach here, result is " + rs );
452
- }
418
+ verifySSLEngineResultStatus (r , side );
453
419
454
- // SSLEngineResult.Status.OK:
455
420
if (appNet .hasRemaining ()) {
456
421
byte [] ba = new byte [appNet .remaining ()];
457
422
appNet .get (ba );
@@ -472,7 +437,7 @@ static DatagramPacket getPacket(
472
437
int offset = packet .getOffset ();
473
438
int length = packet .getLength ();
474
439
475
- // Normally, this pakcet should be a handshake message
440
+ // Normally, this packet should be a handshake message
476
441
// record. However, even if the underlying platform
477
442
// splits the record more, we don't really worry about
478
443
// the improper packet loss because DTLS implementation
@@ -490,12 +455,12 @@ static DatagramPacket getPacket(
490
455
if (data [offset + 4 ] == 0x00 ) { // plaintext
491
456
matched =
492
457
(data [offset + 13 ] == handshakeType );
493
- } else { // cipherext
458
+ } else { // ciphertext
494
459
// The 1st ciphertext is a Finished message.
495
460
//
496
461
// If it is not proposed to loss the Finished
497
462
// message, it is not necessary to check the
498
- // following packets any mroe as a Finished
463
+ // following packets any more as a Finished
499
464
// message is the last handshake message.
500
465
matched = (handshakeType == 20 );
501
466
}
@@ -540,8 +505,8 @@ boolean onReceiveTimeout(SSLEngine engine, SocketAddress socketAddr,
540
505
SSLContext getDTLSContext () throws Exception {
541
506
String passphrase = "passphrase" ;
542
507
return SSLContextBuilder .builder ()
543
- .trustStore (KeyStoreUtils .loadKeyStore (trustFilename , passphrase ))
544
- .keyStore (KeyStoreUtils .loadKeyStore (keyFilename , passphrase ))
508
+ .trustStore (KeyStoreUtils .loadKeyStore (TRUST_FILENAME , passphrase ))
509
+ .keyStore (KeyStoreUtils .loadKeyStore (KEY_FILENAME , passphrase ))
545
510
.kmfPassphrase (passphrase )
546
511
.protocol ("DTLS" )
547
512
.build ();
@@ -559,17 +524,22 @@ public boolean isGoodJob() {
559
524
}
560
525
561
526
public final void runTest (DTLSOverDatagram testCase ) throws Exception {
562
- try (DatagramSocket serverSocket = new DatagramSocket ();
563
- DatagramSocket clientSocket = new DatagramSocket ()) {
527
+ InetSocketAddress serverSocketAddress = new InetSocketAddress
528
+ (InetAddress .getLoopbackAddress (), 0 );
529
+ InetSocketAddress clientSocketAddress = new InetSocketAddress
530
+ (InetAddress .getLoopbackAddress (), 0 );
531
+
532
+ try (DatagramSocket serverSocket = new DatagramSocket (serverSocketAddress );
533
+ DatagramSocket clientSocket = new DatagramSocket (clientSocketAddress )) {
564
534
565
535
serverSocket .setSoTimeout (SOCKET_TIMEOUT );
566
536
clientSocket .setSoTimeout (SOCKET_TIMEOUT );
567
537
568
538
InetSocketAddress serverSocketAddr = new InetSocketAddress (
569
- InetAddress .getLocalHost (), serverSocket .getLocalPort ());
539
+ InetAddress .getLoopbackAddress (), serverSocket .getLocalPort ());
570
540
571
541
InetSocketAddress clientSocketAddr = new InetSocketAddress (
572
- InetAddress .getLocalHost (), clientSocket .getLocalPort ());
542
+ InetAddress .getLoopbackAddress (), clientSocket .getLocalPort ());
573
543
574
544
ExecutorService pool = Executors .newFixedThreadPool (2 );
575
545
Future <String > server , client ;
@@ -611,19 +581,8 @@ public final void runTest(DTLSOverDatagram testCase) throws Exception {
611
581
}
612
582
}
613
583
614
- final static class ServerCallable implements Callable <String > {
615
-
616
- private final DTLSOverDatagram testCase ;
617
- private final DatagramSocket socket ;
618
- private final InetSocketAddress clientSocketAddr ;
619
-
620
- ServerCallable (DTLSOverDatagram testCase , DatagramSocket socket ,
621
- InetSocketAddress clientSocketAddr ) {
622
-
623
- this .testCase = testCase ;
624
- this .socket = socket ;
625
- this .clientSocketAddr = clientSocketAddr ;
626
- }
584
+ record ServerCallable (DTLSOverDatagram testCase , DatagramSocket socket ,
585
+ InetSocketAddress clientSocketAddr ) implements Callable <String > {
627
586
628
587
@ Override
629
588
public String call () throws Exception {
@@ -649,19 +608,8 @@ public String call() throws Exception {
649
608
}
650
609
}
651
610
652
- final static class ClientCallable implements Callable <String > {
653
-
654
- private final DTLSOverDatagram testCase ;
655
- private final DatagramSocket socket ;
656
- private final InetSocketAddress serverSocketAddr ;
657
-
658
- ClientCallable (DTLSOverDatagram testCase , DatagramSocket socket ,
659
- InetSocketAddress serverSocketAddr ) {
660
-
661
- this .testCase = testCase ;
662
- this .socket = socket ;
663
- this .serverSocketAddr = serverSocketAddr ;
664
- }
611
+ record ClientCallable (DTLSOverDatagram testCase , DatagramSocket socket ,
612
+ InetSocketAddress serverSocketAddr ) implements Callable <String > {
665
613
666
614
@ Override
667
615
public String call () throws Exception {
@@ -687,7 +635,7 @@ public String call() throws Exception {
687
635
}
688
636
}
689
637
690
- final static void printHex (String prefix , ByteBuffer bb ) {
638
+ static void printHex (String prefix , ByteBuffer bb ) {
691
639
692
640
synchronized (System .out ) {
693
641
System .out .println (prefix );
@@ -700,7 +648,7 @@ final static void printHex(String prefix, ByteBuffer bb) {
700
648
}
701
649
}
702
650
703
- final static void printHex (String prefix ,
651
+ static void printHex (String prefix ,
704
652
byte [] bytes , int offset , int length ) {
705
653
706
654
synchronized (System .out ) {
0 commit comments