1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.hadoop.hbase.security.visibility;
19
20 import java.util.List;
21
22 import org.apache.commons.logging.Log;
23 import org.apache.commons.logging.LogFactory;
24 import org.apache.hadoop.hbase.classification.InterfaceAudience;
25 import org.apache.hadoop.conf.Configuration;
26 import org.apache.hadoop.hbase.security.User;
27
28
29
30
31
32
33
34
35
36
37
38 @InterfaceAudience.Private
39 public class FeedUserAuthScanLabelGenerator implements ScanLabelGenerator {
40
41 private static final Log LOG = LogFactory.getLog(FeedUserAuthScanLabelGenerator.class);
42
43 private Configuration conf;
44 private VisibilityLabelsCache labelsCache;
45
46 public FeedUserAuthScanLabelGenerator() {
47 this.labelsCache = VisibilityLabelsCache.get();
48 }
49
50 @Override
51 public void setConf(Configuration conf) {
52 this.conf = conf;
53 }
54
55 @Override
56 public Configuration getConf() {
57 return this.conf;
58 }
59
60 @Override
61 public List<String> getLabels(User user, Authorizations authorizations) {
62 if (authorizations == null || authorizations.getLabels() == null
63 || authorizations.getLabels().isEmpty()) {
64 String userName = user.getShortName();
65 return this.labelsCache.getAuths(userName);
66 }
67 return authorizations.getLabels();
68 }
69
70 }