use of com.mysql.cj.exceptions.CJConnectionFeatureNotAvailableException in project ABC by RuiPinto96274.
the class NativeProtocol method negotiateSSLConnection.
/**
* Negotiates the SSL communications channel used when connecting
* to a MySQL server that understands SSL.
*/
@Override
public void negotiateSSLConnection() {
if (!ExportControlled.enabled()) {
throw new CJConnectionFeatureNotAvailableException(this.getPropertySet(), this.serverSession, this.getPacketSentTimeHolder(), null);
}
long clientParam = this.serverSession.getClientParam();
NativePacketPayload packet = new NativePacketPayload(SSL_REQUEST_LENGTH);
packet.writeInteger(IntegerDataType.INT4, clientParam);
packet.writeInteger(IntegerDataType.INT4, NativeConstants.MAX_PACKET_SIZE);
packet.writeInteger(IntegerDataType.INT1, this.serverSession.getCharsetSettings().configurePreHandshake(false));
// Set of bytes reserved for future use.
packet.writeBytes(StringLengthDataType.STRING_FIXED, new byte[23]);
send(packet, packet.getPosition());
try {
this.socketConnection.performTlsHandshake(this.serverSession, this.log);
// i/o streams were replaced, build new packet sender/reader
this.packetSender = new SimplePacketSender(this.socketConnection.getMysqlOutput());
this.packetReader = new SimplePacketReader(this.socketConnection, this.maxAllowedPacket);
} catch (FeatureNotAvailableException nae) {
throw new CJConnectionFeatureNotAvailableException(this.getPropertySet(), this.serverSession, this.getPacketSentTimeHolder(), nae);
} catch (IOException ioEx) {
throw ExceptionFactory.createCommunicationsException(this.propertySet, this.serverSession, this.getPacketSentTimeHolder(), this.getPacketReceivedTimeHolder(), ioEx, getExceptionInterceptor());
}
}
use of com.mysql.cj.exceptions.CJConnectionFeatureNotAvailableException in project ABC by RuiPinto96274.
the class XProtocol method negotiateSSLConnection.
public void negotiateSSLConnection() {
if (!ExportControlled.enabled()) {
throw new CJConnectionFeatureNotAvailableException();
}
if (!((XServerCapabilities) this.serverSession.getCapabilities()).hasCapability(XServerCapabilities.KEY_TLS)) {
throw new CJCommunicationsException("A secure connection is required but the server is not configured with SSL.");
}
// the message reader is async and is always "reading". we need to stop it to use the socket for the TLS handshake
this.reader.stopAfterNextMessage();
Map<String, Object> tlsCapabilities = new HashMap<>();
tlsCapabilities.put(XServerCapabilities.KEY_TLS, true);
sendCapabilities(tlsCapabilities);
try {
this.socketConnection.performTlsHandshake(null, this.log);
} catch (SSLParamsException | FeatureNotAvailableException | IOException e) {
throw new CJCommunicationsException(e);
}
try {
this.sender = new SyncMessageSender(this.socketConnection.getMysqlOutput());
this.reader = new SyncMessageReader(this.socketConnection.getMysqlInput(), this);
} catch (IOException e) {
throw new XProtocolError(e.getMessage(), e);
}
}
use of com.mysql.cj.exceptions.CJConnectionFeatureNotAvailableException in project JavaSegundasQuintas by ecteruel.
the class NativeProtocol method negotiateSSLConnection.
/**
* Negotiates the SSL communications channel used when connecting
* to a MySQL server that understands SSL.
*/
@Override
public void negotiateSSLConnection() {
if (!ExportControlled.enabled()) {
throw new CJConnectionFeatureNotAvailableException(this.getPropertySet(), this.serverSession, this.getPacketSentTimeHolder(), null);
}
long clientParam = this.serverSession.getClientParam();
NativePacketPayload packet = new NativePacketPayload(SSL_REQUEST_LENGTH);
packet.writeInteger(IntegerDataType.INT4, clientParam);
packet.writeInteger(IntegerDataType.INT4, NativeConstants.MAX_PACKET_SIZE);
packet.writeInteger(IntegerDataType.INT1, this.serverSession.getCharsetSettings().configurePreHandshake(false));
// Set of bytes reserved for future use.
packet.writeBytes(StringLengthDataType.STRING_FIXED, new byte[23]);
send(packet, packet.getPosition());
try {
this.socketConnection.performTlsHandshake(this.serverSession, this.log);
// i/o streams were replaced, build new packet sender/reader
this.packetSender = new SimplePacketSender(this.socketConnection.getMysqlOutput());
this.packetReader = new SimplePacketReader(this.socketConnection, this.maxAllowedPacket);
} catch (FeatureNotAvailableException nae) {
throw new CJConnectionFeatureNotAvailableException(this.getPropertySet(), this.serverSession, this.getPacketSentTimeHolder(), nae);
} catch (IOException ioEx) {
throw ExceptionFactory.createCommunicationsException(this.propertySet, this.serverSession, this.getPacketSentTimeHolder(), this.getPacketReceivedTimeHolder(), ioEx, getExceptionInterceptor());
}
}
use of com.mysql.cj.exceptions.CJConnectionFeatureNotAvailableException in project aws-mysql-jdbc by awslabs.
the class NativeProtocol method negotiateSSLConnection.
/**
* Negotiates the SSL communications channel used when connecting
* to a MySQL server that understands SSL.
*/
@Override
public void negotiateSSLConnection() {
if (!ExportControlled.enabled()) {
throw new CJConnectionFeatureNotAvailableException(this.getPropertySet(), this.serverSession, this.getPacketSentTimeHolder(), null);
}
long clientParam = this.serverSession.getClientParam();
NativePacketPayload packet = new NativePacketPayload(SSL_REQUEST_LENGTH);
packet.writeInteger(IntegerDataType.INT4, clientParam);
packet.writeInteger(IntegerDataType.INT4, NativeConstants.MAX_PACKET_SIZE);
packet.writeInteger(IntegerDataType.INT1, this.serverSession.getCharsetSettings().configurePreHandshake(false));
// Set of bytes reserved for future use.
packet.writeBytes(StringLengthDataType.STRING_FIXED, new byte[23]);
send(packet, packet.getPosition());
try {
this.socketConnection.performTlsHandshake(this.serverSession, this.log);
// i/o streams were replaced, build new packet sender/reader
this.packetSender = new SimplePacketSender(this.socketConnection.getMysqlOutput());
this.packetReader = new SimplePacketReader(this.socketConnection, this.maxAllowedPacket);
} catch (FeatureNotAvailableException nae) {
throw new CJConnectionFeatureNotAvailableException(this.getPropertySet(), this.serverSession, this.getPacketSentTimeHolder(), nae);
} catch (IOException ioEx) {
throw ExceptionFactory.createCommunicationsException(this.propertySet, this.serverSession, this.getPacketSentTimeHolder(), this.getPacketReceivedTimeHolder(), ioEx, getExceptionInterceptor());
}
}
use of com.mysql.cj.exceptions.CJConnectionFeatureNotAvailableException in project aws-mysql-jdbc by awslabs.
the class XProtocol method negotiateSSLConnection.
public void negotiateSSLConnection() {
if (!ExportControlled.enabled()) {
throw new CJConnectionFeatureNotAvailableException();
}
if (!((XServerCapabilities) this.serverSession.getCapabilities()).hasCapability(XServerCapabilities.KEY_TLS)) {
throw new CJCommunicationsException("A secure connection is required but the server is not configured with SSL.");
}
// the message reader is async and is always "reading". we need to stop it to use the socket for the TLS handshake
this.reader.stopAfterNextMessage();
Map<String, Object> tlsCapabilities = new HashMap<>();
tlsCapabilities.put(XServerCapabilities.KEY_TLS, true);
sendCapabilities(tlsCapabilities);
try {
this.socketConnection.performTlsHandshake(null, this.log);
} catch (SSLParamsException | FeatureNotAvailableException | IOException e) {
throw new CJCommunicationsException(e);
}
try {
this.sender = new SyncMessageSender(this.socketConnection.getMysqlOutput());
this.reader = new SyncMessageReader(this.socketConnection.getMysqlInput(), this);
} catch (IOException e) {
throw new XProtocolError(e.getMessage(), e);
}
}
Aggregations