HBASE-22250 The same constants used in many places should be placed in constant classes
Signed-off-by: stack <stack@apache.org>
This commit is contained in:
parent
d77e90c006
commit
7617b71f00
|
@ -38,17 +38,17 @@ public class SecurityInfo {
|
|||
// populate info for known services
|
||||
static {
|
||||
infos.put(AdminProtos.AdminService.getDescriptor().getName(),
|
||||
new SecurityInfo("hbase.regionserver.kerberos.principal",
|
||||
new SecurityInfo(SecurityConstants.REGIONSERVER_KRB_PRINCIPAL,
|
||||
Kind.HBASE_AUTH_TOKEN));
|
||||
infos.put(ClientProtos.ClientService.getDescriptor().getName(),
|
||||
new SecurityInfo("hbase.regionserver.kerberos.principal",
|
||||
new SecurityInfo(SecurityConstants.REGIONSERVER_KRB_PRINCIPAL,
|
||||
Kind.HBASE_AUTH_TOKEN));
|
||||
infos.put(MasterService.getDescriptor().getName(),
|
||||
new SecurityInfo("hbase.master.kerberos.principal", Kind.HBASE_AUTH_TOKEN));
|
||||
new SecurityInfo(SecurityConstants.MASTER_KRB_PRINCIPAL, Kind.HBASE_AUTH_TOKEN));
|
||||
infos.put(RegionServerStatusProtos.RegionServerStatusService.getDescriptor().getName(),
|
||||
new SecurityInfo("hbase.master.kerberos.principal", Kind.HBASE_AUTH_TOKEN));
|
||||
new SecurityInfo(SecurityConstants.MASTER_KRB_PRINCIPAL, Kind.HBASE_AUTH_TOKEN));
|
||||
infos.put(MasterProtos.HbckService.getDescriptor().getName(),
|
||||
new SecurityInfo("hbase.master.kerberos.principal", Kind.HBASE_AUTH_TOKEN));
|
||||
new SecurityInfo(SecurityConstants.MASTER_KRB_PRINCIPAL, Kind.HBASE_AUTH_TOKEN));
|
||||
// NOTE: IF ADDING A NEW SERVICE, BE SURE TO UPDATE HBasePolicyProvider ALSO ELSE
|
||||
// new Service will not be found when all is Kerberized!!!!
|
||||
}
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 org.apache.hadoop.hbase.security;
|
||||
|
||||
import org.apache.yetus.audience.InterfaceAudience;
|
||||
|
||||
/**
|
||||
* SecurityConstants holds a bunch of kerberos-related constants
|
||||
*/
|
||||
@InterfaceAudience.Private
|
||||
public final class SecurityConstants {
|
||||
|
||||
/**
|
||||
* Configuration keys for programmatic JAAS configuration for secured master
|
||||
* and regionserver interaction
|
||||
*/
|
||||
public static final String MASTER_KRB_PRINCIPAL = "hbase.master.kerberos.principal";
|
||||
public static final String MASTER_KRB_KEYTAB_FILE = "hbase.master.keytab.file";
|
||||
public static final String REGIONSERVER_KRB_PRINCIPAL = "hbase.regionserver.kerberos.principal";
|
||||
public static final String REGIONSERVER_KRB_KEYTAB_FILE = "hbase.regionserver.keytab.file";
|
||||
|
||||
private SecurityConstants() {
|
||||
// Can't be instantiated with this ctor.
|
||||
}
|
||||
}
|
|
@ -31,6 +31,7 @@ import org.apache.hadoop.fs.Path;
|
|||
import org.apache.hadoop.fs.permission.FsPermission;
|
||||
import org.apache.hadoop.hbase.HBaseConfiguration;
|
||||
import org.apache.hadoop.hbase.IntegrationTestingUtility;
|
||||
import org.apache.hadoop.hbase.security.SecurityConstants;
|
||||
import org.apache.hadoop.hbase.testclassification.IntegrationTests;
|
||||
import org.apache.hadoop.hbase.util.AbstractHBaseTool;
|
||||
import org.apache.hadoop.hbase.util.FSUtils;
|
||||
|
@ -104,7 +105,7 @@ public class IntegrationTestZKAndFSPermissions extends AbstractHBaseTool {
|
|||
@Override
|
||||
protected void processOptions(CommandLine cmd) {
|
||||
isForce = cmd.hasOption(FORCE_CHECK_ARG);
|
||||
masterPrincipal = getShortUserName(conf.get("hbase.master.kerberos.principal"));
|
||||
masterPrincipal = getShortUserName(conf.get(SecurityConstants.MASTER_KRB_PRINCIPAL));
|
||||
superUser = cmd.getOptionValue(SUPERUSER_ARG, conf.get("hbase.superuser"));
|
||||
masterPrincipal = cmd.getOptionValue(PRINCIPAL_ARG, masterPrincipal);
|
||||
fsPerms = cmd.getOptionValue(FS_PERMS, "700");
|
||||
|
|
|
@ -193,6 +193,7 @@ import org.apache.hadoop.hbase.replication.master.ReplicationHFileCleaner;
|
|||
import org.apache.hadoop.hbase.replication.master.ReplicationLogCleaner;
|
||||
import org.apache.hadoop.hbase.replication.master.ReplicationPeerConfigUpgrader;
|
||||
import org.apache.hadoop.hbase.security.AccessDeniedException;
|
||||
import org.apache.hadoop.hbase.security.SecurityConstants;
|
||||
import org.apache.hadoop.hbase.security.UserProvider;
|
||||
import org.apache.hadoop.hbase.trace.TraceUtil;
|
||||
import org.apache.hadoop.hbase.util.Addressing;
|
||||
|
@ -693,8 +694,8 @@ public class HMaster extends HRegionServer implements MasterServices {
|
|||
try {
|
||||
super.login(user, host);
|
||||
} catch (IOException ie) {
|
||||
user.login("hbase.master.keytab.file",
|
||||
"hbase.master.kerberos.principal", host);
|
||||
user.login(SecurityConstants.MASTER_KRB_KEYTAB_FILE,
|
||||
SecurityConstants.MASTER_KRB_PRINCIPAL, host);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -142,6 +142,7 @@ import org.apache.hadoop.hbase.regionserver.throttle.ThroughputController;
|
|||
import org.apache.hadoop.hbase.replication.regionserver.ReplicationLoad;
|
||||
import org.apache.hadoop.hbase.replication.regionserver.ReplicationSourceInterface;
|
||||
import org.apache.hadoop.hbase.replication.regionserver.ReplicationStatus;
|
||||
import org.apache.hadoop.hbase.security.SecurityConstants;
|
||||
import org.apache.hadoop.hbase.security.Superusers;
|
||||
import org.apache.hadoop.hbase.security.User;
|
||||
import org.apache.hadoop.hbase.security.UserProvider;
|
||||
|
@ -533,6 +534,9 @@ public class HRegionServer extends HasThread implements
|
|||
private final boolean masterless;
|
||||
static final String MASTERLESS_CONFIG_NAME = "hbase.masterless";
|
||||
|
||||
/**regionserver codec list **/
|
||||
public static final String REGIONSERVER_CODEC = "hbase.regionserver.codecs";
|
||||
|
||||
/**
|
||||
* Starts a HRegionServer at the default location
|
||||
*/
|
||||
|
@ -729,8 +733,8 @@ public class HRegionServer extends HasThread implements
|
|||
}
|
||||
|
||||
protected void login(UserProvider user, String host) throws IOException {
|
||||
user.login("hbase.regionserver.keytab.file",
|
||||
"hbase.regionserver.kerberos.principal", host);
|
||||
user.login(SecurityConstants.REGIONSERVER_KRB_KEYTAB_FILE,
|
||||
SecurityConstants.REGIONSERVER_KRB_PRINCIPAL, host);
|
||||
}
|
||||
|
||||
|
||||
|
@ -819,7 +823,7 @@ public class HRegionServer extends HasThread implements
|
|||
*/
|
||||
private static void checkCodecs(final Configuration c) throws IOException {
|
||||
// check to see if the codec list is available:
|
||||
String [] codecs = c.getStrings("hbase.regionserver.codecs", (String[])null);
|
||||
String [] codecs = c.getStrings(REGIONSERVER_CODEC, (String[])null);
|
||||
if (codecs == null) return;
|
||||
for (String codec : codecs) {
|
||||
if (!CompressionTest.testCompression(codec)) {
|
||||
|
|
|
@ -40,9 +40,9 @@ import org.apache.hadoop.security.UserGroupInformation;
|
|||
public class HBaseKerberosUtils {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(HBaseKerberosUtils.class);
|
||||
|
||||
public static final String KRB_PRINCIPAL = "hbase.regionserver.kerberos.principal";
|
||||
public static final String MASTER_KRB_PRINCIPAL = "hbase.master.kerberos.principal";
|
||||
public static final String KRB_KEYTAB_FILE = "hbase.regionserver.keytab.file";
|
||||
public static final String KRB_PRINCIPAL = SecurityConstants.REGIONSERVER_KRB_PRINCIPAL;
|
||||
public static final String MASTER_KRB_PRINCIPAL = SecurityConstants.MASTER_KRB_PRINCIPAL;
|
||||
public static final String KRB_KEYTAB_FILE = SecurityConstants.REGIONSERVER_KRB_KEYTAB_FILE;
|
||||
public static final String CLIENT_PRINCIPAL = AuthUtil.HBASE_CLIENT_KERBEROS_PRINCIPAL;
|
||||
public static final String CLIENT_KEYTAB = AuthUtil.HBASE_CLIENT_KEYTAB_FILE;
|
||||
|
||||
|
|
Loading…
Reference in New Issue