Skip to content

Instantly share code, notes, and snippets.

@saisgit
Created April 25, 2020 12:31
Show Gist options
  • Save saisgit/3ce34ba34031da769a5260968b23009d to your computer and use it in GitHub Desktop.
Save saisgit/3ce34ba34031da769a5260968b23009d to your computer and use it in GitHub Desktop.
'''
Function to Retrieve the password from JCEKS file in PySpark
Parameters: SparkContext(sc), JCEKSFILE in hadoop path(jceksfile), Password alias for the jceks(password_alias)
Returns: Password string
'''
def extractPwdFromJceks(sc,jceksfile,password_alias):
config_jceks = sc._jsc.hadoopConfiguration()
config_jceks.set("hadoop.security.credential.provider.path",jceksfile)
temp = config_jceks.getPassword(password_alias)
password = ""
for i in range(temp.__len()__):
password = password+str(temp.__getitem__(i))
return password
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment