package lc.mecha.http.server;

import lc.mecha.security.CertificateKeyStore;

import java.util.Objects;

/**
 * @author Alex Leigh
 * @since mk20 (TOKYO PROTOCOL)
 */
public class ListenerConfig {
    private final boolean isSecure;
    private final int port;
    private final CertificateKeyStore keyStore;


    public ListenerConfig(int port, CertificateKeyStore keyStore) {
        this.isSecure = true;
        this.port = port;
        this.keyStore = keyStore;
    }

    public ListenerConfig(int port) {
        this.isSecure = false;
        this.port = port;
        this.keyStore = null;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ListenerConfig that = (ListenerConfig) o;
        return isSecure == that.isSecure && port == that.port && Objects.equals(keyStore, that.keyStore);
    }

    @Override
    public int hashCode() {
        return Objects.hash(isSecure, port, keyStore);
    }

    @Override
    public String toString() {
        return "WebConnector{" +
                "isSecure=" + isSecure +
                ", port=" + port +
                ", keyStore=" + keyStore +
                '}';
    }

    public boolean isSecure() {
        return isSecure;
    }

    public int getPort() {
        return port;
    }

    public CertificateKeyStore getKeyStore() {
        return keyStore;
    }
}
