@SuppressWarnings("unchecked")
  public T decodeIdentifier() throws IOException {
    Class<? extends TokenIdentifier> cls = getClassForIdentifier(getKind());
    if (cls == null) {
      return null;
    }
    TokenIdentifier tokenIdentifier = ReflectionUtils.newInstance(cls, null);
    ByteArrayInputStream buf = new ByteArrayInputStream(identifier);
    DataInputStream in = new DataInputStream(buf);
    tokenIdentifier.readFields(in);
    in.close();
    return (T) tokenIdentifier;
  }
@Test
  public void testDecodeIdentifier() throws IOException {
    TestDelegationTokenSecretManager secretManager =
      new TestDelegationTokenSecretManager(0, 0, 0, 0);
    secretManager.startThreads();
    TestDelegationTokenIdentifier id = new TestDelegationTokenIdentifier(
        new Text("owner"), new Text("renewer"), new Text("realUser"));
    
    Token<TestDelegationTokenIdentifier> token =
        new Token<>(id, secretManager);
    TokenIdentifier idCopy = token.decodeIdentifier();
    
    assertNotSame(id, idCopy);
    assertEquals(id, idCopy);
  }