-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable TLS Support (DTS - Specific) #515
base: develop
Are you sure you want to change the base?
Changes from 3 commits
87175f1
8d62fb9
b68ec93
b31e53c
7dc9a6c
ae5d1c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,39 +27,56 @@ private OracleConstants() { | |
} | ||
|
||
public static final String PLUGIN_NAME = "Oracle"; | ||
public static final String ORACLE_CONNECTION_STRING_SID_FORMAT = "jdbc:oracle:thin:@%s:%s:%s"; | ||
public static final String ORACLE_CONNECTION_STRING_SERVICE_NAME_FORMAT = "jdbc:oracle:thin:@//%s:%s/%s"; | ||
// Updating connection strings to accept protocol (e.g., jdbc:oracle:thin:@<protocol>://<host>:<port>/<SID>) | ||
public static final String ORACLE_CONNECTION_STRING_SID_FORMAT = "jdbc:oracle:thin:@%s:%s:%s/%s"; | ||
public static final String ORACLE_CONNECTION_STRING_SERVICE_NAME_FORMAT = "jdbc:oracle:thin:@%s://%s:%s/%s"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. similar change here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated [b31e53c] |
||
public static final String ORACLE_CONNECTION_STRING_TNS_FORMAT = "jdbc:oracle:thin:@%s"; | ||
public static final String DEFAULT_BATCH_VALUE = "defaultBatchValue"; | ||
public static final String DEFAULT_ROW_PREFETCH = "defaultRowPrefetch"; | ||
public static final String SERVICE_CONNECTION_TYPE = "service"; | ||
public static final String CONNECTION_TYPE = "connectionType"; | ||
public static final String ROLE = "role"; | ||
public static final String NAME_DATABASE = "database"; | ||
public static final String TNS_CONNECTION_TYPE = "TNS"; | ||
public static final String TNS_CONNECTION_TYPE = "tns"; | ||
public static final String TRANSACTION_ISOLATION_LEVEL = "transactionIsolationLevel"; | ||
public static final String USE_SSL = "useSSL"; | ||
|
||
/** | ||
* Returns the Connection String for the given ConnectionType. | ||
* Constructs the Oracle connection string based on the provided connection type, host, port, and database. | ||
* If SSL is enabled, the connection protocol will be "tcps" instead of "tcp". | ||
* | ||
* @param connectionType TNS/Service/SID | ||
* @param host Host name of the oracle server | ||
* @param port Port of the oracle server | ||
* @param database Database to connect to | ||
* @return Connection String based on the given ConnectionType | ||
* @param useSSL Whether SSL/TLS is required(YES/NO) | ||
* @return Connection String based on the given parameters and connection type. | ||
*/ | ||
public static String getConnectionString(String connectionType, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I cannot see any reason of this new method, why can't we reuse the existing one? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was actually overloaded to reduce the impact of these changes on CDAP connectors, this method will only be used by Source and Sink plugin. Oracle Action, Post Action and Oracle Connector will still use the old method to generate connection string. When we enable TLS for CDAP Connectors we can reuse the code and remove this method. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we are using this method here: https://github.com/data-integrations/database-plugins/pull/515/files#diff-bd85394fe9ff353467fd45fd10ad329b508e0fbbc70145fe34de0d54f483a99bR129 It means it does impact CDAP connectors so it does not really help by overriding the method. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. got it, removed. [b68ec93] |
||
@Nullable String host, | ||
@Nullable int port, | ||
String database) { | ||
if (OracleConstants.TNS_CONNECTION_TYPE.equalsIgnoreCase(connectionType)) { | ||
return String.format(OracleConstants.ORACLE_CONNECTION_STRING_TNS_FORMAT, database); | ||
String database, | ||
@Nullable Boolean useSSL) { | ||
// Use protocol as "tcps" when SSL is requested or else use "tcp". | ||
String connectionProtocol; | ||
if (useSSL != null && useSSL) { | ||
connectionProtocol = "tcps"; | ||
} else { | ||
connectionProtocol = "tcp"; | ||
} | ||
if (OracleConstants.SERVICE_CONNECTION_TYPE.equalsIgnoreCase(connectionType)) { | ||
return String.format(OracleConstants.ORACLE_CONNECTION_STRING_SERVICE_NAME_FORMAT, | ||
host, port, database); | ||
|
||
switch (connectionType.toLowerCase()) { | ||
case OracleConstants.TNS_CONNECTION_TYPE: | ||
// TNS connection doesn't require protocol | ||
return String.format(OracleConstants.ORACLE_CONNECTION_STRING_TNS_FORMAT, database); | ||
case OracleConstants.SERVICE_CONNECTION_TYPE: | ||
// Service connection uses protocol, host, port, and database | ||
return String.format(OracleConstants.ORACLE_CONNECTION_STRING_SERVICE_NAME_FORMAT, | ||
connectionProtocol, host, port, database); | ||
default: | ||
// Default to SID format if no matching case is found | ||
return String.format(OracleConstants.ORACLE_CONNECTION_STRING_SID_FORMAT, | ||
connectionProtocol, host, port, database); | ||
} | ||
return String.format(OracleConstants.ORACLE_CONNECTION_STRING_SID_FORMAT, | ||
host, port, database); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add a constant
ORACLE_CONNECTION_STRING_SID_FORMAT_WITH_PROTOCOL
instead of modifying the older one and use the new one whenuseSSL
istrue
otherwise use the old connection string.This would make the change backward compatible and ensure CDAP connectors are not affected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got it, updated [b31e53c]