@Test public void ifPublicKeyListIsEmptyThenKeyConfigurationIsAllNulls() throws IOException { try (InputStream configData = getClass().getResourceAsStream("/sample-with-only-private-keys.conf")) { final Throwable throwable = catchThrowable(() -> tomlConfigFactory.createKeyDataBuilder(configData).build()); assertThat(throwable).isInstanceOf(ConfigException.class).hasCauseExactlyInstanceOf(RuntimeException.class); assertThat(throwable.getCause()).hasMessage("Different amount of public and private keys supplied"); } }
KeyDataBuilder createKeyDataBuilder(InputStream configData) { final Toml toml = new Toml().read(configData); final List<String> publicKeyList = toml.getList("publickeys", emptyList()); final List<String> privateKeyList = toml.getList("privatekeys", emptyList()); final String pwd = toml.getString("passwords"); final String workdir = toml.getString("workdir"); return KeyDataBuilder.create() .withPublicKeys(publicKeyList) .withPrivateKeys(privateKeyList) .withPrivateKeyPasswordFile(pwd) .withWorkingDirectory(workdir); }
TomlConfigFactory { KeyDataBuilder createKeyDataBuilder(InputStream configData) { final Toml toml = new Toml().read(configData); final List<String> publicKeyList = toml.getList("publickeys", emptyList()); final List<String> privateKeyList = toml.getList("privatekeys", emptyList()); final String pwd = toml.getString("passwords"); final String workdir = toml.getString("workdir"); return KeyDataBuilder.create() .withPublicKeys(publicKeyList) .withPrivateKeys(privateKeyList) .withPrivateKeyPasswordFile(pwd) .withWorkingDirectory(workdir); } }
TomlConfigFactory { KeyDataBuilder createKeyDataBuilder(InputStream configData) { final Toml toml = new Toml().read(configData); final List<String> publicKeyList = toml.getList("publickeys", emptyList()); final List<String> privateKeyList = toml.getList("privatekeys", emptyList()); final String pwd = toml.getString("passwords"); final String workdir = toml.getString("workdir"); return KeyDataBuilder.create() .withPublicKeys(publicKeyList) .withPrivateKeys(privateKeyList) .withPrivateKeyPasswordFile(pwd) .withWorkingDirectory(workdir); }  }
TomlConfigFactory { KeyDataBuilder createKeyDataBuilder(InputStream configData) { final Toml toml = new Toml().read(configData); final List<String> publicKeyList = toml.getList("publickeys", emptyList()); final List<String> privateKeyList = toml.getList("privatekeys", emptyList()); final String pwd = toml.getString("passwords"); final String workdir = toml.getString("workdir"); return KeyDataBuilder.create() .withPublicKeys(publicKeyList) .withPrivateKeys(privateKeyList) .withPrivateKeyPasswordFile(pwd) .withWorkingDirectory(workdir); }  ConfigBuilder create(InputStream configData, ArgonOptions options, String... filenames); }
TomlConfigFactory { KeyDataBuilder createKeyDataBuilder(InputStream configData) { final Toml toml = new Toml().read(configData); final List<String> publicKeyList = toml.getList("publickeys", emptyList()); final List<String> privateKeyList = toml.getList("privatekeys", emptyList()); final String pwd = toml.getString("passwords"); final String workdir = toml.getString("workdir"); return KeyDataBuilder.create() .withPublicKeys(publicKeyList) .withPrivateKeys(privateKeyList) .withPrivateKeyPasswordFile(pwd) .withWorkingDirectory(workdir); }  ConfigBuilder create(InputStream configData, ArgonOptions options, String... filenames);  }