synchronized void rollCurrentKey() {
    if (!leaderElector.isMaster()) {
      LOG.info("Skipping rollCurrentKey() because not running as master.");
      return;
    }

    long now = EnvironmentEdgeManager.currentTime();
    AuthenticationKey prev = currentKey;
    AuthenticationKey newKey = new AuthenticationKey(++idSeq, Long.MAX_VALUE, // don't allow to
                                                                              // expire until it's
                                                                              // replaced by a new
                                                                              // key
      generateSecret());
    allKeys.put(newKey.getKeyId(), newKey);
    currentKey = newKey;
    zkWatcher.addKeyToZK(newKey);
    lastKeyUpdate = now;

    if (prev != null) {
      // make sure previous key is still stored
      prev.setExpiration(now + tokenMaxLifetime);
      allKeys.put(prev.getKeyId(), prev);
      zkWatcher.updateKeyInZK(prev);
    }
  }
Create a new secret manager instance for generating keys.
@param conf              Configuration to use
@param zk                Connection to zookeeper for handling leader elections
@param keyUpdateInterval Time (in milliseconds) between rolling a new master key for token
                         signing
@param tokenMaxLifetime  Maximum age (in milliseconds) before a token expires and is no longer
                         valid
hbase-server/src/main/java/org/apache/hadoop/hbase/security/token/AuthenticationTokenSecretManager.java