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 SshMsgUserAuthFailure
        extends Message<SshMsgUserAuthFailure.Handler> {

    public final List<String> authenticationsThatCanContinue;
    public final boolean partialSuccess;

    public SshMsgUserAuthFailure(List<String> authenticationsThatCanContinue, boolean partialSuccess) {
        assertNotNull(authenticationsThatCanContinue);
        this.authenticationsThatCanContinue = authenticationsThatCanContinue;

        this.partialSuccess = partialSuccess;
    }

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

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

    @Override
    public String toString() {
        return "SshMsgUserAuthFailure {"
                + "authenticationsThatCanContinue=" + this.authenticationsThatCanContinue
                + ", partialSuccess=" + this.partialSuccess
                + '}';
    }

    public interface Handler
            extends Message.HandlerBase {

        void handle(SshMsgUserAuthFailure message, MessageConnection connection);

    }
}
