class KeyUpdateCommand implements Callable<CliResult> {

    PrivateKey getExistingKey(final KeyDataConfig kdc, final List<char[]> passwords) {

        if (kdc.getType() == PrivateKeyType.UNLOCKED) {
            byte[] privateKeyData = Base64.getDecoder().decode(kdc.getValue().getBytes(UTF_8));
            return PrivateKey.from(privateKeyData);
        } else {

            for (final char[] pass : passwords) {
                try {
                    return PrivateKey.from(keyEncryptor.decryptPrivateKey(kdc.getPrivateKeyData(), pass).getKeyBytes());
                } catch (final Exception e) {
                    LOGGER.debug("Password failed to decrypt. Trying next if available.");
                }
            }

            throw new IllegalArgumentException("Locked key but no valid password given");
        }
    }

      KeyUpdateCommand(KeyEncryptorFactory keyEncryptorFactory, PasswordReader passwordReader);

}