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

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

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

/**
 * @author Alex Usun
 */
public class SshMsgUserAuthRequestPassword
        extends SshMsgUserAuthRequest<SshMsgUserAuthRequestPassword.Handler> {

    public final String password;

    public SshMsgUserAuthRequestPassword(String username, String serviceName, String password) {
        super(username, serviceName);

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

    @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 "SshMsgUserAuthRequestPassword {"
                + "username='" + this.username + '\''
                + ", serviceName='" + this.serviceName + '\''
                + ", password='*****'"
                + '}';
    }

    public interface Handler
            extends Message.HandlerBase {

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

    }
}
