@@ -754,7 +754,8 @@ def __check_and_customize_model(model, model_context, aliases, credential_inject
754
754
__logger .info ('WLSDPLY-06014' , _class_name = _class_name , method_name = _method_name )
755
755
756
756
filter_helper .apply_final_filters (model .get_model (), model .get_model (), model_context )
757
- __fix_discovered_template_datasource (model , model_context )
757
+
758
+ __fix_discovered_template_datasource (model , model_context , credential_injector )
758
759
759
760
credential_cache = None
760
761
if credential_injector is not None :
@@ -772,7 +773,6 @@ def __check_and_customize_model(model, model_context, aliases, credential_inject
772
773
773
774
# Apply the injectors specified in model_variable_injector.json, or in the target configuration.
774
775
# Include the variable mappings that were collected in credential_cache.
775
-
776
776
variable_injector = VariableInjector (_program_name , model_context , aliases , variable_dictionary = credential_cache )
777
777
778
778
variable_injector .add_to_cache (dictionary = extra_tokens )
@@ -809,7 +809,7 @@ def __compare_wls_versions(model_context):
809
809
__logger .notification (
810
810
'WLSDPLY-06068' , message_start , class_name = _class_name , method_name = _method_name )
811
811
812
- def __fix_discovered_template_datasource (model , model_context ):
812
+ def __fix_discovered_template_datasource (model , model_context , credential_injector ):
813
813
# fix the case for discovering template datasources.
814
814
# If all the template datasources use the dame passwords then generate the RUCDbInfo section
815
815
# and remove the template datasources from the model
@@ -823,25 +823,27 @@ def __fix_discovered_template_datasource(model, model_context):
823
823
resources = model .get_model_resources ()
824
824
jdbc_system_resources = dictionary_utils .get_element (resources , JDBC_SYSTEM_RESOURCE )
825
825
discover_filters = domain_typedef ._discover_filters
826
- filtered_ds_patterns = dictionary_utils .get_element (discover_filters ,'/JDBCSystemResource' )
826
+ filtered_ds_patterns = dictionary_utils .get_element (discover_filters ,'/JDBCSystemResource' ,
827
+ None )
827
828
passwords = HashSet ()
828
829
urls = HashSet ()
829
830
prefixes = HashSet ()
830
- properties = __get_urls_and_passwords (model_context , jdbc_system_resources , filtered_ds_patterns ,
831
+ properties = __get_urls_and_passwords (jdbc_system_resources , filtered_ds_patterns ,
831
832
urls , passwords , prefixes )
832
833
if _can_generate_rcudb_info (passwords , urls , prefixes ):
833
834
__set_rcuinfo_in_model (model , properties , urls .iterator ().next (), passwords .iterator ().next ())
834
835
__remove_discovered_template_datasource (jdbc_system_resources , filtered_ds_patterns , model )
835
- __fix_rcudbinfo_passwords (model , model_context , model_context . is_discover_passwords () )
836
+ __fix_rcudbinfo_passwords (model , model_context , credential_injector )
836
837
else :
837
- __reset_password_to_regular_discovery (jdbc_system_resources , filtered_ds_patterns , model_context )
838
+ __reset_password_to_regular_discovery (model , filtered_ds_patterns , model_context , credential_injector )
838
839
839
840
__logger .exiting (_class_name , _method_name )
840
841
842
+
841
843
def _can_generate_rcudb_info (passwords , urls , prefixes ):
842
844
return passwords .size () == 1 and urls .size () == 1 and prefixes .size () == 1
843
845
844
- def __get_urls_and_passwords (model_context , jdbc_system_resources , filtered_ds_patterns , urls , passwords , prefixes ):
846
+ def __get_urls_and_passwords (jdbc_system_resources , filtered_ds_patterns , urls , passwords , prefixes ):
845
847
properties = None
846
848
for item in jdbc_system_resources :
847
849
if not __match_filtered_ds_name (item , filtered_ds_patterns ):
@@ -944,10 +946,22 @@ def __remove_discovered_template_datasource(jdbc_system_resources, filtered_ds_p
944
946
if len (resources ) == 0 :
945
947
del model_dict [RESOURCES ]
946
948
947
- def __reset_password_to_regular_discovery (jdbc_system_resources , filtered_ds_patterns , model_context ):
949
+ def __reset_password_to_regular_discovery (model , filtered_ds_patterns , model_context , credential_injector ):
950
+
951
+ resources = model .get_model_resources ()
952
+ jdbc_system_resources = dictionary_utils .get_element (resources , JDBC_SYSTEM_RESOURCE )
953
+
948
954
for item in jdbc_system_resources :
949
955
if not __match_filtered_ds_name (item , filtered_ds_patterns ):
950
956
continue
957
+
958
+ location = LocationContext ().append_location (JDBC_SYSTEM_RESOURCE )
959
+ location .append_location (JDBC_RESOURCE , JDBC_DRIVER_PARAMS )
960
+ location .add_name_token ('DOMAIN' , model_context .get_domain_name ())
961
+ location .add_name_token ('DATASOURCE' , item )
962
+ location .add_name_token ('JDBCRESOURCE' , item )
963
+ location .add_name_token ('JDBCDRIVERPARAMS' , 'NO_NAME_0' )
964
+
951
965
jdbc_system_resource = jdbc_system_resources [item ]
952
966
jdbc_resource = dictionary_utils .get_element (jdbc_system_resource , JDBC_RESOURCE )
953
967
driver_params = dictionary_utils .get_element (jdbc_resource , JDBC_DRIVER_PARAMS )
@@ -958,9 +972,12 @@ def __reset_password_to_regular_discovery(jdbc_system_resources, filtered_ds_pat
958
972
driver_params [PASSWORD_ENCRYPTED ] = encrypted_model_value
959
973
else :
960
974
driver_params [PASSWORD_ENCRYPTED ] = alias_constants .PASSWORD_TOKEN
961
- return
962
975
963
- def __fix_rcudbinfo_passwords (model , model_context , encrypt = False ):
976
+ if credential_injector :
977
+ credential_injector .check_and_tokenize (driver_params , PASSWORD_ENCRYPTED , location )
978
+
979
+
980
+ def __fix_rcudbinfo_passwords (model , model_context , credential_injector ):
964
981
965
982
model_dict = model .get_model ()
966
983
rcudb_info = model_dict [DOMAIN_INFO ][RCU_DB_INFO ]
@@ -971,20 +988,31 @@ def __fix_rcudbinfo_passwords(model, model_context, encrypt=False):
971
988
DRIVER_PARAMS_KEYSTOREPWD_PROPERTY
972
989
]
973
990
991
+ is_discover_password = model_context .is_discover_passwords ()
992
+
993
+ location = LocationContext ().append_location (RCU_DB_INFO )
994
+
974
995
for item in possible_pwds :
975
996
if item in rcudb_info :
976
- if encrypt :
997
+ if is_discover_password :
977
998
passwd = rcudb_info [item ]
978
- rcudb_info [ item ] = encryption_utils .encrypt_one_password (
999
+ model_value = encryption_utils .encrypt_one_password (
979
1000
model_context .get_encryption_passphrase (), passwd )
1001
+ rcudb_info [item ] = model_value
980
1002
else :
981
1003
rcudb_info [item ] = alias_constants .PASSWORD_TOKEN
982
1004
1005
+ if credential_injector :
1006
+ credential_injector .check_and_tokenize (rcudb_info , item , location )
1007
+
1008
+
1009
+
983
1010
def __match_filtered_ds_name (name , patterns ):
984
- for pattern in patterns :
985
- regex = re .compile (pattern )
986
- if regex .match (name ):
987
- return True
1011
+ if patterns is not None :
1012
+ for pattern in patterns :
1013
+ regex = re .compile (pattern )
1014
+ if regex .match (name ):
1015
+ return True
988
1016
return False
989
1017
990
1018
def __generate_remote_report_json (model_context ):
@@ -1056,8 +1084,6 @@ def main(model_context):
1056
1084
password_key = 'WLSDPLY-06024'
1057
1085
__logger .info (password_key , class_name = _class_name , method_name = _method_name )
1058
1086
1059
- __compare_wls_versions (model_context )
1060
-
1061
1087
extra_tokens = {}
1062
1088
try :
1063
1089
model = __discover (model_context , aliases , credential_injector , helper , extra_tokens )
0 commit comments