package com.jscape.inet.ssh.protocol.v2.messages;

import com.jscape.inet.ssh.protocol.messages.Message;
import com.jscape.util.net.connection.MessageConnection;

import java.security.PublicKey;
import java.util.Arrays;

import static com.jscape.util.Parameters.assertNotNull;

/**
 * @author Alex Usun
 */
public class SshMsgKexEcdhReply
        extends Message<SshMsgKexEcdhReply.Handler> {

    public final PublicKey hostKey;
    public final PublicKey qs;
    public final Signature signature;
    public byte[] hostKeyBlob;

    public SshMsgKexEcdhReply(PublicKey hostKey, PublicKey qs, Signature signature) {
        assertNotNull(hostKey);
        this.hostKey = hostKey;

        assertNotNull(qs);
        this.qs = qs;

        assertNotNull(signature);
        this.signature = signature;
    }

    @Override
    public Class handlerClass() {
        return Handler.class;
    }

    @Override
    public void accept(Handler handler, MessageConnection<Message> connection) {
        handler.handle(this, connection);
    }

    @Override
    public String toString() {
        return "SshMsgKexEcdhReply {"
               + "hostKey=" + this.hostKey
               + ", qs=" + this.qs
               + ", signature=" + this.signature
               + ", hostKeyBlob=" + Arrays.toString(this.hostKeyBlob)
               + '}';
    }

    public interface Handler
            extends Message.HandlerBase {
        
        void handle(SshMsgKexEcdhReply message, MessageConnection<Message> connection);
        
    }
}
