HTTPS URL connection support.
We need this delegate because HttpsURLConnection is a subclass of
java.net.HttpURLConnection. We will avoid copying over the code from
sun.net.www.protocol.http.HttpURLConnection by having this class
| Method from sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection Detail: |
public void connect() throws IOException {
if (connected)
return;
plainConnect();
if (cachedResponse != null) {
// using cached response
return;
}
if (!http.isCachedConnection() && http.needsTunneling()) {
doTunneling();
}
((HttpsClient)http).afterConnect();
}
Implements the HTTP protocol handler's "connect" method,
establishing an SSL connection to the server as necessary. |
public String getCipherSuite() {
if (cachedResponse != null) {
return ((SecureCacheResponse)cachedResponse).getCipherSuite();
}
if (http == null) {
throw new IllegalStateException("connection not yet open");
} else {
return ((HttpsClient)http).getCipherSuite ();
}
}
Returns the cipher suite in use on this connection. |
abstract protected HostnameVerifier getHostnameVerifier()
|
public Certificate[] getLocalCertificates() {
if (cachedResponse != null) {
List l = ((SecureCacheResponse)cachedResponse).getLocalCertificateChain();
if (l == null) {
return null;
} else {
return (java.security.cert.Certificate[])l.toArray();
}
}
if (http == null) {
throw new IllegalStateException("connection not yet open");
} else {
return (((HttpsClient)http).getLocalCertificates ());
}
}
Returns the certificate chain the client sent to the
server, or null if the client did not authenticate. |
Principal getLocalPrincipal() {
if (cachedResponse != null) {
return ((SecureCacheResponse)cachedResponse).getLocalPrincipal();
}
if (http == null) {
throw new IllegalStateException("connection not yet open");
} else {
return (((HttpsClient)http).getLocalPrincipal());
}
}
Returns the principal the client sent to the
server, or null if the client did not authenticate. |
protected HttpClient getNewHttpClient(URL url,
Proxy p,
int connectTimeout) throws IOException {
return HttpsClient.New(getSSLSocketFactory(), url,
getHostnameVerifier(), p, true, connectTimeout);
}
|
protected HttpClient getNewHttpClient(URL url,
Proxy p,
int connectTimeout,
boolean useCache) throws IOException {
return HttpsClient.New(getSSLSocketFactory(), url,
getHostnameVerifier(), p,
useCache, connectTimeout);
}
|
Principal getPeerPrincipal() throws SSLPeerUnverifiedException {
if (cachedResponse != null) {
return ((SecureCacheResponse)cachedResponse).getPeerPrincipal();
}
if (http == null) {
throw new IllegalStateException("connection not yet open");
} else {
return (((HttpsClient)http).getPeerPrincipal());
}
}
Returns the server's principal, or throws SSLPeerUnverifiedException
if the server did not authenticate. |
abstract protected SSLSocketFactory getSSLSocketFactory()
|
public X509Certificate[] getServerCertificateChain() throws SSLPeerUnverifiedException {
if (cachedResponse != null) {
throw new UnsupportedOperationException("this method is not supported when using cache");
}
if (http == null) {
throw new IllegalStateException("connection not yet open");
} else {
return ((HttpsClient)http).getServerCertificateChain ();
}
}
Returns the server's X.509 certificate chain, or null if
the server did not authenticate. |
public Certificate[] getServerCertificates() throws SSLPeerUnverifiedException {
if (cachedResponse != null) {
List l = ((SecureCacheResponse)cachedResponse).getServerCertificateChain();
if (l == null) {
return null;
} else {
return (java.security.cert.Certificate[])l.toArray();
}
}
if (http == null) {
throw new IllegalStateException("connection not yet open");
} else {
return (((HttpsClient)http).getServerCertificates ());
}
}
Returns the server's certificate chain, or throws
SSLPeerUnverified Exception if
the server did not authenticate. |
public boolean isConnected() {
return connected;
}
Used by subclass to access "connected" variable. |
protected void proxiedConnect(URL url,
String proxyHost,
int proxyPort,
boolean useCache) throws IOException {
if (connected)
return;
http = HttpsClient.New (getSSLSocketFactory(),
url,
getHostnameVerifier(),
proxyHost, proxyPort, useCache);
connected = true;
}
|
public void setConnected(boolean conn) {
connected = conn;
}
Used by subclass to access "connected" variable. |
public void setNewClient(URL url) throws IOException {
setNewClient (url, false);
}
Create a new HttpClient object, bypassing the cache of
HTTP client objects/connections.
Note: this method is changed from protected to public because
the com.sun.ssl.internal.www.protocol.https handler reuses this
class for its actual implemantation |
public void setNewClient(URL url,
boolean useCache) throws IOException {
http = HttpsClient.New (getSSLSocketFactory(),
url,
getHostnameVerifier(),
useCache);
((HttpsClient)http).afterConnect();
}
Obtain a HttpClient object. Use the cached copy if specified.
Note: this method is changed from protected to public because
the com.sun.ssl.internal.www.protocol.https handler reuses this
class for its actual implemantation |
public void setProxiedClient(URL url,
String proxyHost,
int proxyPort) throws IOException {
setProxiedClient(url, proxyHost, proxyPort, false);
}
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.
Note: this method is changed from protected to public because
the com.sun.ssl.internal.www.protocol.https handler reuses this
class for its actual implemantation |
public void setProxiedClient(URL url,
String proxyHost,
int proxyPort,
boolean useCache) throws IOException {
proxiedConnect(url, proxyHost, proxyPort, useCache);
if (!http.isCachedConnection()) {
doTunneling();
}
((HttpsClient)http).afterConnect();
}
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.
Note: this method is changed from protected to public because
the com.sun.ssl.internal.www.protocol.https handler reuses this
class for its actual implemantation |