author | chegar |
Sun, 17 Aug 2014 15:54:13 +0100 | |
changeset 25859 | 3317bb8137f4 |
parent 23010 | jdk/src/share/classes/com/sun/net/httpserver/HttpsServer.java@6dadb192ad81 |
child 34894 | 3248b89d1921 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
23010
6dadb192ad81
8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents:
20742
diff
changeset
|
2 |
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 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 |
* |
|
5506 | 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. |
|
2 | 24 |
*/ |
25 |
||
26 |
package com.sun.net.httpserver; |
|
27 |
||
28 |
import java.net.*; |
|
29 |
import java.io.*; |
|
30 |
import java.nio.*; |
|
31 |
import java.security.*; |
|
32 |
import java.nio.channels.*; |
|
33 |
import java.util.*; |
|
34 |
import java.util.concurrent.*; |
|
35 |
import javax.net.ssl.*; |
|
36 |
import com.sun.net.httpserver.spi.*; |
|
37 |
||
38 |
/** |
|
39 |
* This class is an extension of {@link HttpServer} which provides |
|
40 |
* support for HTTPS. <p> |
|
41 |
* A HttpsServer must have an associated {@link HttpsConfigurator} object |
|
42 |
* which is used to establish the SSL configuration for the SSL connections. |
|
43 |
* <p> |
|
44 |
* All other configuration is the same as for HttpServer. |
|
45 |
* @since 1.6 |
|
46 |
*/ |
|
47 |
||
20742
4ae78e8060d6
8008662: Add @jdk.Exported to JDK-specific/exported APIs
alanb
parents:
5506
diff
changeset
|
48 |
@jdk.Exported |
2 | 49 |
public abstract class HttpsServer extends HttpServer { |
50 |
||
51 |
/** |
|
52 |
*/ |
|
53 |
protected HttpsServer () { |
|
54 |
} |
|
55 |
||
56 |
/** |
|
57 |
* creates a HttpsServer instance which is initially not bound to any local address/port. |
|
58 |
* The HttpsServer is acquired from the currently installed {@link HttpServerProvider} |
|
59 |
* The server must be bound using {@link #bind(InetSocketAddress,int)} before it can be used. |
|
60 |
* The server must also have a HttpsConfigurator established with {@link #setHttpsConfigurator(HttpsConfigurator)} |
|
61 |
* @throws IOException |
|
62 |
*/ |
|
63 |
public static HttpsServer create () throws IOException { |
|
64 |
return create (null, 0); |
|
65 |
} |
|
66 |
||
67 |
/** |
|
68 |
* Create a <code>HttpsServer</code> instance which will bind to the |
|
69 |
* specified {@link java.net.InetSocketAddress} (IP address and port number) |
|
70 |
* |
|
71 |
* A maximum backlog can also be specified. This is the maximum number of |
|
72 |
* queued incoming connections to allow on the listening socket. |
|
73 |
* Queued TCP connections exceeding this limit may be rejected by the TCP implementation. |
|
74 |
* The HttpsServer is acquired from the currently installed {@link HttpServerProvider} |
|
75 |
* The server must have a HttpsConfigurator established with {@link #setHttpsConfigurator(HttpsConfigurator)} |
|
76 |
* |
|
77 |
* @param addr the address to listen on, if <code>null</code> then bind() must be called |
|
78 |
* to set the address |
|
79 |
* @param backlog the socket backlog. If this value is less than or equal to zero, |
|
80 |
* then a system default value is used. |
|
81 |
* @throws BindException if the server cannot bind to the requested address, |
|
82 |
* or if the server is already bound. |
|
83 |
* @throws IOException |
|
84 |
*/ |
|
85 |
||
86 |
public static HttpsServer create ( |
|
87 |
InetSocketAddress addr, int backlog |
|
88 |
) throws IOException { |
|
89 |
HttpServerProvider provider = HttpServerProvider.provider(); |
|
90 |
return provider.createHttpsServer (addr, backlog); |
|
91 |
} |
|
92 |
||
93 |
/** |
|
94 |
* Sets this server's {@link HttpsConfigurator} object. |
|
95 |
* @param config the HttpsConfigurator to set |
|
96 |
* @throws NullPointerException if config is null. |
|
97 |
*/ |
|
98 |
public abstract void setHttpsConfigurator (HttpsConfigurator config) ; |
|
99 |
||
100 |
/** |
|
101 |
* Gets this server's {@link HttpsConfigurator} object, if it has been set. |
|
102 |
* @return the HttpsConfigurator for this server, or <code>null</code> if not set. |
|
103 |
*/ |
|
104 |
public abstract HttpsConfigurator getHttpsConfigurator (); |
|
105 |
} |