151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski/* 251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Copyright (c) 2001, 2005, Oracle and/or its affiliates. All rights reserved. 351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * This code is free software; you can redistribute it and/or modify it 651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * under the terms of the GNU General Public License version 2 only, as 751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * published by the Free Software Foundation. Oracle designates this 851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * particular file as subject to the "Classpath" exception as provided 951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * by Oracle in the LICENSE file that accompanied this code. 1051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 1151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * This code is distributed in the hope that it will be useful, but WITHOUT 1251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * version 2 for more details (a copy is included in the LICENSE file that 1551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * accompanied this code). 1651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 1751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * You should have received a copy of the GNU General Public License version 1851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 2 along with this work; if not, write to the Free Software Foundation, 1951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 2151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * or visit www.oracle.com if you need additional information or have any 2351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * questions. 2451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 2551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 2651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebskipackage sun.net.www.protocol.https; 2751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 2851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebskiimport java.net.URL; 2951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebskiimport java.net.Proxy; 3051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebskiimport java.io.IOException; 3151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 3251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski/** 3351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * This class was introduced to provide an additional level of 3451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * abstraction between javax.net.ssl.HttpURLConnection and 3551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * com.sun.net.ssl.HttpURLConnection objects. <p> 3651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 3751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * javax.net.ssl.HttpURLConnection is used in the new sun.net version 3851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * of protocol implementation (this one) 3951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * com.sun.net.ssl.HttpURLConnection is used in the com.sun version. 4051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 4151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 4251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebskipublic class DelegateHttpsURLConnection extends AbstractDelegateHttpsURLConnection { 4351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 4451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski // we need a reference to the HttpsURLConnection to get 4551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski // the properties set there 4651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski // we also need it to be public so that it can be referenced 4751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski // from sun.net.www.protocol.http.HttpURLConnection 4851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski // this is for ResponseCache.put(URI, URLConnection) 4951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski // second parameter needs to be cast to javax.net.ssl.HttpsURLConnection 5051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski // instead of AbstractDelegateHttpsURLConnection 5151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski public javax.net.ssl.HttpsURLConnection httpsURLConnection; 5251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 5351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski DelegateHttpsURLConnection(URL url, 5451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski sun.net.www.protocol.http.Handler handler, 5551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski javax.net.ssl.HttpsURLConnection httpsURLConnection) 5651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski throws IOException { 5751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski this(url, null, handler, httpsURLConnection); 5851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski } 5951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 6051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski DelegateHttpsURLConnection(URL url, Proxy p, 6151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski sun.net.www.protocol.http.Handler handler, 6251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski javax.net.ssl.HttpsURLConnection httpsURLConnection) 6351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski throws IOException { 6451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski super(url, p, handler); 6551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski this.httpsURLConnection = httpsURLConnection; 6651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski } 6751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 6851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski protected javax.net.ssl.SSLSocketFactory getSSLSocketFactory() { 6951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski return httpsURLConnection.getSSLSocketFactory(); 7051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski } 7151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 7251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski protected javax.net.ssl.HostnameVerifier getHostnameVerifier() { 7351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski return httpsURLConnection.getHostnameVerifier(); 7451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski } 7551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 7651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /* 7751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Called by layered delegator's finalize() method to handle closing 7851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the underlying object. 7951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 8051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski protected void dispose() throws Throwable { 8151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski super.finalize(); 8251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski } 8351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski} 84