Package anbxj

Class Channel_SSLChannelUtils

java.lang.Object
anbxj.Channel_SSLChannelUtils

public final class Channel_SSLChannelUtils extends Object
Utility methods for SSL/TLS channel setup, eliminating duplication across client, server, proto-server and multi-threaded server implementations.
  • Method Details

    • createSSLContext

      public static SSLContext createSSLContext(Channel_Properties cp)
      Builds an SSLContext from the keystore settings and algorithm embedded in the given Channel_Properties.
      Parameters:
      cp - the channel properties (must contain TLS keystore settings)
      Returns:
      a fully initialised SSLContext
      Throws:
      RuntimeException - if the context cannot be created
    • wrapSocket

      public static SSLSocket wrapSocket(Socket plainSocket, Channel_Properties cp, boolean clientMode) throws IOException
      Wraps an existing plain TCP socket in a TLS/SSL connection, performing the full handshake. This replaces the previous static method in Channel_SSLContextBuilder and the inline logic in Channel_Server.openStream(int).
      Parameters:
      plainSocket - the already-connected plain socket to upgrade
      cp - channel properties determining SSL type, cipher suites, etc.
      clientMode - true to set the socket into client mode, false for server mode
      Returns:
      the handshaken SSLSocket
      Throws:
      IOException - if the handshake fails or the socket cannot be wrapped
    • createSSLServerSocket

      public static SSLServerSocket createSSLServerSocket(int port, Channel_Properties cp) throws IOException
      Creates and configures an SSLServerSocket using the channel properties. This can be used directly by Channel_ProtoServer and Channel_MultiThreadedServer.
      Parameters:
      port - the port to listen on
      cp - the channel properties (used for cipher suites, client auth, etc.)
      Returns:
      a configured SSLServerSocket
      Throws:
      IOException - if the server socket cannot be created
    • filterCipherSuites

      public static String[] filterCipherSuites(Channel_SSLChannelType type, String[] supported)
      Filters the given list of supported cipher suites according to the desired SSL channel type. This replaces the logic previously in Channel_Settings.getEnabledCipherSuites(java.lang.String[]).
      Parameters:
      type - the SSL channel type (determines which suites are allowed)
      supported - all supported suites (must not be null)
      Returns:
      the filtered array of suites to enable (never null)
      Throws:
      NullPointerException - if supported is null