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.util.List;

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

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

    public final String name;
    public final String instruction;
    public final String languageTag;
    public final List<UserAuthInfoRequestPrompt> prompts;

    public SshMsgUserAuthInfoRequest(String name, String instruction, String languageTag, List<UserAuthInfoRequestPrompt> prompts) {
        assertNotNull(name);
        this.name = name;

        assertNotNull(instruction);
        this.instruction = instruction;

        assertNotNull(languageTag);
        this.languageTag = languageTag;

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

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

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

    @Override
    public String toString() {
        return "SshMsgUserAuthInfoRequest {"
               + "name='" + this.name + '\''
               + ", instruction='" + this.instruction + '\''
               + ", languageTag='" + this.languageTag + '\''
               + ", prompts=" + this.prompts
               + '}';
    }

    public interface Handler
            extends Message.HandlerBase {

        void handle(SshMsgUserAuthInfoRequest message, MessageConnection connection);

    }
}
