summaryrefslogtreecommitdiff
path: root/src/main/kotlin/Authenticator.kt
blob: a14684022f9f57c84c02a8aba3d2a48cd6e466a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/**
 * The Authenticator interface provides methods for authenticating a user over an established protocol connection.
 */
interface Authenticator {
    /**
     * Authenticate a user identified by the given [username] and whose authenticity is confirmed by the given
     * [password]. The authentication protocol can read and write data within the underlying connection using [readFun]
     * and [writeFun].
     *
     * @param username The name the user goes by.
     * @param password The confirmation of the user's authenticity.
     * @param readFun A function to read incoming data from the underlying connection.
     * @param writeFun A function to write outgoing data into the underlying connection.
     * @throws FailedAuthenticationException if the authentication could not be performed. A human-readable reason for
     *                                       the failure can be provided if necessary.
     */
    fun authenticate(username: String, password: String, readFun: () -> Array<UByte>, writeFun: (b: Array<UByte>) -> Unit)
}