Java in a Nutshell, 5th Edition [Electronic resources]

نسخه متنی -صفحه : 1191/ 976
نمايش فراداده

SSLSocketFactoryjavax.net.ssl

Java 1.4

This class is a javax.net.SocketFactory for creating SSLSocket objects. Most applications use the default SSLSocketFactory returned by the static getdefault( ) method. Once this SSLSocketFactory has been obtained, they use one of the inherited createSocket( ) methods to create, and optionally connect and bind, a new SSLSocket. The return value of the createSocket( ) methods is a java.net.Socket object, but you can safely cast this object to a SSLSocket if you need to. SSLSocketFactory defines one new version of createSocket( ) in addition to the ones it inherits from its superclass. This version of the method creates an SSLSocket that is layered over an existing Socket object rather than creating a new socket entirely from scratch.

Applications that need to customize the SSL configuration and cannot use the default socket factory may obtain a custom SSLSocketFactory from an SSLContext, which is essentially a factory for socket factories. See SSLContext for details.

Figure 18-17. javax.net.ssl.SSLSocketFactory

public abstract class

SSLSocketFactory extends javax.net.SocketFactory { // Public Constructors public

SSLSocketFactory ( ); // Public Class Methods public static javax.net.SocketFactory

getDefault ( ); synchronized // Public Instance Methods public abstract java.net.Socket

createSocket (java.net.Socket

s , String

host , int

port , boolean

autoClose ) throws java.io.IOException; public abstract String[ ]

getDefaultCipherSuites ( ); public abstract String[ ]

getSupportedCipherSuites ( ); }

Passed To

HttpsURLConnection.{setDefaultSSLSocketFactory( ), setSSLSocketFactory( )}

Returned By

HttpsURLConnection.{getDefaultSSLSocketFactory( ), getSSLSocketFactory( )}, SSLContext.getSocketFactory( ), SSLContextSpi.engineGetSocketFactory( )