pgpainless/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/api/AuthenticateAPI.kt

47 lines
1.4 KiB
Kotlin
Raw Normal View History

2023-06-29 17:49:12 +02:00
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
//
// SPDX-License-Identifier: Apache-2.0
2023-07-07 15:42:04 +02:00
package org.pgpainless.wot.api
2023-06-29 17:49:12 +02:00
2023-07-09 13:03:57 +02:00
import org.pgpainless.wot.network.Fingerprint
2023-06-29 17:49:12 +02:00
/**
* Authenticate a binding.
* A binding is a pair consisting of a certificate and a User ID.
*/
interface AuthenticateAPI {
/**
* Authenticate the binding between a fingerprint and a given userId.
*
* @param arguments arguments
*/
fun authenticate(arguments: Arguments): Result
/**
* Bundle for arguments to the authenticate operation.
* @param fingerprint fingerprint of the certificate
* @param userId user-ID for which we want to authenticate a binding to the certificate
* @param email if true, consider [userId] to be an email address and consider all bindings containing it
*/
data class Arguments(
var fingerprint: Fingerprint,
var userId: String,
var email: Boolean = false)
/**
* Authentication result.
* @param targetAmount the targeted trust amount required to achieve full authentication
* @param paths the number of paths
*/
data class Result(val binding: Binding, val targetAmount: Int) {
val percentage: Int
get() = binding.percentage(targetAmount)
2023-07-13 16:53:35 +02:00
val acceptable: Boolean
get() = binding.paths.amount >= targetAmount
}
2023-06-29 17:49:12 +02:00
2023-07-03 17:07:21 +02:00
}