Skip to content

Commit 0935dfa

Browse files
committed
Add sslenabled to driver parameters
1 parent eb20e2a commit 0935dfa

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

driver/src/main/java/com/dbschema/CassandraClientURI.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ public CassandraClientURI(String uri, Properties info) {
6262
}
6363
}
6464

65-
this.userName = getOption(info, options, "user");
66-
this.password = getOption(info, options, "password");
67-
String sslEnabledOption = getOption(info, options, "sslenabled");
65+
this.userName = getOption(info, options, "user", null);
66+
this.password = getOption(info, options, "password", null);
67+
String sslEnabledOption = getOption(info, options, ENABLE_SSL, ENABLE_SSL_DEFAULT);
6868
this.sslEnabled = isTrue(sslEnabledOption);
69-
String verifyServerCertOption = getOption(info, options, VERIFY_SERVER_CERTIFICATE);
69+
String verifyServerCertOption = getOption(info, options, VERIFY_SERVER_CERTIFICATE, VERIFY_SERVER_CERTIFICATE_DEFAULT);
7070
this.verifyServerCert = isTrue(verifyServerCertOption);
7171

7272

@@ -97,14 +97,15 @@ public CassandraClientURI(String uri, Properties info) {
9797
* @return option from properties or from uri if it is not found in properties.
9898
* null if options was not found.
9999
*/
100-
private String getOption(Properties properties, Map<String, List<String>> options, String optionName) {
100+
private String getOption(Properties properties, Map<String, List<String>> options, String optionName, String defaultValue) {
101101
if (properties != null) {
102102
String option = (String) properties.get(optionName);
103103
if (option != null) {
104104
return option;
105105
}
106106
}
107-
return getLastValue(options, optionName);
107+
String value = getLastValue(options, optionName);
108+
return value != null ? value : defaultValue;
108109
}
109110

110111
Cluster createCluster() throws java.net.UnknownHostException, SSLParamsException {

driver/src/main/java/com/dbschema/DriverPropertyInfoHelper.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,20 @@
55
import java.util.Locale;
66

77
public class DriverPropertyInfoHelper {
8+
public static final String ENABLE_SSL = "sslenabled";
9+
public static final String ENABLE_SSL_DEFAULT = "false";
810
public static final String VERIFY_SERVER_CERTIFICATE = "verifyServerCertificate";
911
public static final String VERIFY_SERVER_CERTIFICATE_DEFAULT = "true";
12+
private static final String[] choices = new String[]{"true", "false"};
1013

1114

1215
public static DriverPropertyInfo[] getPropertyInfo() {
1316
ArrayList<DriverPropertyInfo> propInfos = new ArrayList<>();
1417

18+
addPropInfo(propInfos, ENABLE_SSL, ENABLE_SSL_DEFAULT, "Enable ssl.", choices);
19+
1520
addPropInfo(propInfos, VERIFY_SERVER_CERTIFICATE, VERIFY_SERVER_CERTIFICATE_DEFAULT,
16-
"Configure a connection that uses SSL but does not verify the identity of the server.", null);
21+
"Configure a connection that uses SSL but does not verify the identity of the server.", choices);
1722

1823
return propInfos.toArray(new DriverPropertyInfo[0]);
1924
}

0 commit comments

Comments
 (0)