public static String validate(
      final CommandLine commandLine, final String filename, final String type) {

    final File authfile = new File(filename);
    if (!authfile.exists()) {
      throw new ParameterException(
          commandLine,
          "The specified RPC "
              + type
              + " authentication credential file '"
              + filename
              + "' does not exist");
    }

    final TomlParseResult tomlParseResult;
    try {
      tomlParseResult = TomlConfigFileParser.loadConfigurationFromFile(filename);
    } catch (IOException e) {
      throw new ParameterException(
          commandLine,
          "An error occurred while opening the specified RPC "
              + type
              + " authentication configuration file.");
    } catch (Exception e) {
      throw new ParameterException(
          commandLine,
          "Invalid RPC " + type + " authentication credentials file: " + e.getMessage());
    }

    if (tomlParseResult.hasErrors()) {
      throw new ParameterException(
          commandLine,
          "An error occurred while parsing the specified RPC authentication configuration file.");
    }

    if (!verifyAllUsersHavePassword(tomlParseResult)) {
      throw new ParameterException(commandLine, "RPC user specified without password.");
    }

    if (!verifyAllEntriesHaveValues(tomlParseResult)) {
      throw new ParameterException(
          commandLine, "RPC authentication configuration file contains invalid values.");
    }

    return filename;
  }
Validate auth file.

@param commandLine the command line to use for parameter exceptions
@param filename the auth file
@param type the RPC type
@return the auth filename
app/src/main/java/org/hyperledger/besu/cli/custom/RpcAuthFileValidator.java