@Override
  public void setConf(final Configuration conf) {
    super.setConf(conf);

    synchronized (UserProvider.class) {
      if (!(groups instanceof User.TestingGroups)) {
        groups = Groups.getUserToGroupsMappingService(conf);
      }
    }

    long cacheTimeout = getConf().getLong(CommonConfigurationKeys.HADOOP_SECURITY_GROUPS_CACHE_SECS,
      CommonConfigurationKeys.HADOOP_SECURITY_GROUPS_CACHE_SECS_DEFAULT) * 1000;

    this.groupCache = CacheBuilder.newBuilder()
      // This is the same timeout that hadoop uses. So we'll follow suit.
      .refreshAfterWrite(cacheTimeout, TimeUnit.MILLISECONDS)
      .expireAfterWrite(10 * cacheTimeout, TimeUnit.MILLISECONDS)
      // Set concurrency level equal to the default number of handlers that
      // the simple handler spins up.
      .concurrencyLevel(20)
      // create the loader
      // This just delegates to UGI.
      .build(new CacheLoader<String, String[]>() {

        // Since UGI's don't hash based on the user id
        // The cache needs to be keyed on the same thing that Hadoop's Groups class
        // uses. So this cache uses shortname.
        @Override
        public String[] load(String ugi) throws Exception {
          return getGroupStrings(ugi);
        }

        private String[] getGroupStrings(String ugi) {
          try {
            Set<String> result = new LinkedHashSet<>(groups.getGroups(ugi));
            return result.toArray(new String[result.size()]);
          } catch (Exception e) {
            return new String[0];
          }
        }

        // Provide the reload function that uses the executor thread.
        @Override
        public ListenableFuture<String[]> reload(final String k, String[] oldValue)
          throws Exception {

          return executor.submit(new Callable<String[]>() {
            @Override
            public String[] call() throws Exception {
              return getGroupStrings(k);
            }
          });
        }
      });
  }
Provide an instance of a user. Allows custom {@link User} creation.
hbase-common/src/main/java/org/apache/hadoop/hbase/security/UserProvider.java