Skip to content

Commit 20b4c27

Browse files
authored
Additional rcudb validation (#1396)
* Add extra validation for RCUDbinfo * default databaseType is ORACLE * add fine info for rcu driver params values * reformat message * mask encrypted value as *** * replace net ssl version value with constants * sonar fix
1 parent 883c00b commit 20b4c27

File tree

4 files changed

+85
-30
lines changed

4 files changed

+85
-30
lines changed

core/src/main/python/wlsdeploy/aliases/model_constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@
374374
DRIVER_PARAMS_KEYSTOREPWD_PROPERTY = 'javax.net.ssl.keyStorePassword'
375375
DRIVER_PARAMS_NET_SERVER_DN_MATCH_PROPERTY = 'oracle.net.ssl_server_dn_match'
376376
DRIVER_PARAMS_NET_SSL_VERSION = 'oracle.net.ssl_version'
377+
DRIVER_PARAMS_NET_SSL_VERSION_VALUE = '1.2'
377378
DRIVER_PARAMS_NET_TNS_ADMIN = 'oracle.net.tns_admin'
378379
DRIVER_PARAMS_NET_FAN_ENABLED = 'oracle.jdbc.fanEnabled'
379380
DYNAMIC_CLUSTER_SIZE = 'DynamicClusterSize'

core/src/main/python/wlsdeploy/tool/create/atp_helper.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from wlsdeploy.logging.platform_logger import PlatformLogger
1010
import wlsdeploy.util.unicode_helper as str_helper
11+
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_NET_SSL_VERSION_VALUE
1112

1213
_logger = PlatformLogger('wlsdeploy.create')
1314

@@ -29,7 +30,7 @@ def set_ssl_properties(xml_doc, atp_creds_path, keystore_password, truststore_pa
2930
for prop in props:
3031
if prop.getAttribute('name') == 'props.db.1':
3132
set_property(dom_tree, prop, 'oracle.net.ssl_server_dn_match', 'true')
32-
set_property(dom_tree, prop, 'oracle.net.ssl_version', '1.2')
33+
set_property(dom_tree, prop, 'oracle.net.ssl_version', DRIVER_PARAMS_NET_SSL_VERSION_VALUE)
3334
set_property(dom_tree, prop, 'oracle.net.tns_admin', atp_creds_path)
3435
set_property(dom_tree, prop, 'javax.net.ssl.trustStoreType', truststore_type)
3536
set_property(dom_tree, prop, 'javax.net.ssl.keyStoreType', keystore_type)

core/src/main/python/wlsdeploy/tool/create/domain_creator.py

Lines changed: 77 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_KEYSTOREPWD_PROPERTY
3232
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_NET_SERVER_DN_MATCH_PROPERTY
3333
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_NET_SSL_VERSION
34+
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_NET_SSL_VERSION_VALUE
3435
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_NET_TNS_ADMIN
3536
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_NET_FAN_ENABLED
3637
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_PROPERTY_VALUE
@@ -272,6 +273,11 @@ def __run_rcu(self):
272273
rcu_sys_pass = rcu_db_info.get_preferred_sys_pass()
273274
rcu_schema_pass = rcu_db_info.get_preferred_schema_pass()
274275

276+
database_type = rcu_db_info.get_database_type()
277+
if database_type is not None and database_type not in ['SSL', 'ATP', 'ORACLE']:
278+
ex = exception_helper.create_create_exception('WLSDPLY-12573', database_type)
279+
raise ex
280+
275281
if rcu_db_info.is_use_atp():
276282
# ATP database, build runner map from RCUDbInfo in the model.
277283

@@ -298,7 +304,7 @@ def __run_rcu(self):
298304

299305
# hard coding for now, may need to expose it if ATP access changed later
300306
ssl_conn_properties[DRIVER_PARAMS_NET_FAN_ENABLED] = 'false'
301-
ssl_conn_properties[DRIVER_PARAMS_NET_SSL_VERSION] = '1.2'
307+
ssl_conn_properties[DRIVER_PARAMS_NET_SSL_VERSION] = DRIVER_PARAMS_NET_SSL_VERSION_VALUE
302308
ssl_conn_properties[DRIVER_PARAMS_NET_SERVER_DN_MATCH_PROPERTY] = 'false'
303309

304310
# reset these to pick up any defaults from rcu_db_info
@@ -337,6 +343,11 @@ def __run_rcu(self):
337343
else:
338344
# Non-ATP database, use DB config from the command line or RCUDbInfo in the model.
339345
rcu_db = rcu_db_info.get_preferred_db()
346+
347+
if rcu_db is None:
348+
ex = exception_helper.create_create_exception('WLSDPLY-12572')
349+
raise ex
350+
340351
rcu_db_user = rcu_db_info.get_preferred_db_user()
341352

342353
runner = RCURunner.createRunner(domain_type, oracle_home, java_home, rcu_db, rcu_prefix, rcu_schemas,
@@ -364,6 +375,19 @@ def _set_rcu_ssl_args_properties(self, ssl_conn_properties, rcu_db_info, keystor
364375
ssl_conn_properties[DRIVER_PARAMS_KEYSTORE_PROPERTY] = self.__get_store_path(rcu_db_info.get_tns_admin(),
365376
keystore)
366377

378+
if not os.path.exists(ssl_conn_properties[DRIVER_PARAMS_KEYSTORE_PROPERTY]):
379+
ex = exception_helper.create_create_exception('WLSDPLY-12574',
380+
ssl_conn_properties[DRIVER_PARAMS_KEYSTORE_PROPERTY],
381+
DRIVER_PARAMS_KEYSTORE_PROPERTY)
382+
raise ex
383+
384+
if not os.path.exists(ssl_conn_properties[DRIVER_PARAMS_TRUSTSTORE_PROPERTY]):
385+
ex = exception_helper.create_create_exception('WLSDPLY-12574',
386+
ssl_conn_properties[DRIVER_PARAMS_TRUSTSTORE_PROPERTY],
387+
DRIVER_PARAMS_TRUSTSTORE_PROPERTY)
388+
raise ex
389+
390+
367391
def __fail_mt_1221_domain_creation(self):
368392
"""
369393
Abort create if domain contains MT artifacts that cannot be created in the version of WLST offline being used
@@ -974,6 +998,10 @@ def __create_other_domain_artifacts(self, location, mbean_type_list):
974998
self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
975999
return
9761000

1001+
def __set_connection_property_info(self, root_location, property_name, property_value, info_bucket, encrypted=False):
1002+
p = self.__set_connection_property(root_location, property_name, property_value, encrypted)
1003+
info_bucket.append(p)
1004+
9771005
def __set_connection_property(self, root_location, property_name, property_value, encrypted=False):
9781006
create_path = self.aliases.get_wlst_create_path(root_location)
9791007

@@ -1004,6 +1032,10 @@ def __set_connection_property(self, root_location, property_name, property_value
10041032
self.wlst_helper.set(wlst_name, wlst_value)
10051033

10061034
root_location.remove_name_token(property_name)
1035+
if encrypted:
1036+
return {property_name: '******'}
1037+
else:
1038+
return {property_name: property_value}
10071039

10081040
def __validate_and_get_atp_rcudbinfo(self, rcu_db_info, check_admin_pwd=False):
10091041
"""
@@ -1192,17 +1224,20 @@ def __set_rcu_datasource_parameters_without_shadow_table(self, rcu_db_info):
11921224
for ds_name in ds_names:
11931225

11941226
# Set the driver params
1195-
self.__set_datasource_url(ds_name, fmw_database)
1227+
actual_url = self.__set_datasource_url(ds_name, fmw_database)
11961228
self.__set_datasource_password(ds_name, rcu_schema_pwd)
1197-
self.__reset_datasource_template_userid(ds_name, rcu_prefix)
1198-
1229+
actual_schema = self.__reset_datasource_template_userid(ds_name, rcu_prefix)
1230+
pset = None
11991231
if is_atp_ds:
1200-
self.__set_atp_standard_conn_properties(ds_name, tns_admin, truststore, truststore_pwd, truststore_type,
1232+
pset = self.__set_atp_standard_conn_properties(ds_name, tns_admin, truststore, truststore_pwd, truststore_type,
12011233
keystore_pwd, keystore_type, keystore)
12021234
elif is_ssl_ds:
1203-
self.__set_ssl_standard_conn_properties(ds_name, tns_admin, truststore, truststore_pwd, truststore_type,
1235+
pset = self.__set_ssl_standard_conn_properties(ds_name, tns_admin, truststore, truststore_pwd, truststore_type,
12041236
keystore_pwd, keystore_type, keystore)
12051237

1238+
self.logger.info('WLSDPLY_12575', ds_name, actual_url, actual_schema, pset,
1239+
class_name=self.__class_name, method_name=_method_name)
1240+
12061241
def __reset_datasource_template_userid(self, datasource_name, rcu_prefix):
12071242
location = deployer_utils.get_jdbc_driver_params_location(datasource_name, self.aliases)
12081243
location.append_location(JDBC_DRIVER_PARAMS_PROPERTIES)
@@ -1219,6 +1254,7 @@ def __reset_datasource_template_userid(self, datasource_name, rcu_prefix):
12191254
self.aliases.get_wlst_attribute_name_and_value(location, DRIVER_PARAMS_PROPERTY_VALUE,
12201255
schema_user)
12211256
self.wlst_helper.set_if_needed(wlst_name, wlst_value)
1257+
return wlst_value
12221258

12231259
def __set_datasource_password(self, datasource_name, rcu_schema_pwd):
12241260
location = deployer_utils.get_jdbc_driver_params_location(datasource_name, self.aliases)
@@ -1236,6 +1272,7 @@ def __set_datasource_url(self, datasource_name, url_string):
12361272
wlst_name, wlst_value = \
12371273
self.aliases.get_wlst_attribute_name_and_value(location, URL, url)
12381274
self.wlst_helper.set_if_needed(wlst_name, wlst_value)
1275+
return wlst_value
12391276

12401277
def __get_store_path(self, tns_admin, store):
12411278
result = store
@@ -1247,52 +1284,63 @@ def __get_store_path(self, tns_admin, store):
12471284
def __set_ssl_standard_conn_properties(self, datasource_name, tns_admin, truststore, truststore_pwd,
12481285
truststore_type, keystore_pwd, keystore_type, keystore):
12491286
location = deployer_utils.get_jdbc_driver_params_properties_location(datasource_name, self.aliases)
1287+
properties_set = []
12501288

12511289
# Should always have trust store
1252-
self.__set_connection_property(location, DRIVER_PARAMS_TRUSTSTORE_PROPERTY,
1253-
self.__get_store_path(tns_admin, truststore))
1290+
self.__set_connection_property_info(location, DRIVER_PARAMS_TRUSTSTORE_PROPERTY,
1291+
self.__get_store_path(tns_admin, truststore), properties_set)
12541292

1255-
self.__set_connection_property(location, DRIVER_PARAMS_TRUSTSTORETYPE_PROPERTY,
1256-
truststore_type)
1293+
self.__set_connection_property_info(location, DRIVER_PARAMS_TRUSTSTORETYPE_PROPERTY,
1294+
truststore_type, properties_set)
12571295

12581296
# if not sso type then user must provide pwd
12591297
if truststore_pwd is not None and truststore_pwd != 'None':
1260-
self.__set_connection_property(location, DRIVER_PARAMS_TRUSTSTOREPWD_PROPERTY, truststore_pwd,
1261-
encrypted=True)
1298+
self.__set_connection_property_info(location, DRIVER_PARAMS_TRUSTSTOREPWD_PROPERTY, truststore_pwd,
1299+
properties_set, encrypted=True)
12621300

12631301
if keystore_pwd is not None and keystore_pwd != 'None':
1264-
self.__set_connection_property(location, DRIVER_PARAMS_KEYSTOREPWD_PROPERTY, keystore_pwd, encrypted=True)
1302+
self.__set_connection_property_info(location, DRIVER_PARAMS_KEYSTOREPWD_PROPERTY, keystore_pwd,
1303+
properties_set, encrypted=True)
12651304

12661305
# if it is 2 ways SSL
12671306
if keystore is not None and keystore != 'None':
1268-
self.__set_connection_property(location, DRIVER_PARAMS_KEYSTORE_PROPERTY,
1269-
self.__get_store_path(tns_admin, keystore))
1307+
self.__set_connection_property_info(location, DRIVER_PARAMS_KEYSTORE_PROPERTY,
1308+
self.__get_store_path(tns_admin, keystore), properties_set)
12701309

12711310
if keystore_type is not None and keystore_type != 'None':
1272-
self.__set_connection_property(location, DRIVER_PARAMS_KEYSTORETYPE_PROPERTY, keystore_type)
1311+
self.__set_connection_property_info(location, DRIVER_PARAMS_KEYSTORETYPE_PROPERTY, keystore_type,
1312+
properties_set)
1313+
return properties_set
12731314

12741315
def __set_atp_standard_conn_properties(self, datasource_name, tns_admin, truststore, truststore_pwd,
12751316
truststore_type, keystore_pwd, keystore_type, keystore):
12761317
location = deployer_utils.get_jdbc_driver_params_properties_location(datasource_name, self.aliases)
12771318
keystore, keystore_type, truststore, truststore_type = atp_helper.fix_store_type_and_default_value(keystore,
12781319
keystore_type, truststore, truststore_type)
12791320

1321+
properties_set = []
1322+
self.__set_connection_property_info(location, DRIVER_PARAMS_KEYSTORE_PROPERTY, self.__get_store_path(tns_admin,
1323+
keystore), properties_set)
1324+
1325+
self.__set_connection_property_info(location, DRIVER_PARAMS_KEYSTORETYPE_PROPERTY, keystore_type, properties_set)
12801326

1281-
self.__set_connection_property(location, DRIVER_PARAMS_KEYSTORE_PROPERTY, self.__get_store_path(tns_admin,
1282-
keystore))
1283-
self.__set_connection_property(location, DRIVER_PARAMS_KEYSTORETYPE_PROPERTY, keystore_type)
12841327
if keystore_pwd:
1285-
self.__set_connection_property(location, DRIVER_PARAMS_KEYSTOREPWD_PROPERTY, keystore_pwd, encrypted=True)
1286-
self.__set_connection_property(location, DRIVER_PARAMS_TRUSTSTORE_PROPERTY, self.__get_store_path(tns_admin,
1287-
truststore))
1288-
self.__set_connection_property(location, DRIVER_PARAMS_TRUSTSTORETYPE_PROPERTY, truststore_type)
1328+
self.__set_connection_property_info(location, DRIVER_PARAMS_KEYSTOREPWD_PROPERTY, keystore_pwd,
1329+
properties_set, encrypted=True)
1330+
self.__set_connection_property_info(location, DRIVER_PARAMS_TRUSTSTORE_PROPERTY, self.__get_store_path(tns_admin,
1331+
truststore), properties_set)
1332+
self.__set_connection_property_info(location, DRIVER_PARAMS_TRUSTSTORETYPE_PROPERTY, truststore_type,
1333+
properties_set)
12891334
if truststore_pwd:
1290-
self.__set_connection_property(location, DRIVER_PARAMS_TRUSTSTOREPWD_PROPERTY, truststore_pwd,
1291-
encrypted=True)
1292-
self.__set_connection_property(location, DRIVER_PARAMS_NET_SSL_VERSION, '1.2')
1293-
self.__set_connection_property(location, DRIVER_PARAMS_NET_SERVER_DN_MATCH_PROPERTY, 'true')
1294-
self.__set_connection_property(location, DRIVER_PARAMS_NET_TNS_ADMIN, tns_admin)
1295-
self.__set_connection_property(location, DRIVER_PARAMS_NET_FAN_ENABLED, 'false')
1335+
self.__set_connection_property_info(location, DRIVER_PARAMS_TRUSTSTOREPWD_PROPERTY, truststore_pwd,
1336+
properties_set, encrypted=True)
1337+
self.__set_connection_property_info(location, DRIVER_PARAMS_NET_SSL_VERSION,
1338+
DRIVER_PARAMS_NET_SSL_VERSION_VALUE , properties_set)
1339+
self.__set_connection_property_info(location, DRIVER_PARAMS_NET_SERVER_DN_MATCH_PROPERTY, 'true', properties_set)
1340+
self.__set_connection_property_info(location, DRIVER_PARAMS_NET_TNS_ADMIN, tns_admin, properties_set)
1341+
self.__set_connection_property_info(location, DRIVER_PARAMS_NET_FAN_ENABLED, 'false', properties_set)
1342+
1343+
return properties_set
12961344

12971345
def __set_app_dir(self):
12981346
"""

core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,6 +1449,11 @@ WLSDPLY-12568=Creating empty folder {0}. Folder contains no attributes or sub-fo
14491449
WLSDPLY-12569=Setting the topology profile to {0}
14501450
WLSDPLY-12570=Unable to retrieve database connection info: {0}
14511451
WLSDPLY-12571=Error in setting up ATP connection string: {0}
1452+
WLSDPLY-12572=Failed to create domain because either RCUDbinfo is missing rcu_db_conn_string or -rcu_db is not specified \
1453+
in command line option
1454+
WLSDPLY-12573=Invalid databaseType specified in RCUDbInfo: {0}. It must be 'SSL' or 'ATP'
1455+
WLSDPLY-12574=Path: {0} specified for JDBC driver property: {1} does not exists. Please check your model's RCUDbInfo section.
1456+
WLSDPLY_12575=Setting rcu datasource {0} driver params - url: {1} schema: {2} properties: {3}
14521457

14531458
# domain_typedef.py
14541459
WLSDPLY-12300={0} got the domain type {1} but the domain type definition file {2} was not valid: {3}

0 commit comments

Comments
 (0)