1 /* 2 * Copyright (c) 2015, 2017, 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 jdk.incubator.http; 27 28 import java.io.IOException; 29 import java.net.InetSocketAddress; 30 import java.nio.ByteBuffer; 31 import java.util.concurrent.CompletableFuture; 32 import javax.net.ssl.SSLEngine; 33 import jdk.incubator.http.internal.common.ExceptionallyCloseable; 34 35 36 /** 37 * Asynchronous version of SSLConnection. 38 * 39 * There are two concrete implementations of this class: AsyncSSLConnection 40 * and AsyncSSLTunnelConnection. 41 * This abstraction is useful when downgrading from HTTP/2 to HTTP/1.1 over 42 * an SSL connection. See ExchangeImpl::get in the case where an ALPNException 43 * is thrown. 44 * 45 * Note: An AsyncSSLConnection wraps a PlainHttpConnection, while an 46 * AsyncSSLTunnelConnection wraps a PlainTunnelingConnection. 47 * If both these wrapped classes where made to inherit from a 48 * common abstraction then it might be possible to merge 49 * AsyncSSLConnection and AsyncSSLTunnelConnection back into 50 * a single class - and simply use different factory methods to 51 * create different wrappees, but this is left up for further cleanup. 52 * 53 */ 54 abstract class AbstractAsyncSSLConnection extends HttpConnection 55 implements AsyncConnection, ExceptionallyCloseable { 56 57 58 AbstractAsyncSSLConnection(InetSocketAddress addr, HttpClientImpl client) { 59 super(addr, client); 60 } 61 62 abstract SSLEngine getEngine(); 63 abstract AsyncSSLDelegate sslDelegate(); 64 abstract HttpConnection plainConnection(); 65 abstract HttpConnection downgrade(); 66 67 @Override 68 final boolean isSecure() { 69 return true; 70 } 71 72 // Blocking read functions not used here 73 @Override 74 protected final ByteBuffer readImpl() throws IOException { 75 throw new UnsupportedOperationException("Not supported."); 76 } 77 78 // whenReceivedResponse only used in HTTP/1.1 (Http1Exchange) 79 // AbstractAsyncSSLConnection is only used with HTTP/2 80 @Override 81 final CompletableFuture<Void> whenReceivingResponse() { 82 throw new UnsupportedOperationException("Not supported."); 83 } 84 85 }