public Token<?> getToken(String kind, String service) throws IOException {
    for (Token<?> token : ugi.getTokens()) {
      if (
        token.getKind().toString().equals(kind)
          && (service != null && token.getService().toString().equals(service))
      ) {
        return token;
      }
    }
    return null;
  }
Returns the Token of the specified kind associated with this user, or null if the Token is not
present.
@param kind    the kind of token
@param service service on which the token is supposed to be used
@return the token of the specified kind.
hbase-common/src/main/java/org/apache/hadoop/hbase/security/User.java