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

    public final String oldPassword;
    public final String newPassword;

    public SshMsgUserAuthRequestNewPassword(String username, String serviceName, String oldPassword, String newPassword) {
        super(username, serviceName);

        assertNotNull(oldPassword);
        this.oldPassword = oldPassword;

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

    @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 "SshMsgUserAuthRequestNewPassword {"
                + "oldPassword='*****'"
                + ", newPassword='*****'"
                + '}';
    }

    public interface Handler
            extends Message.HandlerBase {

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

    }
}
