@InterfaceAudience.Private
  static AuthenticationProtos.Token toToken(Token<AuthenticationTokenIdentifier> token) {
    AuthenticationProtos.Token.Builder builder = AuthenticationProtos.Token.newBuilder();
    builder.setIdentifier(ByteString.copyFrom(token.getIdentifier()));
    builder.setPassword(ByteString.copyFrom(token.getPassword()));
    if (token.getService() != null) {
      builder.setService(ByteString.copyFromUtf8(token.getService().toString()));
    }
    return builder.build();
  }
Converts a Token instance (with embedded identifier) to the protobuf representation.
@param token the Token instance to copy
@return the protobuf Token message
hbase-client/src/main/java/org/apache/hadoop/hbase/security/token/ClientTokenUtil.java