### Question:
AuthenticationTokenSecretManager extends SecretManager<AuthenticationTokenIdentifier> { public Entry<Token<AuthenticationTokenIdentifier>,AuthenticationTokenIdentifier> generateToken(String username, DelegationTokenConfig cfg) throws AccumuloException { requireNonNull(username); requireNonNull(cfg); final AuthenticationTokenIdentifier id = new AuthenticationTokenIdentifier(username, cfg); final StringBuilder svcName = new StringBuilder(DelegationTokenImpl.SERVICE_NAME); if (id.getInstanceId() != null) { svcName.append("-").append(id.getInstanceId()); } byte[] password; try { password = createPassword(id); } catch (RuntimeException e) { throw new AccumuloException(e.getMessage()); } Token<AuthenticationTokenIdentifier> token = new Token<>(id.getBytes(), password, id.getKind(), new Text(svcName.toString())); return Maps.immutableEntry(token, id); } AuthenticationTokenSecretManager(String instanceID, long tokenMaxLifetime); @Override byte[] retrievePassword(AuthenticationTokenIdentifier identifier); @Override AuthenticationTokenIdentifier createIdentifier(); Entry<Token<AuthenticationTokenIdentifier>,AuthenticationTokenIdentifier> generateToken(String username, DelegationTokenConfig cfg); synchronized void addKey(AuthenticationKey key); synchronized void removeAllKeys(); static SecretKey createSecretKey(byte[] raw);  }### Answer:
@Test public void testGenerateToken() throws Exception { long then = System.currentTimeMillis(); long tokenLifetime = 60 * 1000; AuthenticationTokenSecretManager secretManager = new AuthenticationTokenSecretManager(instanceId, tokenLifetime); secretManager .addKey(new AuthenticationKey(1, then, then + tokenLifetime, keyGen.generateKey())); String principal = "user@EXAMPLE.COM"; Entry<Token<AuthenticationTokenIdentifier>,AuthenticationTokenIdentifier> pair = secretManager.generateToken(principal, cfg); assertNotNull(pair); Token<AuthenticationTokenIdentifier> token = pair.getKey(); assertNotNull(token); assertEquals(AuthenticationTokenIdentifier.TOKEN_KIND, token.getKind()); AuthenticationTokenIdentifier id = new AuthenticationTokenIdentifier(); id.readFields(new DataInputStream(new ByteArrayInputStream(token.getIdentifier()))); long now = System.currentTimeMillis(); assertTrue("Issue date did not fall within the expected upper bound. Expected less than " + now + ", but was " + id.getIssueDate(), id.getIssueDate() <= now); assertTrue("Issue date did not fall within the expected lower bound. Expected greater than " + then + ", but was " + id.getIssueDate(), id.getIssueDate() >= then); assertEquals(id.getIssueDate() + tokenLifetime, id.getExpirationDate()); assertEquals(instanceId, id.getInstanceId()); assertEquals(pair.getValue(), id); }