Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/javax/net/ssl/TLSCommon/interop/UseCase.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
import java.util.Collections;
25
import java.util.HashMap;
26
import java.util.Map;
27
28
/*
29
* A set of specific SSL/TLS communication parameters on a peer.
30
*/
31
public class UseCase {
32
33
// The tuple for trusted CAs and certificates.
34
private CertTuple certTuple;
35
36
// The supported SSL/TLS protocols.
37
private Protocol[] protocols;
38
39
// The supported cipher suites.
40
private CipherSuite[] cipherSuites;
41
42
// If require client authentication.
43
private boolean clientAuth;
44
45
public static UseCase newInstance() {
46
return new UseCase();
47
}
48
49
public CertTuple getCertTuple() {
50
return certTuple;
51
}
52
53
public UseCase setCertTuple(CertTuple certTuple) {
54
this.certTuple = certTuple;
55
return this;
56
}
57
58
public Protocol[] getProtocols() {
59
return protocols;
60
}
61
62
public Protocol getProtocol() {
63
return protocols != null && protocols.length > 0
64
? protocols[0]
65
: null;
66
}
67
68
public UseCase setProtocols(Protocol... protocols) {
69
this.protocols = protocols;
70
return this;
71
}
72
73
public CipherSuite[] getCipherSuites() {
74
return cipherSuites;
75
}
76
77
public CipherSuite getCipherSuite() {
78
return cipherSuites != null && cipherSuites.length > 0
79
? cipherSuites[0]
80
: null;
81
}
82
83
public UseCase setCipherSuites(CipherSuite... cipherSuites) {
84
this.cipherSuites = cipherSuites;
85
return this;
86
}
87
88
public boolean isClientAuth() {
89
return clientAuth;
90
}
91
92
public UseCase setClientAuth(boolean clientAuth) {
93
this.clientAuth = clientAuth;
94
return this;
95
}
96
97
// The system properties used by a JDK peer.
98
private final Map<String, String> props = new HashMap<>();
99
100
public UseCase addProp(String prop, String value) {
101
props.put(prop, value);
102
return this;
103
}
104
105
public String getProp(String prop) {
106
return props.get(prop);
107
}
108
109
public UseCase addAllProps(Map<String, String> props) {
110
this.props.putAll(props);
111
return this;
112
}
113
114
public Map<String, String> getAllProps() {
115
return Collections.unmodifiableMap(props);
116
}
117
118
public UseCase removeProp(String prop) {
119
props.remove(prop);
120
return this;
121
}
122
123
public UseCase removeAllProps() {
124
props.clear();
125
return this;
126
}
127
128
@Override
129
public String toString() {
130
return Utilities.join(Utilities.PARAM_DELIMITER,
131
"certTuple=[" + certTuple + "]",
132
Utilities.joinNameValue("protocols", Utilities.join(protocols)),
133
Utilities.joinNameValue("cipherSuites", Utilities.join(cipherSuites)),
134
Utilities.joinNameValue("clientAuth", clientAuth ? "true" : ""));
135
}
136
}
137
138