steveloughran commented on code in PR #5352:
URL: https://github.com/apache/hadoop/pull/5352#discussion_r1253054904
##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java:
##########
@@ -2483,6 +2483,36 @@ public char[] getPasswordFromCredentialProviders(String
name)
return pass;
}
+ /**
+ * Try and resolve the provided element name as a credential provider
+ * alias from the given provider path.
+ * @param name alias of the provisioned credential
+ * @param name credProviderPath path for credential provider
+ * @return password or null if not found
+ * @throws IOException when error in fetching password
+ */
+ public char[] getPasswordFromCredentialProvider(String name, String
credProviderPath)
+ throws IOException {
+ try {
+ CredentialProvider provider = CredentialProviderFactory.getProvider(this,
+ credProviderPath);
+ if (provider != null) {
+ try {
+ CredentialEntry entry = getCredentialEntry(provider, name);
+ if (entry != null) {
+ return entry.getCredential();
+ }
+ } catch (IOException ioe) {
+ throw new IOException("Can't get key " + name + " from key provider"
Review Comment:
this loses the original class. how about making
NetUtils.wrapException() public and using it to generate an IOE of the same
type, where possible.
##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/alias/CredentialProviderFactory.java:
##########
@@ -110,4 +110,31 @@ public static List<CredentialProvider>
getProviders(Configuration conf
}
return result;
}
+
+ /**
+ * Get CredentialProvider for hive provider path.
+ *
+ * @param conf configuration object
+ * @param credProviderPath provider path
+ * @return credProviderPath object
+ */
+ public static CredentialProvider getProvider(Configuration conf,
+ String credProviderPath) throws IOException {
Review Comment:
have caller pass in the URI; makes it their problem to create that from a
Path, string, etc.
##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/alias/CredentialProviderFactory.java:
##########
@@ -110,4 +110,31 @@ public static List<CredentialProvider>
getProviders(Configuration conf
}
return result;
}
+
+ /**
+ * Get CredentialProvider for hive provider path.
Review Comment:
nit: not just hive
##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java:
##########
@@ -2483,6 +2483,36 @@ public char[] getPasswordFromCredentialProviders(String
name)
return pass;
}
+ /**
+ * Try and resolve the provided element name as a credential provider
+ * alias from the given provider path.
+ * @param name alias of the provisioned credential
+ * @param name credProviderPath path for credential provider
+ * @return password or null if not found
+ * @throws IOException when error in fetching password
+ */
+ public char[] getPasswordFromCredentialProvider(String name, String
credProviderPath)
Review Comment:
have caller pass in the URI; makes it their problem to create that from a
Path, string, etc. change name appropriately
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]