1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.hadoop.hbase.security;
19
20 import java.util.concurrent.ConcurrentHashMap;
21 import java.util.concurrent.ConcurrentMap;
22
23 import org.apache.hadoop.hbase.classification.InterfaceAudience;
24 import org.apache.hadoop.hbase.protobuf.generated.AdminProtos;
25 import org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.TokenIdentifier.Kind;
26 import org.apache.hadoop.hbase.protobuf.generated.ClientProtos;
27 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.MasterService;
28 import org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos;
29
30
31
32
33 @InterfaceAudience.Private
34 public class SecurityInfo {
35
36 private static ConcurrentMap<String,SecurityInfo> infos = new ConcurrentHashMap<String,SecurityInfo>();
37
38 static {
39 infos.put(AdminProtos.AdminService.getDescriptor().getName(),
40 new SecurityInfo("hbase.regionserver.kerberos.principal", Kind.HBASE_AUTH_TOKEN));
41 infos.put(ClientProtos.ClientService.getDescriptor().getName(),
42 new SecurityInfo("hbase.regionserver.kerberos.principal", Kind.HBASE_AUTH_TOKEN));
43 infos.put(MasterService.getDescriptor().getName(),
44 new SecurityInfo("hbase.master.kerberos.principal", Kind.HBASE_AUTH_TOKEN));
45 infos.put(RegionServerStatusProtos.RegionServerStatusService.getDescriptor().getName(),
46 new SecurityInfo("hbase.master.kerberos.principal", Kind.HBASE_AUTH_TOKEN));
47 }
48
49
50
51
52
53 public static void addInfo(String serviceName, SecurityInfo securityInfo) {
54 infos.putIfAbsent(serviceName, securityInfo);
55 }
56
57
58
59
60 public static SecurityInfo getInfo(String serviceName) {
61 return infos.get(serviceName);
62 }
63
64 private final String serverPrincipal;
65 private final Kind tokenKind;
66
67 public SecurityInfo(String serverPrincipal, Kind tokenKind) {
68 this.serverPrincipal = serverPrincipal;
69 this.tokenKind = tokenKind;
70 }
71
72 public String getServerPrincipal() {
73 return serverPrincipal;
74 }
75
76 public Kind getTokenKind() {
77 return tokenKind;
78 }
79 }