public synchronized void addKey(AuthenticationKey key) throws IOException {
    // ignore zk changes when running as master
    if (leaderElector.isMaster()) {
      LOG.debug("Running as master, ignoring new key {}", key);
      return;
    }

    LOG.debug("Adding key {}", key.getKeyId());

    allKeys.put(key.getKeyId(), key);
    if (currentKey == null || key.getKeyId() > currentKey.getKeyId()) {
      currentKey = key;
    }
    // update current sequence
    if (key.getKeyId() > idSeq) {
      idSeq = key.getKeyId();
    }
  }
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