@@ -754,7 +754,8 @@ def __check_and_customize_model(model, model_context, aliases, credential_inject
754754 __logger .info ('WLSDPLY-06014' , _class_name = _class_name , method_name = _method_name )
755755
756756 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 )
758759
759760 credential_cache = None
760761 if credential_injector is not None :
@@ -772,7 +773,6 @@ def __check_and_customize_model(model, model_context, aliases, credential_inject
772773
773774 # Apply the injectors specified in model_variable_injector.json, or in the target configuration.
774775 # Include the variable mappings that were collected in credential_cache.
775-
776776 variable_injector = VariableInjector (_program_name , model_context , aliases , variable_dictionary = credential_cache )
777777
778778 variable_injector .add_to_cache (dictionary = extra_tokens )
@@ -809,7 +809,7 @@ def __compare_wls_versions(model_context):
809809 __logger .notification (
810810 'WLSDPLY-06068' , message_start , class_name = _class_name , method_name = _method_name )
811811
812- def __fix_discovered_template_datasource (model , model_context ):
812+ def __fix_discovered_template_datasource (model , model_context , credential_injector ):
813813 # fix the case for discovering template datasources.
814814 # If all the template datasources use the dame passwords then generate the RUCDbInfo section
815815 # and remove the template datasources from the model
@@ -823,25 +823,27 @@ def __fix_discovered_template_datasource(model, model_context):
823823 resources = model .get_model_resources ()
824824 jdbc_system_resources = dictionary_utils .get_element (resources , JDBC_SYSTEM_RESOURCE )
825825 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 )
827828 passwords = HashSet ()
828829 urls = HashSet ()
829830 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 ,
831832 urls , passwords , prefixes )
832833 if _can_generate_rcudb_info (passwords , urls , prefixes ):
833834 __set_rcuinfo_in_model (model , properties , urls .iterator ().next (), passwords .iterator ().next ())
834835 __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 )
836837 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 )
838839
839840 __logger .exiting (_class_name , _method_name )
840841
842+
841843def _can_generate_rcudb_info (passwords , urls , prefixes ):
842844 return passwords .size () == 1 and urls .size () == 1 and prefixes .size () == 1
843845
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 ):
845847 properties = None
846848 for item in jdbc_system_resources :
847849 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
944946 if len (resources ) == 0 :
945947 del model_dict [RESOURCES ]
946948
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+
948954 for item in jdbc_system_resources :
949955 if not __match_filtered_ds_name (item , filtered_ds_patterns ):
950956 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+
951965 jdbc_system_resource = jdbc_system_resources [item ]
952966 jdbc_resource = dictionary_utils .get_element (jdbc_system_resource , JDBC_RESOURCE )
953967 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
958972 driver_params [PASSWORD_ENCRYPTED ] = encrypted_model_value
959973 else :
960974 driver_params [PASSWORD_ENCRYPTED ] = alias_constants .PASSWORD_TOKEN
961- return
962975
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 ):
964981
965982 model_dict = model .get_model ()
966983 rcudb_info = model_dict [DOMAIN_INFO ][RCU_DB_INFO ]
@@ -971,20 +988,31 @@ def __fix_rcudbinfo_passwords(model, model_context, encrypt=False):
971988 DRIVER_PARAMS_KEYSTOREPWD_PROPERTY
972989 ]
973990
991+ is_discover_password = model_context .is_discover_passwords ()
992+
993+ location = LocationContext ().append_location (RCU_DB_INFO )
994+
974995 for item in possible_pwds :
975996 if item in rcudb_info :
976- if encrypt :
997+ if is_discover_password :
977998 passwd = rcudb_info [item ]
978- rcudb_info [ item ] = encryption_utils .encrypt_one_password (
999+ model_value = encryption_utils .encrypt_one_password (
9791000 model_context .get_encryption_passphrase (), passwd )
1001+ rcudb_info [item ] = model_value
9801002 else :
9811003 rcudb_info [item ] = alias_constants .PASSWORD_TOKEN
9821004
1005+ if credential_injector :
1006+ credential_injector .check_and_tokenize (rcudb_info , item , location )
1007+
1008+
1009+
9831010def __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
9881016 return False
9891017
9901018def __generate_remote_report_json (model_context ):
@@ -1056,8 +1084,6 @@ def main(model_context):
10561084 password_key = 'WLSDPLY-06024'
10571085 __logger .info (password_key , class_name = _class_name , method_name = _method_name )
10581086
1059- __compare_wls_versions (model_context )
1060-
10611087 extra_tokens = {}
10621088 try :
10631089 model = __discover (model_context , aliases , credential_injector , helper , extra_tokens )
0 commit comments