HBASE-7913 Secure Rest server should login before getting an instance of Rest servlet (Arpit)

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1449264 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Zhihong Yu 2013-02-23 02:26:49 +00:00
parent 67da069ee6
commit cb5590dce6
1 changed files with 9 additions and 10 deletions

View File

@ -77,8 +77,16 @@ public class RESTServer implements Constants {
public static void main(String[] args) throws Exception {
Log LOG = LogFactory.getLog("RESTServer");
VersionInfo.logVersion();
VersionInfo.logVersion();
Configuration conf = HBaseConfiguration.create();
// login the server principal (if using secure Hadoop)
if (User.isSecurityEnabled() && User.isHBaseSecurityEnabled(conf)) {
String machineName = Strings.domainNamePointerToHostName(
DNS.getDefaultHost(conf.get("hbase.rest.dns.interface", "default"),
conf.get("hbase.rest.dns.nameserver", "default")));
User.login(conf, "hbase.rest.keytab.file", "hbase.rest.kerberos.principal",
machineName);
}
RESTServlet servlet = RESTServlet.getInstance(conf);
Options options = new Options();
@ -170,15 +178,6 @@ public class RESTServer implements Constants {
context.addServlet(sh, "/*");
context.addFilter(GzipFilter.class, "/*", 0);
// login the server principal (if using secure Hadoop)
if (User.isSecurityEnabled() && User.isHBaseSecurityEnabled(conf)) {
String machineName = Strings.domainNamePointerToHostName(
DNS.getDefaultHost(conf.get("hbase.rest.dns.interface", "default"),
conf.get("hbase.rest.dns.nameserver", "default")));
User.login(conf, "hbase.rest.keytab.file", "hbase.rest.kerberos.principal",
machineName);
}
// Put up info server.
int port = conf.getInt("hbase.rest.info.port", 8085);
if (port >= 0) {