-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
139 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
...-hive/src/main/java/io/prestosql/plugin/hive/authentication/HiveAuthenticationConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.prestosql.plugin.hive.authentication; | ||
|
||
import io.airlift.configuration.Config; | ||
import io.airlift.configuration.ConfigDescription; | ||
|
||
import javax.validation.constraints.NotNull; | ||
|
||
public class HiveAuthenticationConfig | ||
{ | ||
private HiveMetastoreAuthenticationType hiveMetastoreAuthenticationType = HiveMetastoreAuthenticationType.NONE; | ||
private HdfsAuthenticationType hdfsAuthenticationType = HdfsAuthenticationType.NONE; | ||
private boolean hdfsImpersonationEnabled; | ||
|
||
public enum HiveMetastoreAuthenticationType | ||
{ | ||
NONE, | ||
KERBEROS | ||
} | ||
|
||
@NotNull | ||
public HiveMetastoreAuthenticationType getHiveMetastoreAuthenticationType() | ||
{ | ||
return hiveMetastoreAuthenticationType; | ||
} | ||
|
||
@Config("hive.metastore.authentication.type") | ||
@ConfigDescription("Hive Metastore authentication type") | ||
public HiveAuthenticationConfig setHiveMetastoreAuthenticationType(HiveMetastoreAuthenticationType hiveMetastoreAuthenticationType) | ||
{ | ||
this.hiveMetastoreAuthenticationType = hiveMetastoreAuthenticationType; | ||
return this; | ||
} | ||
|
||
public enum HdfsAuthenticationType | ||
{ | ||
NONE, | ||
KERBEROS, | ||
} | ||
|
||
@NotNull | ||
public HdfsAuthenticationType getHdfsAuthenticationType() | ||
{ | ||
return hdfsAuthenticationType; | ||
} | ||
|
||
@Config("hive.hdfs.authentication.type") | ||
@ConfigDescription("HDFS authentication type") | ||
public HiveAuthenticationConfig setHdfsAuthenticationType(HdfsAuthenticationType hdfsAuthenticationType) | ||
{ | ||
this.hdfsAuthenticationType = hdfsAuthenticationType; | ||
return this; | ||
} | ||
|
||
public boolean isHdfsImpersonationEnabled() | ||
{ | ||
return hdfsImpersonationEnabled; | ||
} | ||
|
||
@Config("hive.hdfs.impersonation.enabled") | ||
@ConfigDescription("Should Presto user be impersonated when communicating with HDFS") | ||
public HiveAuthenticationConfig setHdfsImpersonationEnabled(boolean hdfsImpersonationEnabled) | ||
{ | ||
this.hdfsImpersonationEnabled = hdfsImpersonationEnabled; | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...e/src/test/java/io/prestosql/plugin/hive/authentication/TestHiveAuthenticationConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.prestosql.plugin.hive.authentication; | ||
|
||
import com.google.common.collect.ImmutableMap; | ||
import io.prestosql.plugin.hive.authentication.HiveAuthenticationConfig.HdfsAuthenticationType; | ||
import io.prestosql.plugin.hive.authentication.HiveAuthenticationConfig.HiveMetastoreAuthenticationType; | ||
import org.testng.annotations.Test; | ||
|
||
import java.util.Map; | ||
|
||
import static io.airlift.configuration.testing.ConfigAssertions.assertFullMapping; | ||
import static io.airlift.configuration.testing.ConfigAssertions.assertRecordedDefaults; | ||
import static io.airlift.configuration.testing.ConfigAssertions.recordDefaults; | ||
|
||
public class TestHiveAuthenticationConfig | ||
{ | ||
@Test | ||
public void testDefaults() | ||
{ | ||
assertRecordedDefaults(recordDefaults(HiveAuthenticationConfig.class) | ||
.setHiveMetastoreAuthenticationType(HiveMetastoreAuthenticationType.NONE) | ||
.setHdfsAuthenticationType(HdfsAuthenticationType.NONE) | ||
.setHdfsImpersonationEnabled(false)); | ||
} | ||
|
||
@Test | ||
public void testExplicitPropertyMappings() | ||
{ | ||
Map<String, String> properties = new ImmutableMap.Builder<String, String>() | ||
.put("hive.metastore.authentication.type", "KERBEROS") | ||
.put("hive.hdfs.authentication.type", "KERBEROS") | ||
.put("hive.hdfs.impersonation.enabled", "true") | ||
.build(); | ||
|
||
HiveAuthenticationConfig expected = new HiveAuthenticationConfig() | ||
.setHiveMetastoreAuthenticationType(HiveMetastoreAuthenticationType.KERBEROS) | ||
.setHdfsAuthenticationType(HdfsAuthenticationType.KERBEROS) | ||
.setHdfsImpersonationEnabled(true); | ||
|
||
assertFullMapping(properties, expected); | ||
} | ||
} |