class ChaosSSHCredentials implements SSHCredentials {

    @Override
    public List<AuthMethod> getAuthMethods () {
        List<AuthMethod> authMethods = sshKeys.entrySet()
                                              .stream()
                                              .filter(e -> e.getKey() != null && e.getValue() != null)
                                              .map(e -> new KeyPairWrapper(e.getKey(), e.getValue()))
                                              .map(AuthPublickey::new)
                                              .collect(Collectors.toList());
        if (passwordGenerator != null) {
            try {
                authMethods.add(new AuthPassword(new PasswordFinder() {
                    @Override
                    public char[] reqPassword (Resource<?> resource) {
                        try {
                            return passwordGenerator.call().toCharArray();
                        } catch (Exception e) {
                            throw new ChaosException(SSH_CREDENTIAL_PASSWORD_CALL_FAILURE, e);
                        }
                    }

                    @Override
                    public boolean shouldRetry (Resource<?> resource) {
                        return false;
                    }
                }));
            } catch (ChaosException e) {
                log.error("Could not create password-based authentication token", e);
            }
        }
        return authMethods;
    }

}