package be.iminds.ilabt.jfed.lowlevel.connection;

import be.iminds.ilabt.jfed.lowlevel.JFedException;
import be.iminds.ilabt.jfed.util.JFedPasswordManager;
import be.iminds.ilabt.jfed.util.JFedTrustStore;

import java.net.MalformedURLException;
import java.net.URL;
import java.security.PrivateKey;
import java.security.cert.X509Certificate;
import java.util.List;

/**
 * ConnectionFactory
 */
public interface ConnectionBuilder {
    void setUrl(String serverUrlString) throws MalformedURLException;
    void setUrl(URL serverUrl);

    void setDebugInfo(JFedConnection.DebugInfo debugInfo);

    void setProxy(JFedConnection.ProxyInfo proxyInfo, boolean forceSshProxyDns);

    void useNoAuthentication();

    void useHttpBasicAuthentication(JFedPasswordManager.LoginInfo login);
    void useSslClientAuthentication(List<X509Certificate> clientCertChain, PrivateKey privateKey);

    void useHttp();
    void useHttps(final JFedTrustStore conTrustStore, HandleUntrustedCallback handleUntrustedCallback);

    SfaConnection buildSfaConnection() throws JFedException;
    HttpConnection buildHttpConnection() throws JFedException;

    ConnectionConfig getCurrentConnectionConfig(ConnectionConfig.Type type);
    void set(ConnectionConfig connectionConfig);

    void setHackAllowAllServerCertificates(boolean hackAllowAllServerCertificates);
    /**
     * set yo null to do nothing
     * otherwise, add hostname aliases to allow in the server certificate
     * add "*" to accept any server name alias in the certificate
     */
    void setHackOverrideAllowedServerCertificateAlias(List<String> hackOverrideAllowedServerCertificateAlias);
}

