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

import be.iminds.ilabt.jfed.lowlevel.JFedException;
import org.apache.xmlrpc.client.XmlRpcClient;

/**
 * SfaSslWithClientAuthConnection: XmlRpc over HTTPs, which doesn't use SSL with client authentication
 * THIS IS NOT A NORMAL SFA CONNECTION. This is only used for GetVersion etc...
 */
public class BasicSfaConnection extends SfaConnection {
    /**
     * Create a connection by specifying all low level details needed.
     *
     * @throws be.iminds.ilabt.jfed.lowlevel.JFedException if something went wrong while performing the call: either a server-error or an unexpected server response
     */
    public BasicSfaConnection(ConnectionConfig connectionConfig,
                              HttpInfoXmlRpcTransportFactory xmlRpcTransportFactory,
                              XmlRpcClient xmlRpcClient) throws JFedException {
        super(connectionConfig);

        this.xmlRpcTransportFactory = xmlRpcTransportFactory;
        this.xmlRpcClient = xmlRpcClient;
    }

    public void close() {
        error = true;
        xmlRpcTransportFactory.clearLastCallData();
        xmlRpcTransportFactory.close();
        xmlRpcTransportFactory = null;
        xmlRpcClient = null;
    }
}