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

import com.jscape.inet.ssh.protocol.v2.transport.TransportConnection;
import com.jscape.util.SuppressObfuscation;

/**
 * SSH client authentication operation.
 *
 * @author Alex Usun
 */
public interface ClientAuthentication {

    /**
     * Performs actual client authentication.
     *
     * @param connection SSH transport connection
     * @param serviceName target service name
     *
     * @throws Exception if an error occurs
     */
    void applyTo(TransportConnection connection, String serviceName)
            throws Exception;

    /**
     * Represents invalid credentials error.
     */
    @SuppressObfuscation
    class InvalidCredentialsException
            extends Exception {

        private static final long serialVersionUID = -5286313697452543134L;

        public InvalidCredentialsException() {
            super("Invalid credentials.");
        }
    }

    /**
     * Represents partial success state in case server requires multi-stage authentication.
     */
    @SuppressObfuscation
    class PartialSuccessException
            extends Exception {

        private static final long serialVersionUID = -7082299889016575025L;

        public PartialSuccessException() {
            super("Partial authentication success.");
        }
    }
}
