Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HBASE-23347 Allow custom authentication methods for RPCs; addendum #1060

Merged
merged 3 commits into from Jan 21, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -17,6 +17,7 @@
*/
package org.apache.hadoop.hbase.security.provider;

import java.lang.reflect.InvocationTargetException;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
Expand Down Expand Up @@ -111,13 +112,14 @@ static AuthenticationProviderSelector instantiateSelector(Configuration conf,
Class<? extends AuthenticationProviderSelector> clz = conf.getClass(
SELECTOR_KEY, BuiltInProviderSelector.class, AuthenticationProviderSelector.class);
try {
AuthenticationProviderSelector selector = clz.newInstance();
AuthenticationProviderSelector selector = clz.getConstructor().newInstance();
selector.configure(conf, providers);
if (LOG.isTraceEnabled()) {
LOG.trace("Loaded ProviderSelector {}", selector.getClass());
}
return selector;
} catch (InstantiationException | IllegalAccessException e) {
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException |
InvocationTargetException e) {
throw new RuntimeException("Failed to instantiate " + clz +
" as the ProviderSelector defined by " + SELECTOR_KEY, e);
}
Expand Down Expand Up @@ -148,8 +150,9 @@ static void addExplicitProviders(Configuration conf,
// Instantiate it
SaslClientAuthenticationProvider provider;
try {
provider = (SaslClientAuthenticationProvider) clz.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
provider = (SaslClientAuthenticationProvider) clz.getConstructor().newInstance();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This modification causes TestSaslClientAuthenticationProviders#testDifferentConflictingImplementationsFail test failure. I'll look into it later.

} catch (InstantiationException | IllegalAccessException | NoSuchMethodException
| InvocationTargetException e) {
LOG.warn("Failed to instantiate SaslClientAuthenticationProvider {}", clz, e);
continue;
}
Expand Down
Expand Up @@ -18,6 +18,7 @@
package org.apache.hadoop.hbase.security.provider;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Optional;
import java.util.ServiceLoader;
Expand Down Expand Up @@ -120,9 +121,10 @@ static void addExtraProviders(Configuration conf,

try {
SaslServerAuthenticationProvider provider =
(SaslServerAuthenticationProvider) clz.newInstance();
(SaslServerAuthenticationProvider) clz.getConstructor().newInstance();
addProviderIfNotExists(provider, providers);
} catch (InstantiationException | IllegalAccessException e) {
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException
| InvocationTargetException e) {
LOG.warn("Failed to instantiate {}", clz, e);
}
}
Expand Down