Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/javax/net/ssl/DTLS/RespondToRetransmit.java
41152 views
1
/*
2
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
// SunJSSE does not support dynamic system properties, no way to re-use
25
// system properties in samevm/agentvm mode.
26
27
/*
28
* @test
29
* @bug 8161086 8258914
30
* @key intermittent
31
* @summary DTLS handshaking fails if some messages were lost
32
* @modules java.base/sun.security.util
33
* @library /test/lib
34
* @build DTLSOverDatagram
35
*
36
* @run main/othervm RespondToRetransmit client 0 hello_request
37
* @run main/othervm RespondToRetransmit client 1 client_hello
38
* @run main/othervm RespondToRetransmit client 2 server_hello
39
* @run main/othervm RespondToRetransmit client 3 hello_verify_request
40
* @run main/othervm RespondToRetransmit client 4 new_session_ticket
41
* @run main/othervm RespondToRetransmit client 11 certificate
42
* @run main/othervm RespondToRetransmit client 12 server_key_exchange
43
* @run main/othervm RespondToRetransmit client 13 certificate_request
44
* @run main/othervm RespondToRetransmit client 14 server_hello_done
45
* @run main/othervm RespondToRetransmit client 15 certificate_verify
46
* @run main/othervm RespondToRetransmit client 16 client_key_exchange
47
* @run main/othervm RespondToRetransmit client 20 finished
48
* @run main/othervm RespondToRetransmit client 21 certificate_url
49
* @run main/othervm RespondToRetransmit client 22 certificate_status
50
* @run main/othervm RespondToRetransmit client 23 supplemental_data
51
* @run main/othervm RespondToRetransmit client -1 change_cipher_spec
52
* @run main/othervm RespondToRetransmit server 0 hello_request
53
* @run main/othervm RespondToRetransmit server 1 client_hello
54
* @run main/othervm RespondToRetransmit server 2 server_hello
55
* @run main/othervm RespondToRetransmit server 3 hello_verify_request
56
* @run main/othervm RespondToRetransmit server 4 new_session_ticket
57
* @run main/othervm RespondToRetransmit server 11 certificate
58
* @run main/othervm RespondToRetransmit server 12 server_key_exchange
59
* @run main/othervm RespondToRetransmit server 13 certificate_request
60
* @run main/othervm RespondToRetransmit server 14 server_hello_done
61
* @run main/othervm RespondToRetransmit server 15 certificate_verify
62
* @run main/othervm RespondToRetransmit server 16 client_key_exchange
63
* @run main/othervm RespondToRetransmit server 20 finished
64
* @run main/othervm RespondToRetransmit server 21 certificate_url
65
* @run main/othervm RespondToRetransmit server 22 certificate_status
66
* @run main/othervm RespondToRetransmit server 23 supplemental_data
67
* @run main/othervm RespondToRetransmit server -1 change_cipher_spec
68
*/
69
70
import java.util.List;
71
import java.util.ArrayList;
72
import java.net.DatagramPacket;
73
import java.net.SocketAddress;
74
import javax.net.ssl.SSLEngine;
75
76
/**
77
* Test that DTLS implementation is able to do retransmission internally
78
* automatically if packet get lost.
79
*/
80
public class RespondToRetransmit extends DTLSOverDatagram {
81
private static boolean isClient;
82
private static byte handshakeType;
83
84
private boolean needPacketDuplicate = true;
85
86
public static void main(String[] args) throws Exception {
87
isClient = args[0].equals("client");
88
handshakeType = Byte.parseByte(args[1]);
89
90
RespondToRetransmit testCase = new RespondToRetransmit();
91
testCase.runTest(testCase);
92
}
93
94
@Override
95
boolean produceHandshakePackets(SSLEngine engine, SocketAddress socketAddr,
96
String side, List<DatagramPacket> packets) throws Exception {
97
98
boolean finished = super.produceHandshakePackets(
99
engine, socketAddr, side, packets);
100
101
if (needPacketDuplicate && (isClient == engine.getUseClientMode())) {
102
DatagramPacket packet = getPacket(packets, handshakeType);
103
if (packet != null) {
104
needPacketDuplicate = false;
105
106
System.out.println("Duplicate the flight.");
107
List<DatagramPacket> duplicates = new ArrayList<>();
108
finished = super.produceHandshakePackets(
109
engine, socketAddr, side, duplicates);
110
packets.addAll(duplicates);
111
}
112
}
113
114
return finished;
115
}
116
}
117
118