# # # # finish_wizard_util.cfv # # # include "templates.util.profiles.new_profile_util"; include "templates.util.rbac.create_user_grants"; include "templates.util.rbac.rbac_util"; include "templates.util.profile_structure.profile_structure_util"; include "templates.util.backup_util"; # # # handle_user_preferences() # # subroutine(handle_user_preferences( string user_node_name, node fp_user_preferences), ( # Saves the given user preferences for active user string user_preferences_path = "users_cache." . user_node_name . ".preferences"; if (?(fp_user_preferences . ".show_tips.log_file_management")) then ( # Don't show again log_file_management tip (user_preferences_path . ".new_profile_wizard.show_tips.log_file_management") = false; ); if (?(fp_user_preferences . ".show_tips.backup_your_database")) then ( # Don't show again backup_your_database tip (user_preferences_path . ".new_profile_wizard.show_tips.backup_your_database") = false; ); save_node(user_preferences_path); )); # # # finish_wizard_util_save_profile() # # subroutine(finish_wizard_util_save_profile( bool is_root_admin, string user_node_name, string profile_node_name, node new_profile), ( debug_message("\n\n#### finish_wizard_util_save_profile() \n\n"); node odbc_server; # # # Set log_format date_time and host # # string log_data_type = @new_profile{"log_format_type"}; string log_format_name = if (log_data_type eq "standalone") then (@new_profile{"log_format"}) else (@new_profile{"syslog_required_format"}); node log_format = "log_formats." . log_format_name; if (?(log_format . ".create_profile_wizard_options.date_time_tracking") and @(log_format . ".create_profile_wizard_options.date_time_tracking")) then ( @new_profile{"track_date_time"} = "day"; ); if (?(log_format . ".create_profile_wizard_options.host_tracking") and @(log_format . ".create_profile_wizard_options.host_tracking")) then ( @new_profile{"track_host"} = "individually"; ); # # # log_source # # if (new_profile?{"log_format_string"}) then ( debug_message("log format string: " . @new_profile{"log_format_string"} . "\n"); ); node log_source = new_profile . ".log_source.0"; string log_source_type = @log_source{"type"}; # Decode any log source values # Decode any "__HexEsc__" values in log source node # Encrypt passwords node item; string item_value; foreach item log_source ( item_value = node_value(item); @log_source{node_name(item)} = decode_log_source_item_value(item_value); ); # if the log_source type is "local" then decode the pathname and convert from UTF-8 to loacl code page string local_log_source_pathname; if (log_source_type eq "local") then ( local_log_source_pathname = @log_source{"pathname"}; # local_log_source_pathname = replace_all(local_log_source_pathname, "__HexEsc__24", "$"); # local_log_source_pathname = replace_all(local_log_source_pathname, "__HexEsc__5C", "\\"); @log_source{"pathname"} = convert_utf8_to_local_code_page(local_log_source_pathname); ) else if (log_source_type eq "ftp" or log_source_type eq "sftp") then ( # Add username and password if it doesn't exist if (!log_source?{"username"}) then ( @log_source{"username"} = ""; ); if (!log_source?{"password"}) then ( @log_source{"password"} = ""; ); # Encrypt password password = @log_source{"password"}; if (password ne "") then ( @log_source{"password"} = format(password, "!encrypt"); ); ) else if (log_source_type eq "odbc") then ( odbc_server = log_source{"server"}; # Encrypt password if (odbc_server?{"password"} and @odbc_server{"password"} ne "") then ( password = @odbc_server{"password"}; @odbc_server{"password"} = format(password, "!encrypt"); ); ); # # check database server name # # If this is a MySQL or MS SQL database server and no database name has been defined then # set the profile_node_name as the database_name. node database_server = new_profile . ".database.server"; string db_server_type = @database_server{"type"}; debug_message("#### NEW PROFILE - db_server_type:" . db_server_type . "\n\n"); if ((db_server_type eq "mysql" or db_server_type eq "odbc_mssql") and (@database_server{"database_name"} eq "")) then ( @database_server{"database_name"} = profile_node_name; ); # Encrypt database server password if (database_server?{"password"} and @database_server{"password"} ne "") then ( password = @database_server{"password"}; @database_server{"password"} = format(password, "!encrypt"); ); # # # Handle snapons # # if (new_profile?{"snapons"}) then ( # Overlay the log format plug-in snapons node with the new profile snapon parameter values overlay_node(log_format{"create_profile_wizard_options"}{"snapons"}, new_profile{"snapons"}); debug_message("#### log format plug-in after overriding snapons:\n" . node_as_string(log_format{"create_profile_wizard_options"}) . "\n"); ); # # # Set created_by_user # # @new_profile{"created_by_user"} = user_node_name; # # # create the profile # # create_profile(profile_node_name); # # KHP-RC # Temp, fix this part, above created_by_user is not saved within the profile, # so we save it now, this should be removed later and be handled through create_profile() # "profiles." . profile_node_name . ".created_by_user" = user_node_name; # # # Restructure the report elements via restructure_profile() # # # debug_message("#### reports before restructure_profile(): \n" . node_as_string("profiles." . profile_node_name . ".statistics.reports") . "\n"); # debug_message("\n\n\n#### starting restructure_profile() \n"); restructure_profile("profiles." . profile_node_name); # # # Save the profile changes # # save_node("profiles." . profile_node_name); # Create a profiles backup create_profile_backup(profile_node_name); # # # Handle RBAC # # If this is not a root admin and not the lite version then we have to # a.) Update the user roles by adding the new profile to the right profile/roles associations. # b.) Re-create the user_grants in session_info for this user so that the new profile is considered in user_grants # # if (!is_root_admin) then ( string licensing_tier = get_licensing_tier(); if (licensing_tier ne "lite") then ( add_new_profile_to_user(licensing_tier, user_node_name, profile_node_name); create_user_grants(volatile.session_id); ); ); ));