DelegatingSSLSocketFactory (Apache Hadoop Common 3.5.0 API)
Description: declaration: package: org.apache.hadoop.security.ssl, class: DelegatingSSLSocketFactory

Package org.apache.hadoop.security.ssl

# Class DelegatingSSLSocketFactory

java.lang.Object
javax.net.SocketFactory
javax.net.ssl.SSLSocketFactory
org.apache.hadoop.security.ssl.DelegatingSSLSocketFactory

public final class DelegatingSSLSocketFactory extends SSLSocketFactory
A `SSLSocketFactory` that can delegate to various SSL implementations. Specifically, either OpenSSL or JSSE can be used. OpenSSL offers better performance than JSSE and is made available via the wildlfy-openssl library.

The factory has several different modes of operation:

- OpenSSL: Uses the wildly-openssl library to delegate to the system installed OpenSSL. If the wildfly-openssl integration is not properly setup, an exception is thrown.
- Default: Attempts to use the OpenSSL mode, if it cannot load the necessary libraries, it falls back to the Default_JSEE mode.
- Default_JSSE: Delegates to the JSSE implementation of SSL, but it disables the GCM cipher when running on Java 8.
- Default_JSSE_with_GCM: Delegates to the JSSE implementation of SSL with no modification to the list of enabled ciphers.

In order to load OpenSSL, applications must ensure the wildfly-openssl artifact is on the classpath. Currently, only ABFS declares wildfly-openssl as an explicit dependency.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static enum`
  `DelegatingSSLSocketFactory.SSLChannelMode`
  Default indicates Ordered, preferred OpenSSL, if failed to load then fall back to Default_JSSE.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Socket`
  `createSocket()`
  `Socket`
  `createSocket(String host, int port)`
  `Socket`
  `createSocket(String host, int port, InetAddress localHost, int localPort)`
  `Socket`
  `createSocket(InetAddress host, int port)`
  `Socket`
  `createSocket(InetAddress address, int port, InetAddress localAddress, int localPort)`
  `Socket`
  `createSocket(Socket s, String host, int port, boolean autoClose)`
  `DelegatingSSLSocketFactory.SSLChannelMode`
  `getChannelMode()`
  Get the channel mode of this instance.
  `String[]`
  `getDefaultCipherSuites()`
  `static DelegatingSSLSocketFactory`
  `getDefaultFactory()`
  Singleton instance of the SSLSocketFactory.
  `String`
  `getProviderName()`
  `String[]`
  `getSupportedCipherSuites()`
  `static void`
  `initializeDefaultFactory(DelegatingSSLSocketFactory.SSLChannelMode preferredMode)`
  Initialize a singleton SSL socket factory.
  `static void`
  `resetDefaultFactory()`
  For testing only: reset the socket factory.

  ### Methods inherited from class javax.net.ssl.SSLSocketFactory

  `createSocket, getDefault`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### initializeDefaultFactory

    public static void initializeDefaultFactory(DelegatingSSLSocketFactory.SSLChannelMode preferredMode) throws IOException
    Initialize a singleton SSL socket factory.
    Parameters:
      `preferredMode` - applicable only if the instance is not initialized.
    Throws:
      `IOException` - if an error occurs.

  - ### resetDefaultFactory

    @VisibleForTesting public static void resetDefaultFactory()
    For testing only: reset the socket factory.

  - ### getDefaultFactory

    public static DelegatingSSLSocketFactory getDefaultFactory()
    Singleton instance of the SSLSocketFactory. SSLSocketFactory must be initialized with appropriate SSLChannelMode using initializeDefaultFactory method.
    Returns:
      instance of the SSLSocketFactory, instance must be initialized by initializeDefaultFactory.

  - ### getProviderName

    public String getProviderName()

  - ### getDefaultCipherSuites

    public String[] getDefaultCipherSuites()
    Specified by:
      `getDefaultCipherSuites` in class `SSLSocketFactory`

  - ### getSupportedCipherSuites

    public String[] getSupportedCipherSuites()
    Specified by:
      `getSupportedCipherSuites` in class `SSLSocketFactory`

  - ### getChannelMode

    public DelegatingSSLSocketFactory.SSLChannelMode getChannelMode()
    Get the channel mode of this instance.
    Returns:
      a channel mode.

  - ### createSocket

    public Socket createSocket() throws IOException
    Overrides:
      `createSocket` in class `SocketFactory`
    Throws:
      `IOException`

  - ### createSocket

    public Socket createSocket(Socket s, String host, int port, boolean autoClose) throws IOException
    Specified by:
      `createSocket` in class `SSLSocketFactory`
    Throws:
      `IOException`

  - ### createSocket

    public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort) throws IOException
    Specified by:
      `createSocket` in class `SocketFactory`
    Throws:
      `IOException`

  - ### createSocket

    public Socket createSocket(String host, int port, InetAddress localHost, int localPort) throws IOException
    Specified by:
      `createSocket` in class `SocketFactory`
    Throws:
      `IOException`

  - ### createSocket

    public Socket createSocket(InetAddress host, int port) throws IOException
    Specified by:
      `createSocket` in class `SocketFactory`
    Throws:
      `IOException`

  - ### createSocket

    public Socket createSocket(String host, int port) throws IOException
    Specified by:
      `createSocket` in class `SocketFactory`
    Throws:
      `IOException`