feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
66
jdkSrc/jdk8/com/sun/net/ssl/internal/ssl/Provider.java
Normal file
66
jdkSrc/jdk8/com/sun/net/ssl/internal/ssl/Provider.java
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.net.ssl.internal.ssl;
|
||||
|
||||
import sun.security.ssl.SunJSSE;
|
||||
|
||||
/**
|
||||
* Main class for the SunJSSE provider. The actual code was moved to the
|
||||
* class sun.security.ssl.SunJSSE, but for backward compatibility we
|
||||
* continue to use this class as the main Provider class.
|
||||
*/
|
||||
public final class Provider extends SunJSSE {
|
||||
|
||||
private static final long serialVersionUID = 3231825739635378733L;
|
||||
|
||||
// standard constructor
|
||||
public Provider() {
|
||||
super();
|
||||
}
|
||||
|
||||
// preferred constructor to enable FIPS mode at runtime
|
||||
public Provider(java.security.Provider cryptoProvider) {
|
||||
super(cryptoProvider);
|
||||
}
|
||||
|
||||
// constructor to enable FIPS mode from java.security file
|
||||
public Provider(String cryptoProvider) {
|
||||
super(cryptoProvider);
|
||||
}
|
||||
|
||||
// public for now, but we may want to change it or not document it.
|
||||
public static synchronized boolean isFIPS() {
|
||||
return SunJSSE.isFIPS();
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs the JSSE provider.
|
||||
*/
|
||||
public static synchronized void install() {
|
||||
/* nop. Remove this method in the future. */
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.net.ssl.internal.ssl;
|
||||
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.security.cert.CertificateException;
|
||||
|
||||
/**
|
||||
* Instance of this class is an extension of <code>X509TrustManager</code>.
|
||||
* <p>
|
||||
* Note that this class is referenced by the Deploy workspace. Any updates
|
||||
* must make sure that they do not cause any breakage there.
|
||||
* <p>
|
||||
* It takes the responsiblity of checking the peer identity with its
|
||||
* principal declared in the cerificate.
|
||||
* <p>
|
||||
* The class provides an alternative to <code>HostnameVerifer</code>.
|
||||
* If application customizes its <code>HostnameVerifer</code> for
|
||||
* <code>HttpsURLConnection</code>, the peer identity will be checked
|
||||
* by the customized <code>HostnameVerifer</code>; otherwise, it will
|
||||
* be checked by the extended trust manager.
|
||||
* <p>
|
||||
* RFC2830 defines the server identification specification for "LDAP"
|
||||
* algorithm. RFC2818 defines both the server identification and the
|
||||
* client identification specification for "HTTPS" algorithm.
|
||||
*
|
||||
* @see X509TrustManager
|
||||
* @see HostnameVerifier
|
||||
*
|
||||
* @since 1.6
|
||||
* @author Xuelei Fan
|
||||
*/
|
||||
public abstract class X509ExtendedTrustManager implements X509TrustManager {
|
||||
/**
|
||||
* Constructor used by subclasses only.
|
||||
*/
|
||||
protected X509ExtendedTrustManager() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Given the partial or complete certificate chain provided by the
|
||||
* peer, check its identity and build a certificate path to a trusted
|
||||
* root, return if it can be validated and is trusted for client SSL
|
||||
* authentication based on the authentication type.
|
||||
* <p>
|
||||
* The authentication type is determined by the actual certificate
|
||||
* used. For instance, if RSAPublicKey is used, the authType
|
||||
* should be "RSA". Checking is case-sensitive.
|
||||
* <p>
|
||||
* The algorithm parameter specifies the client identification protocol
|
||||
* to use. If the algorithm and the peer hostname are available, the
|
||||
* peer hostname is checked against the peer's identity presented in
|
||||
* the X509 certificate, in order to prevent masquerade attacks.
|
||||
*
|
||||
* @param chain the peer certificate chain
|
||||
* @param authType the authentication type based on the client certificate
|
||||
* @param hostname the peer hostname
|
||||
* @param algorithm the identification algorithm
|
||||
* @throws IllegalArgumentException if null or zero-length chain
|
||||
* is passed in for the chain parameter or if null or zero-length
|
||||
* string is passed in for the authType parameter
|
||||
* @throws CertificateException if the certificate chain is not trusted
|
||||
* by this TrustManager.
|
||||
*/
|
||||
public abstract void checkClientTrusted(X509Certificate[] chain,
|
||||
String authType, String hostname, String algorithm)
|
||||
throws CertificateException;
|
||||
|
||||
/**
|
||||
* Given the partial or complete certificate chain provided by the
|
||||
* peer, check its identity and build a certificate path to a trusted
|
||||
* root, return if it can be validated and is trusted for server SSL
|
||||
* authentication based on the authentication type.
|
||||
* <p>
|
||||
* The authentication type is the key exchange algorithm portion
|
||||
* of the cipher suites represented as a String, such as "RSA",
|
||||
* "DHE_DSS". Checking is case-sensitive.
|
||||
* <p>
|
||||
* The algorithm parameter specifies the server identification protocol
|
||||
* to use. If the algorithm and the peer hostname are available, the
|
||||
* peer hostname is checked against the peer's identity presented in
|
||||
* the X509 certificate, in order to prevent masquerade attacks.
|
||||
*
|
||||
* @param chain the peer certificate chain
|
||||
* @param authType the key exchange algorithm used
|
||||
* @param hostname the peer hostname
|
||||
* @param algorithm the identification algorithm
|
||||
* @throws IllegalArgumentException if null or zero-length chain
|
||||
* is passed in for the chain parameter or if null or zero-length
|
||||
* string is passed in for the authType parameter
|
||||
* @throws CertificateException if the certificate chain is not trusted
|
||||
* by this TrustManager.
|
||||
*/
|
||||
public abstract void checkServerTrusted(X509Certificate[] chain,
|
||||
String authType, String hostname, String algorithm)
|
||||
throws CertificateException;
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.net.ssl.internal.www.protocol.https;
|
||||
|
||||
import java.net.URL;
|
||||
import java.net.Proxy;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Iterator;
|
||||
|
||||
import java.security.Principal;
|
||||
import java.security.cert.*;
|
||||
|
||||
import javax.security.auth.x500.X500Principal;
|
||||
|
||||
import sun.security.util.HostnameChecker;
|
||||
import sun.security.util.DerValue;
|
||||
import sun.security.x509.X500Name;
|
||||
|
||||
import sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection;
|
||||
|
||||
/**
|
||||
* This class was introduced to provide an additional level of
|
||||
* abstraction between javax.net.ssl.HttpURLConnection and
|
||||
* com.sun.net.ssl.HttpURLConnection objects. <p>
|
||||
*
|
||||
* javax.net.ssl.HttpURLConnection is used in the new sun.net version
|
||||
* of protocol implementation (this one)
|
||||
* com.sun.net.ssl.HttpURLConnection is used in the com.sun version.
|
||||
*
|
||||
*/
|
||||
public class DelegateHttpsURLConnection extends AbstractDelegateHttpsURLConnection {
|
||||
|
||||
// we need a reference to the HttpsURLConnection to get
|
||||
// the properties set there
|
||||
// we also need it to be public so that it can be referenced
|
||||
// from sun.net.www.protocol.http.HttpURLConnection
|
||||
// this is for ResponseCache.put(URI, URLConnection)
|
||||
// second parameter needs to be cast to javax.net.ssl.HttpsURLConnection
|
||||
// instead of AbstractDelegateHttpsURLConnection
|
||||
public com.sun.net.ssl.HttpsURLConnection httpsURLConnection;
|
||||
|
||||
DelegateHttpsURLConnection(URL url,
|
||||
sun.net.www.protocol.http.Handler handler,
|
||||
com.sun.net.ssl.HttpsURLConnection httpsURLConnection)
|
||||
throws IOException {
|
||||
this(url, null, handler, httpsURLConnection);
|
||||
}
|
||||
|
||||
DelegateHttpsURLConnection(URL url, Proxy p,
|
||||
sun.net.www.protocol.http.Handler handler,
|
||||
com.sun.net.ssl.HttpsURLConnection httpsURLConnection)
|
||||
throws IOException {
|
||||
super(url, p, handler);
|
||||
this.httpsURLConnection = httpsURLConnection;
|
||||
}
|
||||
|
||||
protected javax.net.ssl.SSLSocketFactory getSSLSocketFactory() {
|
||||
return httpsURLConnection.getSSLSocketFactory();
|
||||
}
|
||||
|
||||
protected javax.net.ssl.HostnameVerifier getHostnameVerifier() {
|
||||
// note: getHostnameVerifier() never returns null
|
||||
return new VerifierWrapper(httpsURLConnection.getHostnameVerifier());
|
||||
}
|
||||
|
||||
/*
|
||||
* Called by layered delegator's finalize() method to handle closing
|
||||
* the underlying object.
|
||||
*/
|
||||
protected void dispose() throws Throwable {
|
||||
super.finalize();
|
||||
}
|
||||
}
|
||||
|
||||
class VerifierWrapper implements javax.net.ssl.HostnameVerifier {
|
||||
|
||||
private com.sun.net.ssl.HostnameVerifier verifier;
|
||||
|
||||
VerifierWrapper(com.sun.net.ssl.HostnameVerifier verifier) {
|
||||
this.verifier = verifier;
|
||||
}
|
||||
|
||||
/*
|
||||
* In com.sun.net.ssl.HostnameVerifier the method is defined
|
||||
* as verify(String urlHostname, String certHostname).
|
||||
* This means we need to extract the hostname from the X.509 certificate
|
||||
* or from the Kerberos principal name, in this wrapper.
|
||||
*/
|
||||
public boolean verify(String hostname, javax.net.ssl.SSLSession session) {
|
||||
try {
|
||||
String serverName;
|
||||
// Use ciphersuite to determine whether Kerberos is active.
|
||||
if (session.getCipherSuite().startsWith("TLS_KRB5")) {
|
||||
serverName =
|
||||
HostnameChecker.getServerName(getPeerPrincipal(session));
|
||||
|
||||
} else { // X.509
|
||||
Certificate[] serverChain = session.getPeerCertificates();
|
||||
if ((serverChain == null) || (serverChain.length == 0)) {
|
||||
return false;
|
||||
}
|
||||
if (serverChain[0] instanceof X509Certificate == false) {
|
||||
return false;
|
||||
}
|
||||
X509Certificate serverCert = (X509Certificate)serverChain[0];
|
||||
serverName = getServername(serverCert);
|
||||
}
|
||||
if (serverName == null) {
|
||||
return false;
|
||||
}
|
||||
return verifier.verify(hostname, serverName);
|
||||
} catch (javax.net.ssl.SSLPeerUnverifiedException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the peer principal from the session
|
||||
*/
|
||||
private Principal getPeerPrincipal(javax.net.ssl.SSLSession session)
|
||||
throws javax.net.ssl.SSLPeerUnverifiedException
|
||||
{
|
||||
Principal principal;
|
||||
try {
|
||||
principal = session.getPeerPrincipal();
|
||||
} catch (AbstractMethodError e) {
|
||||
// if the provider does not support it, return null, since
|
||||
// we need it only for Kerberos.
|
||||
principal = null;
|
||||
}
|
||||
return principal;
|
||||
}
|
||||
|
||||
/*
|
||||
* Extract the name of the SSL server from the certificate.
|
||||
*
|
||||
* Note this code is essentially a subset of the hostname extraction
|
||||
* code in HostnameChecker.
|
||||
*/
|
||||
private static String getServername(X509Certificate peerCert) {
|
||||
try {
|
||||
// compare to subjectAltNames if dnsName is present
|
||||
Collection<List<?>> subjAltNames = peerCert.getSubjectAlternativeNames();
|
||||
if (subjAltNames != null) {
|
||||
for (Iterator<List<?>> itr = subjAltNames.iterator(); itr.hasNext(); ) {
|
||||
List<?> next = itr.next();
|
||||
if (((Integer)next.get(0)).intValue() == 2) {
|
||||
// compare dNSName with host in url
|
||||
String dnsName = ((String)next.get(1));
|
||||
return dnsName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// else check against common name in the subject field
|
||||
X500Name subject = HostnameChecker.getSubjectX500Name(peerCert);
|
||||
|
||||
DerValue derValue = subject.findMostSpecificAttribute
|
||||
(X500Name.commonName_oid);
|
||||
if (derValue != null) {
|
||||
try {
|
||||
String name = derValue.getAsString();
|
||||
return name;
|
||||
} catch (IOException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
} catch (java.security.cert.CertificateException e) {
|
||||
// ignore
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.net.ssl.internal.www.protocol.https;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.net.Proxy;
|
||||
|
||||
/**
|
||||
* This class exists for compatibility with previous JSSE releases
|
||||
* only. The HTTPS implementation can now be found in
|
||||
* sun.net.www.protocol.https.
|
||||
*
|
||||
*/
|
||||
public class Handler extends sun.net.www.protocol.https.Handler {
|
||||
|
||||
public Handler() {
|
||||
super();
|
||||
}
|
||||
|
||||
public Handler(String proxy, int port) {
|
||||
super(proxy, port);
|
||||
}
|
||||
|
||||
protected java.net.URLConnection openConnection(URL u) throws IOException {
|
||||
return openConnection(u, (Proxy)null);
|
||||
}
|
||||
|
||||
protected java.net.URLConnection openConnection(URL u, Proxy p) throws IOException {
|
||||
return new HttpsURLConnectionOldImpl(u, p, this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,517 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* NOTE: This class lives in the package sun.net.www.protocol.https.
|
||||
* There is a copy in com.sun.net.ssl.internal.www.protocol.https for JSSE
|
||||
* 1.0.2 compatibility. It is 100% identical except the package and extends
|
||||
* lines. Any changes should be made to be class in sun.net.* and then copied
|
||||
* to com.sun.net.*.
|
||||
*/
|
||||
|
||||
// For both copies of the file, uncomment one line and comment the other
|
||||
// package sun.net.www.protocol.https;
|
||||
package com.sun.net.ssl.internal.www.protocol.https;
|
||||
|
||||
import java.net.URL;
|
||||
import java.net.Proxy;
|
||||
import java.net.ProtocolException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.io.*;
|
||||
import javax.net.ssl.*;
|
||||
import java.security.Permission;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import sun.net.www.http.HttpClient;
|
||||
|
||||
/**
|
||||
* A class to represent an HTTP connection to a remote object.
|
||||
*
|
||||
* Ideally, this class should subclass and inherit the http handler
|
||||
* implementation, but it can't do so because that class have the
|
||||
* wrong Java Type. Thus it uses the delegate (aka, the
|
||||
* Adapter/Wrapper design pattern) to reuse code from the http
|
||||
* handler.
|
||||
*
|
||||
* Since it would use a delegate to access
|
||||
* sun.net.www.protocol.http.HttpURLConnection functionalities, it
|
||||
* needs to implement all public methods in it's super class and all
|
||||
* the way to Object.
|
||||
*
|
||||
*/
|
||||
|
||||
// For both copies of the file, uncomment one line and comment the other
|
||||
// public class HttpsURLConnectionImpl
|
||||
// extends javax.net.ssl.HttpsURLConnection {
|
||||
public class HttpsURLConnectionOldImpl
|
||||
extends com.sun.net.ssl.HttpsURLConnection {
|
||||
|
||||
private DelegateHttpsURLConnection delegate;
|
||||
|
||||
// For both copies of the file, uncomment one line and comment the other
|
||||
// HttpsURLConnectionImpl(URL u, Handler handler) throws IOException {
|
||||
HttpsURLConnectionOldImpl(URL u, Handler handler) throws IOException {
|
||||
this(u, null, handler);
|
||||
}
|
||||
|
||||
static URL checkURL(URL u) throws IOException {
|
||||
if (u != null) {
|
||||
if (u.toExternalForm().indexOf('\n') > -1) {
|
||||
throw new MalformedURLException("Illegal character in URL");
|
||||
}
|
||||
}
|
||||
return u;
|
||||
}
|
||||
// For both copies of the file, uncomment one line and comment the other
|
||||
// HttpsURLConnectionImpl(URL u, Handler handler) throws IOException {
|
||||
HttpsURLConnectionOldImpl(URL u, Proxy p, Handler handler) throws IOException {
|
||||
super(checkURL(u));
|
||||
delegate = new DelegateHttpsURLConnection(url, p, handler, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new HttpClient object, bypassing the cache of
|
||||
* HTTP client objects/connections.
|
||||
*
|
||||
* @param url the URL being accessed
|
||||
*/
|
||||
protected void setNewClient(URL url) throws IOException {
|
||||
delegate.setNewClient(url, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain a HttpClient object. Use the cached copy if specified.
|
||||
*
|
||||
* @param url the URL being accessed
|
||||
* @param useCache whether the cached connection should be used
|
||||
* if present
|
||||
*/
|
||||
protected void setNewClient(URL url, boolean useCache)
|
||||
throws IOException {
|
||||
delegate.setNewClient(url, useCache);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new HttpClient object, set up so that it uses
|
||||
* per-instance proxying to the given HTTP proxy. This
|
||||
* bypasses the cache of HTTP client objects/connections.
|
||||
*
|
||||
* @param url the URL being accessed
|
||||
* @param proxyHost the proxy host to use
|
||||
* @param proxyPort the proxy port to use
|
||||
*/
|
||||
protected void setProxiedClient(URL url, String proxyHost, int proxyPort)
|
||||
throws IOException {
|
||||
delegate.setProxiedClient(url, proxyHost, proxyPort);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain a HttpClient object, set up so that it uses per-instance
|
||||
* proxying to the given HTTP proxy. Use the cached copy of HTTP
|
||||
* client objects/connections if specified.
|
||||
*
|
||||
* @param url the URL being accessed
|
||||
* @param proxyHost the proxy host to use
|
||||
* @param proxyPort the proxy port to use
|
||||
* @param useCache whether the cached connection should be used
|
||||
* if present
|
||||
*/
|
||||
protected void setProxiedClient(URL url, String proxyHost, int proxyPort,
|
||||
boolean useCache) throws IOException {
|
||||
delegate.setProxiedClient(url, proxyHost, proxyPort, useCache);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements the HTTP protocol handler's "connect" method,
|
||||
* establishing an SSL connection to the server as necessary.
|
||||
*/
|
||||
public void connect() throws IOException {
|
||||
delegate.connect();
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by subclass to access "connected" variable. Since we are
|
||||
* delegating the actual implementation to "delegate", we need to
|
||||
* delegate the access of "connected" as well.
|
||||
*/
|
||||
protected boolean isConnected() {
|
||||
return delegate.isConnected();
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by subclass to access "connected" variable. Since we are
|
||||
* delegating the actual implementation to "delegate", we need to
|
||||
* delegate the access of "connected" as well.
|
||||
*/
|
||||
protected void setConnected(boolean conn) {
|
||||
delegate.setConnected(conn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the cipher suite in use on this connection.
|
||||
*/
|
||||
public String getCipherSuite() {
|
||||
return delegate.getCipherSuite();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the certificate chain the client sent to the
|
||||
* server, or null if the client did not authenticate.
|
||||
*/
|
||||
public java.security.cert.Certificate []
|
||||
getLocalCertificates() {
|
||||
return delegate.getLocalCertificates();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the server's certificate chain, or throws
|
||||
* SSLPeerUnverified Exception if
|
||||
* the server did not authenticate.
|
||||
*/
|
||||
public java.security.cert.Certificate []
|
||||
getServerCertificates() throws SSLPeerUnverifiedException {
|
||||
return delegate.getServerCertificates();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the server's X.509 certificate chain, or null if
|
||||
* the server did not authenticate.
|
||||
*
|
||||
* NOTE: This method is not necessary for the version of this class
|
||||
* implementing javax.net.ssl.HttpsURLConnection, but provided for
|
||||
* compatibility with the com.sun.net.ssl.HttpsURLConnection version.
|
||||
*/
|
||||
public javax.security.cert.X509Certificate[] getServerCertificateChain() {
|
||||
try {
|
||||
return delegate.getServerCertificateChain();
|
||||
} catch (SSLPeerUnverifiedException e) {
|
||||
// this method does not throw an exception as declared in
|
||||
// com.sun.net.ssl.HttpsURLConnection.
|
||||
// Return null for compatibility.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Allowable input/output sequences:
|
||||
* [interpreted as POST/PUT]
|
||||
* - get output, [write output,] get input, [read input]
|
||||
* - get output, [write output]
|
||||
* [interpreted as GET]
|
||||
* - get input, [read input]
|
||||
* Disallowed:
|
||||
* - get input, [read input,] get output, [write output]
|
||||
*/
|
||||
|
||||
public synchronized OutputStream getOutputStream() throws IOException {
|
||||
return delegate.getOutputStream();
|
||||
}
|
||||
|
||||
public synchronized InputStream getInputStream() throws IOException {
|
||||
return delegate.getInputStream();
|
||||
}
|
||||
|
||||
public InputStream getErrorStream() {
|
||||
return delegate.getErrorStream();
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnect from the server.
|
||||
*/
|
||||
public void disconnect() {
|
||||
delegate.disconnect();
|
||||
}
|
||||
|
||||
public boolean usingProxy() {
|
||||
return delegate.usingProxy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an unmodifiable Map of the header fields.
|
||||
* The Map keys are Strings that represent the
|
||||
* response-header field names. Each Map value is an
|
||||
* unmodifiable List of Strings that represents
|
||||
* the corresponding field values.
|
||||
*
|
||||
* @return a Map of header fields
|
||||
* @since 1.4
|
||||
*/
|
||||
public Map<String,List<String>> getHeaderFields() {
|
||||
return delegate.getHeaderFields();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a header field by name. Returns null if not known.
|
||||
* @param name the name of the header field
|
||||
*/
|
||||
public String getHeaderField(String name) {
|
||||
return delegate.getHeaderField(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a header field by index. Returns null if not known.
|
||||
* @param n the index of the header field
|
||||
*/
|
||||
public String getHeaderField(int n) {
|
||||
return delegate.getHeaderField(n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a header field by index. Returns null if not known.
|
||||
* @param n the index of the header field
|
||||
*/
|
||||
public String getHeaderFieldKey(int n) {
|
||||
return delegate.getHeaderFieldKey(n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets request property. If a property with the key already
|
||||
* exists, overwrite its value with the new value.
|
||||
* @param value the value to be set
|
||||
*/
|
||||
public void setRequestProperty(String key, String value) {
|
||||
delegate.setRequestProperty(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a general request property specified by a
|
||||
* key-value pair. This method will not overwrite
|
||||
* existing values associated with the same key.
|
||||
*
|
||||
* @param key the keyword by which the request is known
|
||||
* (e.g., "<code>accept</code>").
|
||||
* @param value the value associated with it.
|
||||
* @see #getRequestProperties(java.lang.String)
|
||||
* @since 1.4
|
||||
*/
|
||||
public void addRequestProperty(String key, String value) {
|
||||
delegate.addRequestProperty(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrite super class method
|
||||
*/
|
||||
public int getResponseCode() throws IOException {
|
||||
return delegate.getResponseCode();
|
||||
}
|
||||
|
||||
public String getRequestProperty(String key) {
|
||||
return delegate.getRequestProperty(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an unmodifiable Map of general request
|
||||
* properties for this connection. The Map keys
|
||||
* are Strings that represent the request-header
|
||||
* field names. Each Map value is a unmodifiable List
|
||||
* of Strings that represents the corresponding
|
||||
* field values.
|
||||
*
|
||||
* @return a Map of the general request properties for this connection.
|
||||
* @throws IllegalStateException if already connected
|
||||
* @since 1.4
|
||||
*/
|
||||
public Map<String,List<String>> getRequestProperties() {
|
||||
return delegate.getRequestProperties();
|
||||
}
|
||||
|
||||
/*
|
||||
* We support JDK 1.2.x so we can't count on these from JDK 1.3.
|
||||
* We override and supply our own version.
|
||||
*/
|
||||
public void setInstanceFollowRedirects(boolean shouldFollow) {
|
||||
delegate.setInstanceFollowRedirects(shouldFollow);
|
||||
}
|
||||
|
||||
public boolean getInstanceFollowRedirects() {
|
||||
return delegate.getInstanceFollowRedirects();
|
||||
}
|
||||
|
||||
public void setRequestMethod(String method) throws ProtocolException {
|
||||
delegate.setRequestMethod(method);
|
||||
}
|
||||
|
||||
public String getRequestMethod() {
|
||||
return delegate.getRequestMethod();
|
||||
}
|
||||
|
||||
public String getResponseMessage() throws IOException {
|
||||
return delegate.getResponseMessage();
|
||||
}
|
||||
|
||||
public long getHeaderFieldDate(String name, long Default) {
|
||||
return delegate.getHeaderFieldDate(name, Default);
|
||||
}
|
||||
|
||||
public Permission getPermission() throws IOException {
|
||||
return delegate.getPermission();
|
||||
}
|
||||
|
||||
public URL getURL() {
|
||||
return delegate.getURL();
|
||||
}
|
||||
|
||||
public int getContentLength() {
|
||||
return delegate.getContentLength();
|
||||
}
|
||||
|
||||
public long getContentLengthLong() {
|
||||
return delegate.getContentLengthLong();
|
||||
}
|
||||
|
||||
public String getContentType() {
|
||||
return delegate.getContentType();
|
||||
}
|
||||
|
||||
public String getContentEncoding() {
|
||||
return delegate.getContentEncoding();
|
||||
}
|
||||
|
||||
public long getExpiration() {
|
||||
return delegate.getExpiration();
|
||||
}
|
||||
|
||||
public long getDate() {
|
||||
return delegate.getDate();
|
||||
}
|
||||
|
||||
public long getLastModified() {
|
||||
return delegate.getLastModified();
|
||||
}
|
||||
|
||||
public int getHeaderFieldInt(String name, int Default) {
|
||||
return delegate.getHeaderFieldInt(name, Default);
|
||||
}
|
||||
|
||||
public long getHeaderFieldLong(String name, long Default) {
|
||||
return delegate.getHeaderFieldLong(name, Default);
|
||||
}
|
||||
|
||||
public Object getContent() throws IOException {
|
||||
return delegate.getContent();
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public Object getContent(Class[] classes) throws IOException {
|
||||
return delegate.getContent(classes);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return delegate.toString();
|
||||
}
|
||||
|
||||
public void setDoInput(boolean doinput) {
|
||||
delegate.setDoInput(doinput);
|
||||
}
|
||||
|
||||
public boolean getDoInput() {
|
||||
return delegate.getDoInput();
|
||||
}
|
||||
|
||||
public void setDoOutput(boolean dooutput) {
|
||||
delegate.setDoOutput(dooutput);
|
||||
}
|
||||
|
||||
public boolean getDoOutput() {
|
||||
return delegate.getDoOutput();
|
||||
}
|
||||
|
||||
public void setAllowUserInteraction(boolean allowuserinteraction) {
|
||||
delegate.setAllowUserInteraction(allowuserinteraction);
|
||||
}
|
||||
|
||||
public boolean getAllowUserInteraction() {
|
||||
return delegate.getAllowUserInteraction();
|
||||
}
|
||||
|
||||
public void setUseCaches(boolean usecaches) {
|
||||
delegate.setUseCaches(usecaches);
|
||||
}
|
||||
|
||||
public boolean getUseCaches() {
|
||||
return delegate.getUseCaches();
|
||||
}
|
||||
|
||||
public void setIfModifiedSince(long ifmodifiedsince) {
|
||||
delegate.setIfModifiedSince(ifmodifiedsince);
|
||||
}
|
||||
|
||||
public long getIfModifiedSince() {
|
||||
return delegate.getIfModifiedSince();
|
||||
}
|
||||
|
||||
public boolean getDefaultUseCaches() {
|
||||
return delegate.getDefaultUseCaches();
|
||||
}
|
||||
|
||||
public void setDefaultUseCaches(boolean defaultusecaches) {
|
||||
delegate.setDefaultUseCaches(defaultusecaches);
|
||||
}
|
||||
|
||||
/*
|
||||
* finalize (dispose) the delegated object. Otherwise
|
||||
* sun.net.www.protocol.http.HttpURLConnection's finalize()
|
||||
* would have to be made public.
|
||||
*/
|
||||
protected void finalize() throws Throwable {
|
||||
delegate.dispose();
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
return delegate.equals(obj);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return delegate.hashCode();
|
||||
}
|
||||
|
||||
public void setConnectTimeout(int timeout) {
|
||||
delegate.setConnectTimeout(timeout);
|
||||
}
|
||||
|
||||
public int getConnectTimeout() {
|
||||
return delegate.getConnectTimeout();
|
||||
}
|
||||
|
||||
public void setReadTimeout(int timeout) {
|
||||
delegate.setReadTimeout(timeout);
|
||||
}
|
||||
|
||||
public int getReadTimeout() {
|
||||
return delegate.getReadTimeout();
|
||||
}
|
||||
|
||||
public void setFixedLengthStreamingMode (int contentLength) {
|
||||
delegate.setFixedLengthStreamingMode(contentLength);
|
||||
}
|
||||
|
||||
public void setFixedLengthStreamingMode(long contentLength) {
|
||||
delegate.setFixedLengthStreamingMode(contentLength);
|
||||
}
|
||||
|
||||
public void setChunkedStreamingMode (int chunklen) {
|
||||
delegate.setChunkedStreamingMode(chunklen);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user