Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/javax/net/ssl/TLSCommon/interop/ResumptionUseCase.java
41154 views
1
/*
2
* Copyright (c) 2020, 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
/*
25
* The SSL/TLS communication parameters on session resumption.
26
*/
27
public class ResumptionUseCase extends ExtUseCase {
28
29
private boolean enableServerSessionTicket
30
= Boolean.getBoolean("jdk.tls.server.enableSessionTicketExtension");
31
32
private boolean enableClientSessionTicket
33
= Boolean.getBoolean("jdk.tls.client.enableSessionTicketExtension");
34
35
public static ResumptionUseCase newInstance() {
36
return new ResumptionUseCase();
37
}
38
39
public boolean isEnableServerSessionTicket() {
40
return enableServerSessionTicket;
41
}
42
43
public ResumptionUseCase setEnableServerSessionTicket(
44
boolean enableServerSessionTicket) {
45
this.enableServerSessionTicket = enableServerSessionTicket;
46
return this;
47
}
48
49
public boolean isEnableClientSessionTicket() {
50
return enableClientSessionTicket;
51
}
52
53
public ResumptionUseCase setEnableClientSessionTicket(
54
boolean enableClientSessionTicket) {
55
this.enableClientSessionTicket = enableClientSessionTicket;
56
return this;
57
}
58
59
/*
60
* For TLS 1.3, the session should always be resumed via session ticket.
61
* For TLS 1.2, if both of server and client support session ticket,
62
* the session should be resumed via session ticket; otherwise, the session
63
* should be resumed via session ID.
64
*/
65
public ResumptionMode expectedResumptionMode() {
66
if (getProtocol() == Protocol.TLSV1_3
67
|| (enableServerSessionTicket && enableClientSessionTicket)) {
68
return ResumptionMode.TICKET;
69
} else {
70
return ResumptionMode.ID;
71
}
72
}
73
74
@Override
75
public String toString() {
76
return Utilities.join(Utilities.PARAM_DELIMITER,
77
super.toString(),
78
Utilities.joinNameValue(
79
"enableServerSessionTicket", enableServerSessionTicket),
80
Utilities.joinNameValue(
81
"enableClientSessionTicket", enableClientSessionTicket));
82
}
83
}
84
85