1212import com .marklogic .client .ext .SecurityContextType ;
1313import com .marklogic .client .ext .modulesloader .impl .PropertiesModuleManager ;
1414import com .marklogic .client .ext .modulesloader .ssl .SimpleX509TrustManager ;
15+ import com .marklogic .client .ext .ssl .SslUtil ;
1516import com .marklogic .client .ext .tokenreplacer .DefaultTokenReplacer ;
1617import com .marklogic .client .ext .tokenreplacer .PropertiesSource ;
1718import com .marklogic .client .ext .tokenreplacer .RoxyTokenReplacer ;
1819import com .marklogic .client .ext .tokenreplacer .TokenReplacer ;
20+ import org .springframework .util .StringUtils ;
1921
2022import javax .net .ssl .SSLContext ;
2123import javax .net .ssl .X509TrustManager ;
@@ -92,7 +94,11 @@ public class AppConfig {
9294 private String restCertPassword ;
9395 private String restExternalName ;
9496 private X509TrustManager restTrustManager ;
95- private Integer restPort = DEFAULT_PORT ;
97+ private boolean restUseDefaultKeystore ;
98+ private String restSslProtocol ;
99+ private String restTrustManagementAlgorithm ;
100+
101+ private Integer restPort = DEFAULT_PORT ;
96102 private Integer testRestPort ;
97103
98104 // Connection info for using the App Services client REST API - e.g. to load non-REST API modules
@@ -107,6 +113,9 @@ public class AppConfig {
107113 private String appServicesCertPassword ;
108114 private String appServicesExternalName ;
109115 private X509TrustManager appServicesTrustManager ;
116+ private boolean appServicesUseDefaultKeystore ;
117+ private String appServicesSslProtocol ;
118+ private String appServicesTrustManagementAlgorithm ;
110119
111120 // These can all be set to override the default names that are generated off of the "name" attribute.
112121 private String groupName = DEFAULT_GROUP ;
@@ -364,15 +373,24 @@ public DatabaseClient newTestDatabaseClient() {
364373 }
365374
366375 public DatabaseClientConfig newRestDatabaseClientConfig (int port ) {
367- DatabaseClientConfig config = new DatabaseClientConfig (getHost () , port , getRestAdminUsername (), getRestAdminPassword () );
368- config .setCertFile (getRestCertFile () );
369- config .setCertPassword (getRestCertPassword () );
376+ DatabaseClientConfig config = new DatabaseClientConfig (host , port , restAdminUsername , restAdminPassword );
377+ config .setCertFile (restCertFile );
378+ config .setCertPassword (restCertPassword );
370379 config .setConnectionType (restConnectionType );
371- config .setExternalName (getRestExternalName () );
380+ config .setExternalName (restExternalName );
372381 config .setSecurityContextType (restSecurityContextType );
373- config .setSslContext (getRestSslContext ());
374- config .setSslHostnameVerifier (getRestSslHostnameVerifier ());
375- config .setTrustManager (restTrustManager );
382+
383+ if (restUseDefaultKeystore ) {
384+ config .setSslProtocol (StringUtils .hasText (restSslProtocol ) ? restSslProtocol : SslUtil .DEFAULT_SSL_PROTOCOL );
385+ config .setTrustManagementAlgorithm (restTrustManagementAlgorithm );
386+ config .setSslHostnameVerifier (restSslHostnameVerifier != null ? restSslHostnameVerifier : SSLHostnameVerifier .ANY );
387+ }
388+ else {
389+ config .setSslContext (restSslContext );
390+ config .setTrustManager (restTrustManager );
391+ config .setSslHostnameVerifier (restSslHostnameVerifier );
392+ }
393+
376394 return config ;
377395 }
378396
@@ -394,16 +412,25 @@ public DatabaseClient newSchemasDatabaseClient() {
394412 }
395413
396414 public DatabaseClient newAppServicesDatabaseClient (String databaseName ) {
397- DatabaseClientConfig config = new DatabaseClientConfig (getHost (), getAppServicesPort (), getAppServicesUsername (), getAppServicesPassword () );
398- config .setCertFile (getAppServicesCertFile () );
399- config .setCertPassword (getAppServicesCertPassword () );
415+ DatabaseClientConfig config = new DatabaseClientConfig (host , appServicesPort , appServicesUsername , appServicesPassword );
416+ config .setCertFile (appServicesCertFile );
417+ config .setCertPassword (appServicesCertPassword );
400418 config .setConnectionType (appServicesConnectionType );
401419 config .setDatabase (databaseName );
402- config .setExternalName (getAppServicesExternalName () );
420+ config .setExternalName (appServicesExternalName );
403421 config .setSecurityContextType (appServicesSecurityContextType );
404- config .setSslContext (getAppServicesSslContext ());
405- config .setSslHostnameVerifier (getAppServicesSslHostnameVerifier ());
406- config .setTrustManager (appServicesTrustManager );
422+
423+ if (appServicesUseDefaultKeystore ) {
424+ config .setSslProtocol (StringUtils .hasText (appServicesSslProtocol ) ? appServicesSslProtocol : SslUtil .DEFAULT_SSL_PROTOCOL );
425+ config .setTrustManagementAlgorithm (appServicesTrustManagementAlgorithm );
426+ config .setSslHostnameVerifier (appServicesSslHostnameVerifier != null ? appServicesSslHostnameVerifier : SSLHostnameVerifier .ANY );
427+ }
428+ else {
429+ config .setSslContext (appServicesSslContext );
430+ config .setTrustManager (appServicesTrustManager );
431+ config .setSslHostnameVerifier (appServicesSslHostnameVerifier );
432+ }
433+
407434 return configuredDatabaseClientFactory .newDatabaseClient (config );
408435 }
409436
@@ -1424,4 +1451,53 @@ public void setDeployAmpsWithCma(boolean b) {
14241451 getCmaConfig ().setDeployAmps (b );
14251452 }
14261453 // End of methods still used by DHF 4.3.x
1454+
1455+
1456+ public boolean isRestUseDefaultKeystore () {
1457+ return restUseDefaultKeystore ;
1458+ }
1459+
1460+ public void setRestUseDefaultKeystore (boolean restUseDefaultKeystore ) {
1461+ this .restUseDefaultKeystore = restUseDefaultKeystore ;
1462+ }
1463+
1464+ public String getRestSslProtocol () {
1465+ return restSslProtocol ;
1466+ }
1467+
1468+ public void setRestSslProtocol (String restSslProtocol ) {
1469+ this .restSslProtocol = restSslProtocol ;
1470+ }
1471+
1472+ public String getRestTrustManagementAlgorithm () {
1473+ return restTrustManagementAlgorithm ;
1474+ }
1475+
1476+ public void setRestTrustManagementAlgorithm (String restTrustManagementAlgorithm ) {
1477+ this .restTrustManagementAlgorithm = restTrustManagementAlgorithm ;
1478+ }
1479+
1480+ public boolean isAppServicesUseDefaultKeystore () {
1481+ return appServicesUseDefaultKeystore ;
1482+ }
1483+
1484+ public void setAppServicesUseDefaultKeystore (boolean appServicesUseDefaultKeystore ) {
1485+ this .appServicesUseDefaultKeystore = appServicesUseDefaultKeystore ;
1486+ }
1487+
1488+ public String getAppServicesSslProtocol () {
1489+ return appServicesSslProtocol ;
1490+ }
1491+
1492+ public void setAppServicesSslProtocol (String appServicesSslProtocol ) {
1493+ this .appServicesSslProtocol = appServicesSslProtocol ;
1494+ }
1495+
1496+ public String getAppServicesTrustManagementAlgorithm () {
1497+ return appServicesTrustManagementAlgorithm ;
1498+ }
1499+
1500+ public void setAppServicesTrustManagementAlgorithm (String appServicesTrustManagementAlgorithm ) {
1501+ this .appServicesTrustManagementAlgorithm = appServicesTrustManagementAlgorithm ;
1502+ }
14271503}
0 commit comments