Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract KerberosConfig from SecurityConfig
Introduced a new property called "http-server.authentication.type" which can have values NONE, KERBEROS (and LDAP- separate commit).
- Loading branch information
Showing
7 changed files
with
153 additions
and
67 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
presto-main/src/main/java/com/facebook/presto/server/security/KerberosConfig.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,61 @@ | ||
/* | ||
* 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 com.facebook.presto.server.security; | ||
|
||
import io.airlift.configuration.Config; | ||
|
||
import java.io.File; | ||
|
||
public class KerberosConfig | ||
{ | ||
private File kerberosConfig; | ||
private String serviceName; | ||
private File keytab; | ||
|
||
public File getKerberosConfig() | ||
{ | ||
return kerberosConfig; | ||
} | ||
|
||
@Config("http.authentication.krb5.config") | ||
public KerberosConfig setKerberosConfig(File kerberosConfig) | ||
{ | ||
this.kerberosConfig = kerberosConfig; | ||
return this; | ||
} | ||
|
||
public String getServiceName() | ||
{ | ||
return serviceName; | ||
} | ||
|
||
@Config("http.server.authentication.krb5.service-name") | ||
public KerberosConfig setServiceName(String serviceName) | ||
{ | ||
this.serviceName = serviceName; | ||
return this; | ||
} | ||
|
||
public File getKeytab() | ||
{ | ||
return keytab; | ||
} | ||
|
||
@Config("http.server.authentication.krb5.keytab") | ||
public KerberosConfig setKeytab(File keytab) | ||
{ | ||
this.keytab = keytab; | ||
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
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
50 changes: 50 additions & 0 deletions
50
presto-main/src/test/java/com/facebook/presto/server/security/TestKerberosConfig.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,50 @@ | ||
/* | ||
* 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 com.facebook.presto.server.security; | ||
|
||
import com.google.common.collect.ImmutableMap; | ||
import io.airlift.configuration.testing.ConfigAssertions; | ||
import org.testng.annotations.Test; | ||
|
||
import java.io.File; | ||
import java.util.Map; | ||
|
||
public class TestKerberosConfig | ||
{ | ||
@Test | ||
public void testDefaults() | ||
{ | ||
ConfigAssertions.assertRecordedDefaults(ConfigAssertions.recordDefaults(KerberosConfig.class) | ||
.setKerberosConfig(null) | ||
.setServiceName(null) | ||
.setKeytab(null)); | ||
} | ||
|
||
@Test | ||
public void testExplicitPropertyMappings() | ||
{ | ||
Map<String, String> properties = new ImmutableMap.Builder<String, String>() | ||
.put("http.authentication.krb5.config", "/etc/krb5.conf") | ||
.put("http.server.authentication.krb5.service-name", "airlift") | ||
.put("http.server.authentication.krb5.keytab", "/tmp/presto.keytab") | ||
.build(); | ||
|
||
KerberosConfig expected = new KerberosConfig() | ||
.setKerberosConfig(new File("/etc/krb5.conf")) | ||
.setServiceName("airlift") | ||
.setKeytab(new File("/tmp/presto.keytab")); | ||
|
||
ConfigAssertions.assertFullMapping(properties, expected); | ||
} | ||
} |
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