@Test public void loadingMalformedKeyfileThrowsError() throws Exception { final Path key = Files.createTempFile("key", ".key"); Files.write(key, "BAD JSON DATA".getBytes()); command.privateKeyPath = key; addEmptyEncryptorConfigToCommand(); addDefaultArgonConfigToCommand(); final Throwable throwable = catchThrowable(() -> command.call()); assertThat(throwable).isInstanceOf(ConfigException.class).hasCauseExactlyInstanceOf(UnmarshalException.class); verify(keyEncryptorFactory).create(any()); }
@Override public CliResult call() throws Exception { final EncryptorConfig encryptorConfig; if (Optional.ofNullable(config).map(Config::getEncryptor).isPresent()) { encryptorConfig = config.getEncryptor(); } else { encryptorConfig = encryptorOptions.parseEncryptorConfig(); } this.keyEncryptor = keyEncryptorFactory.create(encryptorConfig); return execute(); }
KeyUpdateCommand implements Callable<CliResult> { @Override public CliResult call() throws Exception { final EncryptorConfig encryptorConfig; if (Optional.ofNullable(config).map(Config::getEncryptor).isPresent()) { encryptorConfig = config.getEncryptor(); } else { encryptorConfig = encryptorOptions.parseEncryptorConfig(); } this.keyEncryptor = keyEncryptorFactory.create(encryptorConfig); return execute(); } }
KeyUpdateCommand implements Callable<CliResult> { @Override public CliResult call() throws Exception { final EncryptorConfig encryptorConfig; if (Optional.ofNullable(config).map(Config::getEncryptor).isPresent()) { encryptorConfig = config.getEncryptor(); } else { encryptorConfig = encryptorOptions.parseEncryptorConfig(); } this.keyEncryptor = keyEncryptorFactory.create(encryptorConfig); return execute(); } KeyUpdateCommand(KeyEncryptorFactory keyEncryptorFactory, PasswordReader passwordReader); }
KeyUpdateCommand implements Callable<CliResult> { @Override public CliResult call() throws Exception { final EncryptorConfig encryptorConfig; if (Optional.ofNullable(config).map(Config::getEncryptor).isPresent()) { encryptorConfig = config.getEncryptor(); } else { encryptorConfig = encryptorOptions.parseEncryptorConfig(); } this.keyEncryptor = keyEncryptorFactory.create(encryptorConfig); return execute(); } KeyUpdateCommand(KeyEncryptorFactory keyEncryptorFactory, PasswordReader passwordReader); @Override CliResult call(); CliResult execute(); }
KeyUpdateCommand implements Callable<CliResult> { @Override public CliResult call() throws Exception { final EncryptorConfig encryptorConfig; if (Optional.ofNullable(config).map(Config::getEncryptor).isPresent()) { encryptorConfig = config.getEncryptor(); } else { encryptorConfig = encryptorOptions.parseEncryptorConfig(); } this.keyEncryptor = keyEncryptorFactory.create(encryptorConfig); return execute(); } KeyUpdateCommand(KeyEncryptorFactory keyEncryptorFactory, PasswordReader passwordReader); @Override CliResult call(); CliResult execute(); @CommandLine.Option(names = "--keys.keyData.privateKeyPath", required = true)
    public Path privateKeyPath; @CommandLine.Option(names = "--keys.keyData.config.data.aopts.algorithm", defaultValue = "i")
    public String algorithm; @CommandLine.Option(names = "--keys.keyData.config.data.aopts.iterations", defaultValue = "10")
    public Integer iterations; @CommandLine.Option(names = "--keys.keyData.config.data.aopts.memory", defaultValue = "1048576")
    public Integer memory; @CommandLine.Option(names = "--keys.keyData.config.data.aopts.parallelism", defaultValue = "4")
    public Integer parallelism; @CommandLine.Option(names = {"--keys.passwords"})
    public String password; @CommandLine.Option(names = {"--keys.passwordFile"})
    public Path passwordFile; @CommandLine.Option(
            names = {"--configfile", "-configfile"},
            description = "Path to node configuration file")
    public Config config; @CommandLine.Mixin public EncryptorOptions encryptorOptions; @CommandLine.Mixin public DebugOptions debugOptions; }