Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/jdk.httpserver/share/classes/com/sun/net/httpserver/HttpsParameters.java
41159 views
1
/*
2
* Copyright (c) 2005, 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. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
26
package com.sun.net.httpserver;
27
28
import java.net.InetSocketAddress;
29
import javax.net.ssl.SSLContext;
30
import javax.net.ssl.SSLParameters;
31
32
/**
33
* Represents the set of parameters for each https connection negotiated with
34
* clients. One of these is created and passed to
35
* {@link HttpsConfigurator#configure(HttpsParameters)} for every incoming https
36
* connection, in order to determine the parameters to use.
37
*
38
* <p> The underlying SSL parameters may be established either via the set/get
39
* methods of this class, or else via a {@link javax.net.ssl.SSLParameters}
40
* object. {@code SSLParameters} is the preferred method, because in the future,
41
* additional configuration capabilities may be added to that class, and it is
42
* easier to determine the set of supported parameters and their default values
43
* with SSLParameters. Also, if an {@code SSLParameters} object is provided via
44
* {@link #setSSLParameters(SSLParameters)} then those parameter settings are
45
* used, and any settings made in this object are ignored.
46
*
47
* @since 1.6
48
*/
49
public abstract class HttpsParameters {
50
51
private String[] cipherSuites;
52
private String[] protocols;
53
private boolean wantClientAuth;
54
private boolean needClientAuth;
55
56
/**
57
* Constructor for subclasses to call.
58
*/
59
protected HttpsParameters() {}
60
61
/**
62
* Returns the {@link HttpsConfigurator} for this {@code HttpsParameters}.
63
*
64
* @return {@code HttpsConfigurator} for this instance of {@code HttpsParameters}
65
*/
66
public abstract HttpsConfigurator getHttpsConfigurator();
67
68
/**
69
* Returns the address of the remote client initiating the connection.
70
*
71
* @return address of the remote client initiating the connection
72
*/
73
public abstract InetSocketAddress getClientAddress();
74
75
/**
76
* Sets the {@link SSLParameters} to use for this {@code HttpsParameters}.
77
* The parameters must be supported by the {@link SSLContext} contained
78
* by the {@link HttpsConfigurator} associated with this {@code HttpsParameters}.
79
* If no parameters are set, then the default behavior is to use
80
* the default parameters from the associated {@link SSLContext}.
81
*
82
* @param params the {@code SSLParameters} to set. If {@code null} then the
83
* existing parameters (if any) remain unchanged
84
* @throws IllegalArgumentException if any of the parameters are invalid or
85
* unsupported
86
*/
87
public abstract void setSSLParameters(SSLParameters params);
88
89
/**
90
* Returns a copy of the array of ciphersuites or {@code null} if none
91
* have been set.
92
*
93
* @return a copy of the array of ciphersuites or {@code null} if none have
94
* been set
95
*/
96
public String[] getCipherSuites() {
97
return cipherSuites != null ? cipherSuites.clone() : null;
98
}
99
100
/**
101
* Sets the array of ciphersuites.
102
*
103
* @param cipherSuites the array of ciphersuites (or {@code null})
104
*/
105
public void setCipherSuites(String[] cipherSuites) {
106
this.cipherSuites = cipherSuites != null ? cipherSuites.clone() : null;
107
}
108
109
/**
110
* Returns a copy of the array of protocols or {@code null} if none have been
111
* set.
112
*
113
* @return a copy of the array of protocols or {@code null} if none have been
114
* set
115
*/
116
public String[] getProtocols() {
117
return protocols != null ? protocols.clone() : null;
118
}
119
120
/**
121
* Sets the array of protocols.
122
*
123
* @param protocols the array of protocols (or {@code null})
124
*/
125
public void setProtocols(String[] protocols) {
126
this.protocols = protocols != null ? protocols.clone() : null;
127
}
128
129
/**
130
* Returns whether client authentication should be requested.
131
*
132
* @return whether client authentication should be requested
133
*/
134
public boolean getWantClientAuth() {
135
return wantClientAuth;
136
}
137
138
/**
139
* Sets whether client authentication should be requested. Calling this
140
* method clears the {@code needClientAuth} flag.
141
*
142
* @param wantClientAuth whether client authentication should be requested
143
*/
144
public void setWantClientAuth(boolean wantClientAuth) {
145
this.wantClientAuth = wantClientAuth;
146
}
147
148
/**
149
* Returns whether client authentication should be required.
150
*
151
* @return whether client authentication should be required
152
*/
153
public boolean getNeedClientAuth() {
154
return needClientAuth;
155
}
156
157
/**
158
* Sets whether client authentication should be required. Calling this method
159
* clears the {@code wantClientAuth} flag.
160
*
161
* @param needClientAuth whether client authentication should be required
162
*/
163
public void setNeedClientAuth(boolean needClientAuth) {
164
this.needClientAuth = needClientAuth;
165
}
166
}
167
168