# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # Script Name: UpdateFDMEEPasswordFile.py # Author: Matthias Heilos, FinTech Innovations # Copyright: FinTech Innovations, 2018 # Created on: March 10, 2018 # URL: https://www.fintechinnovations.com/wp-content/uploads/2018/03/UpdateFDMEEPasswordFile_v1.txt # Purpose: this script can be used as a Custom script in FDMEE to simplify # updating FDMEE Password files. Leave the script as is and only # define the values for a few variables as indicated below # Distributed under: Apache License v2.0 (http://www.apache.org/licenses/LICENSE-2.0) # As part of this, please note specifically: # 4.c. You must retain, in the Source form of any Derivative Works that You # distribute, all copyright, patent, trademark, and attribution notices # from the Source form of the Work, excluding those notices that do not # pertain to any part of the Derivative Works... # Disclaimer: Please read our Privacy Statement and Terms of Use available at # https://www.fintechinnovations.com/privacy-statement/ and # https://www.fintechinnovations.com/terms-of-use/ # Installation steps: # 1) Log on to FDMEE and create a Custom Script named "UpdateFDMEEPasswordFile" # 2) Copy the entire content of file "UpdateFDMEEPasswordFile_v1.txt" into the Custom script # 3) Update the variables in section "PLEASE DEFINE THE FOLLOWING VARIABLES" # 4) Register the Custom script and create a Static Parameter named "PASSWORD" # 5) Ensure that FDMEE's Encrypted Password directory has been set correctly # Update the Password File: # 1) Switch to the Script Execution screen and execute the Custom Script # 2) Enter the password as a parameter (entered value will be ignored if password is entered directly in the script) # 3) Run FDMEE's loaddata script (from command line) # 4) Check the Data Load status to ensure the password file has been updated correctly # Compatible FDMEE Versions: 11.1.2.4 (was not able to test with 11.1.2.3, might work also) # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # import os import sys import os.path from java.lang import System from java.io import ByteArrayInputStream from java.lang import String # # # # # # # # # # # # # # # # # # # # # # # # # # PLEASE DEFINE THE FOLLOWING VARIABLES - START # # # # # # # # # # # # # # # # # # # # # # # # # # # Leave the password as "" to retrieve it from a script parameter when you execute the script # Optional: You can also set the password directly in the script (i.e. script parameter will be ignored) strPassword = "" # enter Name of Password file (password will be stored in FDMEE Password directory) strPasswordFile = "name_of_password_file.txt" # define your own log handle if desired strLogPrefix = "log@FinTechInnovations: " # # # # # # # # # # # # # # # # # # # # # # # # # # PLEASE DEFINE THE FOLLOWING VARIABLES - END # # # # # # # # # # # # # # # # # # # # # # # # # # # STEP 1: MANAGE PASSWORD # get password from Script parameter (unless defined directly in this script) if strPassword == "": fdmAPI.logInfo(strLogPrefix + "Retrieving Password from Script Parameter") # retrieve password from Script Parameter strPassword = fdmAPI.getCustomScriptParameterValue("PASSWORD") # Overwrite plain text password in database strUPDATE = "UPDATE aif_process_parameters SET paramvalue = '' WHERE paramName = 'PASSWORD' AND process_id = ?" # get FDMEE Process Id and add as parameter for UPDATE statement params = [ fdmContext["LOADID"] ] fdmAPI.logInfo(strLogPrefix + "overwriting plain text password in database: " + strUPDATE) # execute UPDATE statement to overwrite password intStatus = fdmAPI.executeDML(strUPDATE, params, False) # check status of overwriting the password in the database if intStatus == 1: fdmAPI.logInfo(strLogPrefix + "Overwriting Plain Text Password Successful") elif intStatus == 0: fdmAPI.logWarn(strLogPrefix + "Overwriting Plain Text Password FAILED") else: fdmAPI.logInfo(strLogPrefix + "Unexpected Return Value: " + str(intStatus)) fdmAPI.commitTransaction() else: fdmAPI.logInfo(strLogPrefix + "Password has been defined directly in Script (Script Parameter will be ignored)") # STEP 2: VALIDATE ENCRYPTED PASSWORD FOLDER # This step validates that the Encrypted Passsword Folder option (under System Settings > File) has # been set to a valid directory. This is required for the BatchExecutor process to work properly. strProfileOptionName = "ENCRYPT_PASSWORD_DIR" strErrorMessage = """ ERROR: "Encrypted Password Folder" is undefined. Description: The System Setting "Encrypted Password Folder" needs to be defined for this script to work. This is the directory where password files are stored. Resolution steps: 1) In Data Management, navigate to the Setup tab, then choose System Settings 2) Select the Profile Type as File 3) Set "Encrypted Password Folder" to a valid directory on the FDMEE server (Technical Info: strPasswordFolder=" + str(strPasswordFolder) + ") """ intApplicationId = None strUserName = None strPasswordFolder = fdmAPI.getProfileOptionValue(strProfileOptionName, intApplicationId, strUserName) if strPasswordFolder == None: fdmAPI.logError(strLogPrefix + strErrorMessage) raise("Please define the 'Encrypted Password Folder'") else: fdmAPI.logInfo(strLogPrefix + "PasswordFolder has been defined: " + strPasswordFolder) if os.path.exists(strPasswordFolder): if os.path.isfile(strPasswordFolder): fdmAPI.logError(strLogPrefix + "PasswordFolder is NOT valid") raise("'Encrypted Password Folder' is currently set to a file, but needs to be a directory") else: fdmAPI.logInfo(strLogPrefix + "PasswordFolder is a valid folder") else: fdmAPI.logError(strLogPrefix + "PasswordFolder is NOT valid") raise("Please correct the 'Encrypted Password Folder'") # STEP 3: ADD REQUIRED JAR FILES TO PATH VARIABLE # retrieve information about the environment strEpmOracleHome = os.environ['EPM_ORACLE_HOME'] fdmAPI.logInfo(strLogPrefix + "EPM_ORACLE_HOME=" + strEpmOracleHome) # define list of jar files to add to the environment PATH arrJarsToImport = [ strEpmOracleHome + os.path.sep + "products" + os.path.sep + "FinancialDataQuality" + os.path.sep + "lib" + os.path.sep + "aif-batch.jar", ] # add jars to environment PATH - only if they have not already been added fdmAPI.logInfo(strLogPrefix + "Adding Jars to Path:") # get initial value of sys.path, replace double backslash strSysPath = str(sys.path) fdmAPI.logInfo(strLogPrefix + "sys.path (before adding additional Jars): " + strSysPath) strSysPath = strSysPath.replace(os.path.sep + os.path.sep, os.path.sep) # process each Jar to be imported for strJar in arrJarsToImport: if os.path.exists(strJar): # fdmAPI.logInfo(strLogPrefix + "Jar '" + strJar + "' exists") fdmAPI.logInfo(strLogPrefix + "strJar=" + strJar + " IN " + strSysPath + "?") if not strJar in strSysPath: fdmAPI.logInfo(strLogPrefix + "Adding Jar '" + strJar + "'") sys.path.append(strJar) else: fdmAPI.logInfo(strLogPrefix + "Jar file '" + strJar + "' has already been added to PATH and will not be added again") else: strErrorMessage = "Jar file '" + module + "' does NOT exist. Process will abort." fdmAPI.logFatal(strLogPrefix + strErrorMessage) raise strErrorMessage # STEP 4: ASSIGN PASSWORD TO STANDARD INPUT # assign the new password to a variable of the Java type String fdmAPI.logInfo(strLogPrefix + "Create String to store password") strInput = String(strPassword) # assign the password string as bytes to the InputStream fdmAPI.logInfo(strLogPrefix + "Assign Password to ByteArrayInputStream") bais = ByteArrayInputStream(strInput.getBytes()) # assign the ByteArrayInputStream as the Standard Input fdmAPI.logInfo(strLogPrefix + "Set ByteArrayInputStream as StandardInput") System.setIn(bais) # STEP 5: UPDATE PASSWORD FILE VIA BATCHEXECUTOR # import the BatchExecutor class which is available now that we imported the jar files fdmAPI.logInfo(strLogPrefix + "Import Class BatchExecutor") from com.hyperion.aif.util import BatchExecutor # create an object of class BatchExecutor fdmAPI.logInfo(strLogPrefix + "Create BatchExecutor object") be = BatchExecutor() # define the arguments to pass into the main() method of the the BatchExecutor object fdmAPI.logInfo(strLogPrefix + "Define Arguments") args = [ "encryptpassword" , strPasswordFile ] # launch the main() method with the parameters fdmAPI.logInfo(strLogPrefix + "Launch Main method of BatchExecutor object") be.main(args) # confirm that the password file has been created successfully fdmAPI.logInfo(strLogPrefix + "Password file has been successfully updated")