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 SshMsgUserAuthRequestKeyboardInteractive
        extends SshMsgUserAuthRequest<SshMsgUserAuthRequestKeyboardInteractive.Handler> {

    public final String languageTag;
    public final List<String> subMethods;

    public SshMsgUserAuthRequestKeyboardInteractive(String username, String serviceName, String languageTag, List<String> subMethods) {
        super(username, serviceName);

        assertNotNull(languageTag);
        this.languageTag = languageTag;

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

    @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 "SshMsgUserAuthRequestKeyboardInteractive {"
               + "username='" + this.username + '\''
               + ", serviceName='" + this.serviceName + '\''
               + ", languageTag='" + this.languageTag + '\''
               + ", subMethods=" + this.subMethods
               + '}';
    }

    public interface Handler
            extends Message.HandlerBase {

        void handle(SshMsgUserAuthRequestKeyboardInteractive message, MessageConnection<Message> connection);

    }
}
