Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/com/sun/net/httpserver/HttpsServer.java
38922 views
/*1* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package com.sun.net.httpserver;2627import java.net.*;28import java.io.*;29import java.nio.*;30import java.security.*;31import java.nio.channels.*;32import java.util.*;33import java.util.concurrent.*;34import javax.net.ssl.*;35import com.sun.net.httpserver.spi.*;3637/**38* This class is an extension of {@link HttpServer} which provides39* support for HTTPS. <p>40* A HttpsServer must have an associated {@link HttpsConfigurator} object41* which is used to establish the SSL configuration for the SSL connections.42* <p>43* All other configuration is the same as for HttpServer.44* @since 1.645*/4647@jdk.Exported48public abstract class HttpsServer extends HttpServer {4950/**51*/52protected HttpsServer () {53}5455/**56* creates a HttpsServer instance which is initially not bound to any local address/port.57* The HttpsServer is acquired from the currently installed {@link HttpServerProvider}58* The server must be bound using {@link #bind(InetSocketAddress,int)} before it can be used.59* The server must also have a HttpsConfigurator established with {@link #setHttpsConfigurator(HttpsConfigurator)}60* @throws IOException61*/62public static HttpsServer create () throws IOException {63return create (null, 0);64}6566/**67* Create a <code>HttpsServer</code> instance which will bind to the68* specified {@link java.net.InetSocketAddress} (IP address and port number)69*70* A maximum backlog can also be specified. This is the maximum number of71* queued incoming connections to allow on the listening socket.72* Queued TCP connections exceeding this limit may be rejected by the TCP implementation.73* The HttpsServer is acquired from the currently installed {@link HttpServerProvider}74* The server must have a HttpsConfigurator established with {@link #setHttpsConfigurator(HttpsConfigurator)}75*76* @param addr the address to listen on, if <code>null</code> then bind() must be called77* to set the address78* @param backlog the socket backlog. If this value is less than or equal to zero,79* then a system default value is used.80* @throws BindException if the server cannot bind to the requested address,81* or if the server is already bound.82* @throws IOException83*/8485public static HttpsServer create (86InetSocketAddress addr, int backlog87) throws IOException {88HttpServerProvider provider = HttpServerProvider.provider();89return provider.createHttpsServer (addr, backlog);90}9192/**93* Sets this server's {@link HttpsConfigurator} object.94* @param config the HttpsConfigurator to set95* @throws NullPointerException if config is null.96*/97public abstract void setHttpsConfigurator (HttpsConfigurator config) ;9899/**100* Gets this server's {@link HttpsConfigurator} object, if it has been set.101* @return the HttpsConfigurator for this server, or <code>null</code> if not set.102*/103public abstract HttpsConfigurator getHttpsConfigurator ();104}105106107