Package org.mariadb.jdbc.client
Class ConnectionHelper
- java.lang.Object
-
- org.mariadb.jdbc.client.ConnectionHelper
-
public final class ConnectionHelper extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private static SocketHandlerFunction
socketHandler
-
Constructor Summary
Constructors Constructor Description ConnectionHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
authenticationHandler(Credential credential, PacketWriter writer, PacketReader reader, Context context)
static java.net.Socket
connectSocket(Configuration conf, HostAddress hostAddress)
static java.net.Socket
createSocket(Configuration conf, HostAddress hostAddress)
Create socket accordingly to options.static byte
decideLanguage(InitialHandshakePacket handshake)
Default collation used for string exchanges with server.(package private) static void
enabledSslCipherSuites(javax.net.ssl.SSLSocket sslSocket, Configuration conf)
Set ssl socket cipher according to options.(package private) static void
enabledSslProtocolSuites(javax.net.ssl.SSLSocket sslSocket, Configuration conf)
Return possible protocols : values of option enabledSslProtocolSuites is set, or default to "TLSv1,TLSv1.1".static long
initializeClientCapabilities(Configuration configuration, long serverCapabilities)
static Credential
loadCredential(CredentialPlugin credentialPlugin, Configuration configuration, HostAddress hostAddress)
static javax.net.ssl.SSLSocket
sslWrapper(HostAddress hostAddress, java.net.Socket socket, long clientCapabilities, byte exchangeCharset, Context context, PacketWriter writer)
static java.net.Socket
standardSocket(Configuration conf, HostAddress hostAddress)
Use standard socket implementation.
-
-
-
Field Detail
-
socketHandler
private static final SocketHandlerFunction socketHandler
-
-
Method Detail
-
createSocket
public static java.net.Socket createSocket(Configuration conf, HostAddress hostAddress) throws java.io.IOException, java.sql.SQLException
Create socket accordingly to options.- Parameters:
conf
- Url optionshostAddress
- host ( mandatory but for named pipe / unix socket)- Returns:
- a nex socket
- Throws:
java.io.IOException
- if connection error occurjava.sql.SQLException
- in case of configuration error
-
standardSocket
public static java.net.Socket standardSocket(Configuration conf, HostAddress hostAddress) throws java.io.IOException, java.sql.SQLException
Use standard socket implementation.- Parameters:
conf
- url optionshostAddress
- host to connect- Returns:
- socket
- Throws:
java.io.IOException
- in case of error establishing socket.java.sql.SQLException
- in case host is null
-
connectSocket
public static java.net.Socket connectSocket(Configuration conf, HostAddress hostAddress) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
initializeClientCapabilities
public static long initializeClientCapabilities(Configuration configuration, long serverCapabilities)
-
decideLanguage
public static byte decideLanguage(InitialHandshakePacket handshake)
Default collation used for string exchanges with server. Always return 4 bytes utf8 collation for server that permit it.- Parameters:
handshake
- initial handshake packet- Returns:
- collation byte
-
authenticationHandler
public static void authenticationHandler(Credential credential, PacketWriter writer, PacketReader reader, Context context) throws java.sql.SQLException, java.io.IOException
- Throws:
java.sql.SQLException
java.io.IOException
-
loadCredential
public static Credential loadCredential(CredentialPlugin credentialPlugin, Configuration configuration, HostAddress hostAddress) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
sslWrapper
public static javax.net.ssl.SSLSocket sslWrapper(HostAddress hostAddress, java.net.Socket socket, long clientCapabilities, byte exchangeCharset, Context context, PacketWriter writer) throws java.sql.SQLException, java.io.IOException
- Throws:
java.sql.SQLException
java.io.IOException
-
enabledSslProtocolSuites
static void enabledSslProtocolSuites(javax.net.ssl.SSLSocket sslSocket, Configuration conf) throws java.sql.SQLException
Return possible protocols : values of option enabledSslProtocolSuites is set, or default to "TLSv1,TLSv1.1". MariaDB versions ≥ 10.0.15 and ≥ 5.5.41 supports TLSv1.2 if compiled with openSSL (default). MySQL's community versions ≥ 5.7.10 is compiled with yaSSL, so max TLS is TLSv1.1.- Parameters:
sslSocket
- current sslSocket- Throws:
java.sql.SQLException
- if protocol isn't a supported protocol
-
enabledSslCipherSuites
static void enabledSslCipherSuites(javax.net.ssl.SSLSocket sslSocket, Configuration conf) throws java.sql.SQLException
Set ssl socket cipher according to options.- Parameters:
sslSocket
- current ssl socketconf
- configuration- Throws:
java.sql.SQLException
- if a cipher isn't known
-
-