class SecretKeyInputFactory implements ImportInputFactory {

    public ImportInput createInput(Parameters parameters) {
        EncryptionParams cryptoParameters = new EncryptionParams(parameters);
        Optional<String> keyAlias = cryptoParameters.getKeyAlias();
        Optional<String> keyStore = cryptoParameters.getKeyStore();
        final Supplier<String> passwdSupplier = () -> {
            String passwd = requestConfirmedPassword(console,
                    "Please enter key password: ",
                    "Please confirm key password: ");
            parameters.setParameterValue(KEY_PASSWD_PARAMETER, passwd);
            return passwd;
        };


        String[] key = parameters.getParameterValues(inputKeyParameter);
        if (key == null && !keyStore.isPresent() && !cryptoParameters.hasGenKey()) {
            // Adding non localized message cause import-export tool does not support localization.
            throw new JSException("No import secret key was specified.");
        }

        if (keyStore.isPresent()) {
            String keyStorePasswd;
            if (cryptoParameters.getKeyStorePasswd().isPresent() ) {
                keyStorePasswd = cryptoParameters.getKeyStorePasswd().get();
                if (keyStorePasswd.isEmpty()) {
                    keyStorePasswd = requestConfirmedPassword(console,
                            "Please enter keystore password: ",
                            "Please confirm keystore password: ");

                    parameters.setParameterValue(KEY_STORE_PASSWD_PARAMETER, keyStorePasswd);
                }
            } else {
                if (defaultKeystorePasswdProvider != null) {
                    keyStorePasswd = defaultKeystorePasswdProvider.getDefaultPassword();
                    parameters.setParameterValue(KEY_STORE_PASSWD_PARAMETER, keyStorePasswd);
                } else {
                    throw new JSException("--storepass must be specified.");
                }
            }

            if (keyAlias.isPresent()) {
                String keyPasswd = cryptoParameters.getKeyPasswd().orElseGet(passwdSupplier);
                if (keyPasswd.isEmpty()) {
                    passwdSupplier.get();
                }
            }

        } else {
            if ((!keyAlias.isPresent() || keyAlias.get().isEmpty())) {
                throw new JSException("--keyalias must be specified.");
            }

            if (!keystoreManager.containsAlias(keyAlias.get())) {
                String keyPasswd = cryptoParameters.getKeyPasswd().orElseGet(passwdSupplier);
                if (keyPasswd.isEmpty()) {
                    passwdSupplier.get();
                }
            }
        }

        parameters.setParameterValue("importerBeanName", this.importerBeanName);

        return new SecretKeyInput(key, cryptoParameters);
    }

    public  SecretKeyInputFactory();
      SecretKeyInputFactory(Console console);

}