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.protobuf.generated.AdminProtos;
24 import org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.TokenIdentifier.Kind;
25 import org.apache.hadoop.hbase.protobuf.generated.ClientProtos;
26 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.MasterService;
27 import org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos;
28
29
30
31
32 public class SecurityInfo {
33
34 private static ConcurrentMap<String,SecurityInfo> infos = new ConcurrentHashMap<String,SecurityInfo>();
35
36 static {
37 infos.put(AdminProtos.AdminService.getDescriptor().getName(),
38 new SecurityInfo("hbase.regionserver.kerberos.principal", Kind.HBASE_AUTH_TOKEN));
39 infos.put(ClientProtos.ClientService.getDescriptor().getName(),
40 new SecurityInfo("hbase.regionserver.kerberos.principal", Kind.HBASE_AUTH_TOKEN));
41 infos.put(MasterService.getDescriptor().getName(),
42 new SecurityInfo("hbase.master.kerberos.principal", Kind.HBASE_AUTH_TOKEN));
43 infos.put(RegionServerStatusProtos.RegionServerStatusService.getDescriptor().getName(),
44 new SecurityInfo("hbase.master.kerberos.principal", Kind.HBASE_AUTH_TOKEN));
45 }
46
47
48
49
50
51 public static void addInfo(String serviceName, SecurityInfo securityInfo) {
52 infos.putIfAbsent(serviceName, securityInfo);
53 }
54
55
56
57
58 public static SecurityInfo getInfo(String serviceName) {
59 return infos.get(serviceName);
60 }
61
62 private final String serverPrincipal;
63 private final Kind tokenKind;
64
65 public SecurityInfo(String serverPrincipal, Kind tokenKind) {
66 this.serverPrincipal = serverPrincipal;
67 this.tokenKind = tokenKind;
68 }
69
70 public String getServerPrincipal() {
71 return serverPrincipal;
72 }
73
74 public Kind getTokenKind() {
75 return tokenKind;
76 }
77 }