FileDocCategorySizeDatePackage
HttpsURLConnection.javaAPI DocAndroid 1.5 API8373Wed May 06 22:41:06 BST 2009javax.net.ssl

HttpsURLConnection

public abstract class HttpsURLConnection extends HttpURLConnection
This abstract subclass of {@code HttpURLConnection} defines methods for managing HTTPS connections according to the description given by RFC 2818.
since
Android 1.0

Fields Summary
private static HostnameVerifier
defaultHostnameVerifier
private static SSLSocketFactory
defaultSSLSocketFactory
protected HostnameVerifier
hostnameVerifier
The host name verifier used by this connection. It is initialized from the default hostname verifier {@link #setDefaultHostnameVerifier(HostnameVerifier)} or {@link #getDefaultHostnameVerifier()}.
private static SSLSocketFactory
socketFactory
Constructors Summary
protected HttpsURLConnection(URL url)
Creates a new {@code HttpsURLConnection} with the specified {@code URL}.

param
url the {@code URL} to connect to.
since
Android 1.0


                                          
       
        super(url);
        hostnameVerifier = defaultHostnameVerifier;
        socketFactory = defaultSSLSocketFactory;
    
Methods Summary
public abstract java.lang.StringgetCipherSuite()
Returns the name of the cipher suite negotiated during the SSL handshake.

return
the name of the cipher suite negotiated during the SSL handshake.
throws
IllegalStateException if no connection has been established yet.
since
Android 1.0

public static javax.net.ssl.HostnameVerifiergetDefaultHostnameVerifier()
Returns the default hostname verifier.

return
the default hostname verifier.
since
Android 1.0

        return defaultHostnameVerifier;
    
public static javax.net.ssl.SSLSocketFactorygetDefaultSSLSocketFactory()
Returns the default SSL socket factory for new instances.

return
the default SSL socket factory for new instances.
since
Android 1.0

        return defaultSSLSocketFactory;
    
public javax.net.ssl.HostnameVerifiergetHostnameVerifier()
Returns the hostname verifier used by this instance.

return
the hostname verifier used by this instance.
since
Android 1.0

        return hostnameVerifier;
    
public abstract java.security.cert.Certificate[]getLocalCertificates()
Returns the list of local certificates used during the handshake. These certificates were sent to the peer.

return
Returns the list of certificates used during the handshake with the local identity certificate followed by CAs, or {@code null} if no certificates were used during the handshake.
throws
IllegalStateException if no connection has been established yet.
since
Android 1.0

public java.security.PrincipalgetLocalPrincipal()
Returns the {@code Principal} used to identify the local host during the handshake.

return
the {@code Principal} used to identify the local host during the handshake, or {@code null} if none was used.
throws
IllegalStateException if no connection has been established yet.
since
Android 1.0

        Certificate[] certs = getLocalCertificates();
        if (certs == null || certs.length == 0
                || (!(certs[0] instanceof X509Certificate))) {
            return null;
        }
        return ((X509Certificate) certs[0]).getSubjectX500Principal();
    
public java.security.PrincipalgetPeerPrincipal()
Returns the {@code Principal} identifying the peer.

return
the {@code Principal} identifying the peer.
throws
SSLPeerUnverifiedException if the identity of the peer has not been verified.
throws
IllegalStateException if no connection has been established yet.
since
Android 1.0

        Certificate[] certs = getServerCertificates();
        if (certs == null || certs.length == 0 || 
                (!(certs[0] instanceof X509Certificate))) {
            throw new SSLPeerUnverifiedException(
                    "No server's end-entity certificate");
        }
        return ((X509Certificate) certs[0]).getSubjectX500Principal();
    
public javax.net.ssl.SSLSocketFactorygetSSLSocketFactory()
Returns the SSL socket factory used by this instance.

return
the SSL socket factory used by this instance.
since
Android 1.0

        return socketFactory;
    
public abstract java.security.cert.Certificate[]getServerCertificates()
Return the list of certificates identifying the peer during the handshake.

return
the list of certificates identifying the peer with the peer's identity certificate followed by CAs.
throws
SSLPeerUnverifiedException if the identity of the peer has not been verified..
throws
IllegalStateException if no connection has been established yet.
since
Android 1.0

public static voidsetDefaultHostnameVerifier(javax.net.ssl.HostnameVerifier v)
Sets the default hostname verifier to be used by new instances.

param
v the new default hostname verifier
throws
IllegalArgumentException if the specified verifier is {@code null}.
since
Android 1.0

        if (v == null) {
            throw new IllegalArgumentException("HostnameVerifier is null");
        }
        defaultHostnameVerifier = v;
    
public static voidsetDefaultSSLSocketFactory(javax.net.ssl.SSLSocketFactory sf)
Sets the default SSL socket factory to be used by new instances.

param
sf the new default SSL socket factory.
throws
IllegalArgumentException if the specified socket factory is {@code null}.
since
Android 1.0

        if (sf == null) {
            throw new IllegalArgumentException("SSLSocketFactory is null");
        }
        defaultSSLSocketFactory = sf;
    
public voidsetHostnameVerifier(javax.net.ssl.HostnameVerifier v)
Sets the hostname verifier for this instance.

param
v the hostname verifier for this instance.
throws
IllegalArgumentException if the specified verifier is {@code null}.
since
Android 1.0

        if (v == null) {
            throw new IllegalArgumentException("HostnameVerifier is null");
        }
        hostnameVerifier = v;
    
public voidsetSSLSocketFactory(javax.net.ssl.SSLSocketFactory sf)
Sets the SSL socket factory for this instance.

param
sf the SSL socket factory to be used by this instance.
throws
IllegalArgumentException if the specified socket factory is {@code null}.
since
Android 1.0

        if (sf == null) {
            throw new IllegalArgumentException("SSLSocketFactory is null");
        }
        socketFactory = sf;