steveloughran commented on code in PR #5352:
URL: https://github.com/apache/hadoop/pull/5352#discussion_r1257309280
##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java:
##########
@@ -2483,6 +2483,38 @@ 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 providerURI The URI of the provider path
+ * @return password or null if not found
+ * @throws IOException when error in fetching password
+ */
+ public char[] getPasswordFromCredentialProvider(String name, URI providerUri)
+ throws IOException {
+ try {
+ CredentialProvider provider = CredentialProviderFactory.getProvider(this,
+ providerUri);
+ if (provider != null) {
+ try {
+ CredentialEntry entry = getCredentialEntry(provider, name);
+ if (entry != null) {
+ return entry.getCredential();
+ }
+ } catch (IOException ioe) {
+ String msg = String.format(
+ "Can't get key %s from key provider of type: %s.", name,
+ provider.getClass().getName());
+ throw NetUtils.wrapWithMessage(ioe, msg);
+ }
+ }
+ } catch (IOException ioe) {
Review Comment:
this will ignore the work done on L2509; really wrapWithMessage() should be
invoked for all, and exactly once.
##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/alias/CredentialProviderFactory.java:
##########
@@ -110,4 +110,26 @@ public static List<CredentialProvider>
getProviders(Configuration conf
}
return result;
}
+
+ /**
+ * Get the CredentialProvider for a given provider URI.
+ *
+ * @param conf The configuration object
+ * @param providerURI The URI of the provider path
+ * @return The CredentialProvider
+ * @throws IOException If an I/O error occurs
+ */
+ public static CredentialProvider getProvider(Configuration conf,
+ URI providerUri) throws IOException {
+ synchronized (serviceLoader) {
+ for (CredentialProviderFactory factory : serviceLoader) {
+ CredentialProvider kp = factory.createProvider(providerUri, conf);
+ if (kp != null) {
+ return kp;
+ }
+ }
+ }
+ throw new IOException(
Review Comment:
PathIOException with path as URI.toString
or FileNotFoundException
--
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]