summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdoardo La Greca2025-08-02 19:08:05 +0200
committerEdoardo La Greca2025-08-02 19:08:05 +0200
commitc11decee92748a7c6ea4294b0954438c6cf5d782 (patch)
treec6108589083136e5a6e5748c8e0c8c9292cfb046
parent451f327d034f27aef470abfd67eaa4ea70f1a33c (diff)
add Authenticator, Authenticator9PAnyV2DP9IK (draft), FailedAuthenticationException
-rw-r--r--src/main/kotlin/Authenticator.kt18
-rw-r--r--src/main/kotlin/Authenticator9PAnyV2DP9IK.kt12
-rw-r--r--src/main/kotlin/FailedAuthenticationException.kt6
3 files changed, 36 insertions, 0 deletions
diff --git a/src/main/kotlin/Authenticator.kt b/src/main/kotlin/Authenticator.kt
new file mode 100644
index 0000000..a146840
--- /dev/null
+++ b/src/main/kotlin/Authenticator.kt
@@ -0,0 +1,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)
+} \ No newline at end of file
diff --git a/src/main/kotlin/Authenticator9PAnyV2DP9IK.kt b/src/main/kotlin/Authenticator9PAnyV2DP9IK.kt
new file mode 100644
index 0000000..ec0710d
--- /dev/null
+++ b/src/main/kotlin/Authenticator9PAnyV2DP9IK.kt
@@ -0,0 +1,12 @@
+/**
+ * This class (with an ugly ass name) implements the authentication procedure for the p9any meta-protocol version 2,
+ * hinting at the usage of dp9ik during negotiation and failing if it's unavailable.
+ *
+ * The 9P protocol does not provide a default authentication method. However, since NineKt must work with 9front's
+ * default authenticated 9P service, it must implement the p9any meta-protocol, preferably version 2.
+ */
+class Authenticator9PAnyV2DP9IK : Authenticator {
+ override fun authenticate(username: String, password: String, readFun: () -> Array<UByte>, writeFun: (Array<UByte>) -> Unit) {
+ TODO("Not yet implemented")
+ }
+} \ No newline at end of file
diff --git a/src/main/kotlin/FailedAuthenticationException.kt b/src/main/kotlin/FailedAuthenticationException.kt
new file mode 100644
index 0000000..f437673
--- /dev/null
+++ b/src/main/kotlin/FailedAuthenticationException.kt
@@ -0,0 +1,6 @@
+/**
+ * The authentication with the remote part failed.
+ *
+ * @param reason A human-readable reason for which the authentication failed.
+ */
+class FailedAuthenticationException(val reason: String) : Exception() \ No newline at end of file