def sanityCheckOnlineConfig(cfg): error = 0 nmPassword = cfg.getProperty('nodemanager.password') nmUsername = cfg.getProperty('nodemanager.username') prompt = cfg.getProperty('password.prompt') if nmUsername and not nmPassword: if prompt is not None and prompt.lower() == 'true': dont_match = 1 while dont_match: print 'Please enter the Nodemanager password: '******'Please re-enter the Nodemanager password: '******'PASSWORDS DO NOT MATCH' cfg.setProperty('nodemanager.password', nm_password1) else: log.error( 'Please verify nodemanager.password property exists in configuration' ) error = 1 if error: sys.exit()
def validateAdminPassword(domainProperties): error=0 admin_password = domainProperties.getProperty('wls.admin.password') prompt=domainProperties.getProperty('password.prompt') if admin_password is None or len(admin_password)==0: if prompt is not None and prompt.lower()=='true': admin_username=domainProperties.getProperty('wls.admin.username') if admin_username and not admin_password: dont_match=1 while dont_match: print 'Please enter WebLogic admin password: '******'Please re-enter the WebLogic admin password: '******'PASSWORDS DO NOT MATCH' domainProperties.setProperty('wls.admin.password',admin_password1) else: log.error('Please verify wls.admin.password property exists in configuration.') error=1 else: log.debug('Admin password is valid.') if error: sys.exit()
def __checkJdbcPasswords(domainProperties): # Check if global.jdbc.password flag is set to determine if the same JDBC password is to be used for each datasource. globalJdbcPasswordEnabled = domainProperties.getProperty('global.jdbc.password') jdbcDatasources=domainProperties.getProperty('jdbc.datasources') if jdbcDatasources: jdbcList=jdbcDatasources.split(',') for datasource in jdbcList: dsPassword=None dsPassword=domainProperties.getProperty('jdbc.datasource.' + str(datasource) + '.Password') if not dsPassword: if globalJdbcPasswordEnabled: globalJdbcPasswordValue = domainProperties.getProperty('global.jdbc.password.value') if not globalJdbcPasswordValue: log.info('Property global.jdbc.password is set, which indicates that all JDBC data sources have the same password.') dont_match=1 while dont_match: print 'Please enter the password for all JDBC data sources: ' password1=System.console().readPassword().tostring() print 'Please re-enter the password for all JDBC data sources: ' password2=System.console().readPassword().tostring() if password1==password2: dont_match=0 else: print 'PASSWORDS DO NOT MATCH' domainProperties.setProperty('global.jdbc.password.value', password1) globalJdbcPasswordValue=password1 domainProperties.setProperty('jdbc.datasource.' + str(datasource) + '.Password', globalJdbcPasswordValue) else: print 'Please enter password for JDBC data source [' + str(datasource) + '] :' password=System.console().readPassword().tostring() domainProperties.setProperty('jdbc.datasource.' + str(datasource) + '.Password', password)
def __process_passphrase_arg(optional_arg_map): """ Prompt for the passphrase. :param optional_arg_map: the optional arguments map :raises CLAException: if an error occurs reading the passphrase input from the user """ _method_name = '__process_passphrase_arg' if CommandLineArgUtil.PASSPHRASE_SWITCH not in optional_arg_map: got_matching_passphrases = False while not got_matching_passphrases: try: passphrase = getcreds.getpass('WLSDPLY-04203') passphrase2 = getcreds.getpass('WLSDPLY-04204') except IOException, ioe: ex = exception_helper.create_encryption_exception( 'WLSDPLY-04205', ioe.getLocalizedMessage(), error=ioe) __logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex if passphrase == passphrase2: got_matching_passphrases = True optional_arg_map[ CommandLineArgUtil.PASSPHRASE_SWITCH] = String(passphrase) else: # if it is script mode do not prompt again if System.console() is None: ex = exception_helper.create_cla_exception('WLSDPLY-04213') ex.setExitCode(CommandLineArgUtil.PROG_ERROR_EXIT_CODE) __logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex
def __main_cipher(app_ctx): from java.lang import System from java.lang import String crypto_utils = CryptoUtils.createAESCrypto() encryption_key = crypto_utils.generateKey() console = System.console() logger.info("{}", "#" * 80) logger.info( " Start to input AWS access key id & AWS secret acces key ... ") logger.info(" P.S. No echo would display back to the console)") logger.info("{}", "#" * 80) ## version 1: aws_access_key_id = console.readPassword("Please enter AWS access key: ") aws_secret_access_key = console.readPassword( "Please enter AWS secret access key: ") encrypt_key_id = CryptoUtils.toHexString( crypto_utils.encrypt(String(aws_access_key_id), encryption_key)) encrypt_access_key = CryptoUtils.toHexString( crypto_utils.encrypt(String(aws_secret_access_key), encryption_key)) ## version 2: # aws_access_key_id = console.readLine("Please enter AWS access key: ") # aws_secret_access_key = console.readLine("Please enter AWS secret access key: ") # encrypt_key_id = CryptoUtils.toHexString(crypto_utils.encrypt(aws_access_key_id, encryption_key)) # encrypt_access_key = CryptoUtils.toHexString(crypto_utils.encrypt(aws_secret_access_key, encryption_key)) write_key(app_ctx.aws_crypto_key_path, encryption_key) write_aws_crypto(app_ctx.aws_crypto_path, encrypt_key_id, encrypt_access_key)
def java6_getpass(prompt="Password: "******"".join(console.readPassword())
def sanityCheckOnlineConfig(cfg): error=0 nmPassword=cfg.getProperty('nodemanager.password') nmUsername=cfg.getProperty('nodemanager.username') prompt=cfg.getProperty('password.prompt') if nmUsername and not nmPassword: if prompt is not None and prompt.lower()=='true': dont_match=1 while dont_match: print 'Please enter the Nodemanager password: '******'Please re-enter the Nodemanager password: '******'PASSWORDS DO NOT MATCH' cfg.setProperty('nodemanager.password', nm_password1) else: log.error('Please verify nodemanager.password property exists in configuration') error = 1 if error: sys.exit()
def readPwd(user): cons = System.console() prompt = array(["Please enter password for user '"+user+"': "],String) if cons != None: pw = cons.readPassword("%s", prompt) if pw != None: s = String(pw) java.util.Arrays.fill(pw, ' '); return s else: # We assume there will be no more than a total of 5 arguments passed to this script. # Change if more arguments are added. Check is just a barf protection. if len(sys.argv) >= 4: for i in xrange(2,4): p = sys.argv[i].split('=') if p[0] == user: return p[1] return ''
def readPwd(user): cons = System.console() prompt = array(["Please enter password for user '" + user + "': "], String) if cons != None: pw = cons.readPassword("%s", prompt) if pw != None: s = String(pw) java.util.Arrays.fill(pw, ' ') return s else: # We assume there will be no more than a total of 5 arguments passed to this script. # Change if more arguments are added. Check is just a barf protection. if len(sys.argv) >= 4: for i in xrange(2, 4): p = sys.argv[i].split('=') if p[0] == user: return p[1] return ''
def getpassword(username): """ Retrieves the password from the commom location. The password file is a properties file located in the scripts tmp dir If the file does'nt exist it creates a new one. :param username: a String containing the key that identifies the desired password :return: a String containing the found password (empty if none) """ username = username.upper() password_file = os.getenv('SCRIPTS_TMP') + '/password.properties' passwords = {} a_file = None try: a_file = open(password_file, 'r+') file_lines = a_file.readlines() for line in file_lines: line = line.rstrip() # removes trailing whitespace and '\n' chars if "=" not in line: continue # skips blanks and comments w/o = if line.startswith("#"): continue # skips comments which contain = k, v = line.split("=", 1) passwords[k] = v except IOError: a_file = open(password_file, 'w+') print 'Creating Password File at : ' + password_file try: apassword = passwords[username] except: # Prompt for Password console = System.console() input_passwd = console.readPassword("%s", [username + " PASSWORD: "******"".join(input_passwd) a_file.write(username + '=' + apassword + '\n') a_file.close() return apassword