1 package net.pterodactylus.sone.freenet.wot
3 import net.pterodactylus.sone.freenet.plugin.*
6 * Connector for the web of trust plugin.
8 interface WebOfTrustConnector {
11 * Loads all own identities from the Web of Trust plugin.
13 * @return All own identity
14 * @throws WebOfTrustException if the own identities can not be loaded
16 @Throws(WebOfTrustException::class)
17 fun loadAllOwnIdentities(): Set<OwnIdentity>
20 * Loads all identities that the given identities trusts with a score of
21 * more than 0 and the (optional) given context.
23 * @param ownIdentity The own identity
24 * @param context The context to filter, or `null`
25 * @return All trusted identities
26 * @throws PluginException if an error occured talking to the Web of Trust plugin
28 @Throws(PluginException::class)
29 fun loadTrustedIdentities(ownIdentity: OwnIdentity, context: String? = null): Set<Identity>
32 * Adds the given context to the given identity.
34 * @param ownIdentity The identity to add the context to
35 * @param context The context to add
36 * @throws PluginException if an error occured talking to the Web of Trust plugin
38 @Throws(PluginException::class)
39 fun addContext(ownIdentity: OwnIdentity, context: String)
42 * Removes the given context from the given identity.
44 * @param ownIdentity The identity to remove the context from
45 * @param context The context to remove
46 * @throws PluginException if an error occured talking to the Web of Trust plugin
48 @Throws(PluginException::class)
49 fun removeContext(ownIdentity: OwnIdentity, context: String)
52 * Sets the property with the given name to the given value.
54 * @param ownIdentity The identity to set the property on
55 * @param name The name of the property to set
56 * @param value The value to set
57 * @throws PluginException if an error occured talking to the Web of Trust plugin
59 @Throws(PluginException::class)
60 fun setProperty(ownIdentity: OwnIdentity, name: String, value: String)
63 * Removes the property with the given name.
65 * @param ownIdentity The identity to remove the property from
66 * @param name The name of the property to remove
67 * @throws PluginException if an error occured talking to the Web of Trust plugin
69 @Throws(PluginException::class)
70 fun removeProperty(ownIdentity: OwnIdentity, name: String)
73 * Returns the trust for the given identity assigned to it by the given own
76 * @param ownIdentity The own identity
77 * @param identity The identity to get the trust for
78 * @return The trust for the given identity
79 * @throws PluginException if an error occured talking to the Web of Trust plugin
81 @Throws(PluginException::class)
82 fun getTrust(ownIdentity: OwnIdentity, identity: Identity): Trust
85 * Sets the trust for the given identity.
87 * @param ownIdentity The trusting identity
88 * @param identity The trusted identity
89 * @param trust The amount of trust (-100 thru 100)
90 * @param comment The comment or explanation of the trust value
91 * @throws PluginException if an error occured talking to the Web of Trust plugin
93 @Throws(PluginException::class)
94 fun setTrust(ownIdentity: OwnIdentity, identity: Identity, trust: Int, comment: String)
97 * Removes any trust assignment of the given own identity for the given
100 * @param ownIdentity The own identity
101 * @param identity The identity to remove all trust for
102 * @throws WebOfTrustException if an error occurs
104 @Throws(WebOfTrustException::class)
105 fun removeTrust(ownIdentity: OwnIdentity, identity: Identity)
108 * Pings the Web of Trust plugin. If the plugin can not be reached, a
109 * [PluginException] is thrown.
111 * @throws PluginException if the plugin is not loaded
113 @Throws(PluginException::class)
117 * Stops the web of trust connector.