generated from salesforce/oss-template
-
Notifications
You must be signed in to change notification settings - Fork 12
feat: Add SSL/TLS Support to DataCloud JDBC Driver #89
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
Merged
praveen2450
merged 20 commits into
forcedotcom:main
from
praveen2450:praveen-driver-connection-ssl-mode-enhancement
Jan 22, 2026
Merged
Changes from 2 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
a2f46c4
feat: Add SSL/TLS support and additionalHeaders mechanism
praveen2450 cbdbae4
feat: Add unit test, rename custom_truststore to onesided_tls amd ren…
praveen2450 82500dd
feat: Add SSL/TLS support with mTLS capabilities
praveen2450 984d8fa
remove empty line
praveen2450 5376bf9
refactor: Implement review comments
praveen2450 6d09c53
Update DEVELOPMENT.md
praveen2450 5e654c9
merge upstream and resolve conflicts
praveen2450 57c8d85
fix build issue
praveen2450 a1e9f1f
refactor code and clean up comments
praveen2450 10a2cec
Address review comment, cleaned up code
praveen2450 63a88e8
remove sl4j reference
praveen2450 53fec21
fix spotless issue
praveen2450 4274bb2
refactor(ssl): align SslProperties with SalesforceAuthProperties patt…
praveen2450 1bab401
Merge upstream main
praveen2450 92c0b60
Fix spotless
praveen2450 ca406e1
Refactor: Remove early exception catch to match SalesforceAuthProperties
praveen2450 be4d04e
Address review comments
praveen2450 089bdf0
Merge branch 'forcedotcom:main' into praveen-driver-connection-ssl-mo…
praveen2450 77e1f94
Address review comment : add test case, reduce duplication, remove re…
praveen2450 5e755d7
remove spurious empty lines
praveen2450 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
162 changes: 162 additions & 0 deletions
162
...src/main/java/com/salesforce/datacloud/jdbc/core/DirectDataCloudConnectionProperties.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,162 @@ | ||
| /** | ||
| * This file is part of https://github.com/forcedotcom/datacloud-jdbc which is released under the | ||
| * Apache 2.0 license. See https://github.com/forcedotcom/datacloud-jdbc/blob/main/LICENSE.txt | ||
| */ | ||
| package com.salesforce.datacloud.jdbc.core; | ||
|
|
||
| import com.salesforce.datacloud.jdbc.exception.DataCloudJDBCException; | ||
| import java.util.Properties; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
|
|
||
| /** | ||
| * Connection properties that control the Direct Data cloud JDBC connection behavior. | ||
| */ | ||
| @Getter | ||
| @Builder | ||
| public class DirectDataCloudConnectionProperties { | ||
| // Property key constants | ||
| public static final String direct = "direct"; | ||
|
|
||
| // property to disable SSL (for testing only, we might change the implementation in future) | ||
| public static final String sslDisabled = "ssl_disabled"; | ||
|
|
||
| // JKS truststore properties - for trust verification | ||
| public static final String truststorePath = "truststore_path"; | ||
| public static final String truststorePassword = "truststore_password"; | ||
| public static final String truststoreType = "truststore_type"; | ||
|
|
||
| // PEM certificate properties - for trust verification and client authentication | ||
| public static final String clientCertPath = "client_cert_path"; | ||
| public static final String clientKeyPath = "client_key_path"; | ||
| public static final String caCertPath = "ca_cert_path"; | ||
|
|
||
| // Instance fields for parsed property values | ||
| @Builder.Default | ||
| private final boolean directConnection = false; | ||
|
|
||
| @Builder.Default | ||
| private final boolean sslDisabledFlag = false; | ||
|
|
||
| @Builder.Default | ||
| private final String truststorePathValue = ""; | ||
|
|
||
| @Builder.Default | ||
| private final String truststorePasswordValue = ""; | ||
|
|
||
| @Builder.Default | ||
| private final String truststoreTypeValue = "JKS"; | ||
|
|
||
| @Builder.Default | ||
| private final String clientCertPathValue = ""; | ||
|
|
||
| @Builder.Default | ||
| private final String clientKeyPathValue = ""; | ||
|
|
||
| @Builder.Default | ||
| private final String caCertPathValue = ""; | ||
|
|
||
| /** | ||
| * Parses direct connection properties from a Properties object. | ||
| * | ||
| * @param props The properties to parse | ||
| * @return A DirectDataCloudConnectionProperties instance | ||
| * @throws DataCloudJDBCException if parsing of property values fails | ||
| */ | ||
| public static DirectDataCloudConnectionProperties of(Properties props) throws DataCloudJDBCException { | ||
| if (props == null) { | ||
| return DirectDataCloudConnectionProperties.builder().build(); | ||
| } | ||
|
|
||
| DirectDataCloudConnectionPropertiesBuilder builder = DirectDataCloudConnectionProperties.builder(); | ||
|
|
||
| // Parse direct connection flag | ||
| String directValue = props.getProperty(direct); | ||
| if (directValue != null) { | ||
| builder.directConnection(Boolean.parseBoolean(directValue)); | ||
| } | ||
|
|
||
| // Parse SSL disabled flag | ||
| String sslDisabledValue = props.getProperty(sslDisabled); | ||
| if (sslDisabledValue != null) { | ||
| builder.sslDisabledFlag(Boolean.parseBoolean(sslDisabledValue)); | ||
| } | ||
|
|
||
| // Parse truststore properties | ||
| String truststorePathVal = props.getProperty(truststorePath); | ||
| if (truststorePathVal != null) { | ||
| builder.truststorePathValue(truststorePathVal); | ||
| } | ||
|
|
||
| String truststorePasswordVal = props.getProperty(truststorePassword); | ||
| if (truststorePasswordVal != null) { | ||
| builder.truststorePasswordValue(truststorePasswordVal); | ||
| } | ||
|
|
||
| String truststoreTypeVal = props.getProperty(truststoreType); | ||
| if (truststoreTypeVal != null) { | ||
| builder.truststoreTypeValue(truststoreTypeVal); | ||
| } | ||
|
|
||
| // Parse client certificate properties | ||
| String clientCertPathVal = props.getProperty(clientCertPath); | ||
| if (clientCertPathVal != null) { | ||
| builder.clientCertPathValue(clientCertPathVal); | ||
| } | ||
|
|
||
| String clientKeyPathVal = props.getProperty(clientKeyPath); | ||
| if (clientKeyPathVal != null) { | ||
| builder.clientKeyPathValue(clientKeyPathVal); | ||
| } | ||
|
|
||
| String caCertPathVal = props.getProperty(caCertPath); | ||
| if (caCertPathVal != null) { | ||
| builder.caCertPathValue(caCertPathVal); | ||
| } | ||
|
|
||
| return builder.build(); | ||
| } | ||
|
|
||
| /** | ||
| * Serializes this instance into a Properties object. | ||
| * | ||
| * @return A Properties object containing the direct connection properties | ||
| */ | ||
| public Properties toProperties() { | ||
| Properties props = new Properties(); | ||
|
|
||
| if (directConnection) { | ||
| props.setProperty(direct, String.valueOf(directConnection)); | ||
| } | ||
|
|
||
| if (sslDisabledFlag) { | ||
| props.setProperty(sslDisabled, String.valueOf(sslDisabledFlag)); | ||
| } | ||
|
|
||
| if (!truststorePathValue.isEmpty()) { | ||
| props.setProperty(truststorePath, truststorePathValue); | ||
| } | ||
|
|
||
| if (!truststorePasswordValue.isEmpty()) { | ||
| props.setProperty(truststorePassword, truststorePasswordValue); | ||
| } | ||
|
|
||
| if (!truststoreTypeValue.equals("JKS")) { | ||
| props.setProperty(truststoreType, truststoreTypeValue); | ||
| } | ||
|
|
||
| if (!clientCertPathValue.isEmpty()) { | ||
| props.setProperty(clientCertPath, clientCertPathValue); | ||
| } | ||
|
|
||
| if (!clientKeyPathValue.isEmpty()) { | ||
| props.setProperty(clientKeyPath, clientKeyPathValue); | ||
| } | ||
|
|
||
| if (!caCertPathValue.isEmpty()) { | ||
| props.setProperty(caCertPath, caCertPathValue); | ||
| } | ||
|
|
||
| return props; | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.