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/HttpsServer.java
41159 views
1
/*
2
* Copyright (c) 2005, 2013, 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.io.IOException;
29
import java.net.BindException;
30
import java.net.InetSocketAddress;
31
import com.sun.net.httpserver.spi.HttpServerProvider;
32
33
/**
34
* This class is an extension of {@link HttpServer} which provides support for
35
* HTTPS.
36
*
37
* <p>A {@code HttpsServer} must have an associated {@link HttpsConfigurator} object
38
* which is used to establish the SSL configuration for the SSL connections.
39
*
40
* <p>All other configuration is the same as for {@code HttpServer}.
41
*
42
* @since 1.6
43
*/
44
45
public abstract class HttpsServer extends HttpServer {
46
47
/**
48
* Constructor for subclasses to call.
49
*/
50
protected HttpsServer() {
51
}
52
53
/**
54
* Creates a {@code HttpsServer} instance which is initially not bound to any
55
* local address/port. The {@code HttpsServer} is acquired from the currently
56
* installed {@link HttpServerProvider}. The server must be bound using
57
* {@link #bind(InetSocketAddress,int)} before it can be used. The server
58
* must also have a {@code HttpsConfigurator} established with
59
* {@link #setHttpsConfigurator(HttpsConfigurator)}.
60
*
61
* @return an instance of {@code HttpsServer}
62
* @throws IOException if an I/O error occurs
63
*/
64
public static HttpsServer create() throws IOException {
65
return create(null, 0);
66
}
67
68
/**
69
* Create a {@code HttpsServer} instance which will bind to the specified
70
* {@link java.net.InetSocketAddress} (IP address and port number).
71
*
72
* A maximum backlog can also be specified. This is the maximum number of
73
* queued incoming connections to allow on the listening socket. Queued TCP
74
* connections exceeding this limit may be rejected by the TCP implementation.
75
* The {@code HttpsServer} is acquired from the currently installed
76
* {@link HttpServerProvider}. The server must have a {@code HttpsConfigurator}
77
* established with {@link #setHttpsConfigurator(HttpsConfigurator)}.
78
*
79
* @param addr the address to listen on, if {@code null} then
80
* {@link #bind(InetSocketAddress,int)} must be called to set
81
* the address
82
* @param backlog the socket backlog. If this value is less than or equal to
83
* zero, then a system default value is used.
84
* @return an instance of {@code HttpsServer}
85
* @throws BindException if the server cannot bind to the requested address,
86
* or if the server is already bound
87
* @throws IOException if an I/O error occurs
88
*/
89
90
public static HttpsServer create(InetSocketAddress addr, int backlog) throws IOException {
91
HttpServerProvider provider = HttpServerProvider.provider();
92
return provider.createHttpsServer(addr, backlog);
93
}
94
95
/**
96
* Sets this server's {@link HttpsConfigurator} object.
97
*
98
* @param config the {@code HttpsConfigurator} to set
99
* @throws NullPointerException if config is {@code null}
100
*/
101
public abstract void setHttpsConfigurator(HttpsConfigurator config);
102
103
/**
104
* Gets this server's {@link HttpsConfigurator} object, if it has been set.
105
*
106
* @return the {@code HttpsConfigurator} for this server, or {@code null} if
107
* not set
108
*/
109
public abstract HttpsConfigurator getHttpsConfigurator();
110
}
111
112