Skip to content

Commit

Permalink
HIVE-22720: Optimise AuthenticationProviderFactory::getAuthentication…
Browse files Browse the repository at this point in the history
…Provider (Rajesh Balamohan, reviewed by Ashutosh Chauhan, Gopal V)
  • Loading branch information
rbalamohan committed Jan 16, 2020
1 parent 3b1138b commit c5ffb78
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public enum AuthMethods {

private final String authMethod;

private final HiveConf conf = new HiveConf();

AuthMethods(String authMethod) {
this.authMethod = authMethod;
}
Expand All @@ -42,6 +44,10 @@ public String getAuthMethod() {
return authMethod;
}

public HiveConf getConf() {
return conf;
}

public static AuthMethods getValidAuthMethod(String authMethodStr)
throws AuthenticationException {
for (AuthMethods auth : AuthMethods.values()) {
Expand All @@ -58,16 +64,16 @@ private AuthenticationProviderFactory() {

public static PasswdAuthenticationProvider getAuthenticationProvider(AuthMethods authMethod)
throws AuthenticationException {
return getAuthenticationProvider(authMethod, new HiveConf());
return getAuthenticationProvider(authMethod, null);
}
public static PasswdAuthenticationProvider getAuthenticationProvider(AuthMethods authMethod, HiveConf conf)
throws AuthenticationException {
if (authMethod == AuthMethods.LDAP) {
return new LdapAuthenticationProviderImpl(conf);
return new LdapAuthenticationProviderImpl((conf == null) ? AuthMethods.LDAP.getConf() : conf);
} else if (authMethod == AuthMethods.PAM) {
return new PamAuthenticationProviderImpl(conf);
return new PamAuthenticationProviderImpl((conf == null) ? AuthMethods.PAM.getConf() : conf);
} else if (authMethod == AuthMethods.CUSTOM) {
return new CustomAuthenticationProviderImpl(conf);
return new CustomAuthenticationProviderImpl((conf == null) ? AuthMethods.CUSTOM.getConf() : conf);
} else if (authMethod == AuthMethods.NONE) {
return new AnonymousAuthenticationProviderImpl();
} else {
Expand Down

0 comments on commit c5ffb78

Please sign in to comment.