X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Ffreenet%2Fwot%2FDefaultIdentity.kt;h=88527b30f7fc951b2d7cef535435d8b0fa7c399c;hp=d50a4bab14050b308a7d8ec083237545f279f172;hb=69a95e89c8a306713bbe719ce23f49e7536774be;hpb=29c49a60fc90dff37f981d813aa613606cbcd4dd diff --git a/src/main/kotlin/net/pterodactylus/sone/freenet/wot/DefaultIdentity.kt b/src/main/kotlin/net/pterodactylus/sone/freenet/wot/DefaultIdentity.kt index d50a4ba..88527b3 100644 --- a/src/main/kotlin/net/pterodactylus/sone/freenet/wot/DefaultIdentity.kt +++ b/src/main/kotlin/net/pterodactylus/sone/freenet/wot/DefaultIdentity.kt @@ -1,5 +1,5 @@ /* - * Sone - DefaultIdentity.java - Copyright © 2010–2019 David Roden + * Sone - DefaultIdentity.kt - Copyright © 2010–2020 David Roden * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,12 +17,14 @@ package net.pterodactylus.sone.freenet.wot -import java.util.Collections.* +import java.util.Collections.synchronizedMap +import java.util.Collections.synchronizedSet +import kotlin.collections.set /** * A Web of Trust identity. */ -open class DefaultIdentity(private val id: String, private val nickname: String, private val requestUri: String) : Identity { +open class DefaultIdentity(private val id: String, private val nickname: String?, private val requestUri: String) : Identity { private val contexts = mutableSetOf().synchronized() private val properties = mutableMapOf().synchronized() @@ -35,7 +37,7 @@ open class DefaultIdentity(private val id: String, private val nickname: String, override fun hasContext(context: String) = context in contexts - override fun setContexts(contexts: Collection) { + override fun setContexts(contexts: Set) { synchronized(this.contexts) { this.contexts.clear() this.contexts.addAll(contexts) @@ -77,6 +79,10 @@ open class DefaultIdentity(private val id: String, private val nickname: String, } } + override fun getTrust(): Map = synchronized(trustCache) { + trustCache.toMap() + } + override fun getTrust(ownIdentity: OwnIdentity) = synchronized(trustCache) { trustCache[ownIdentity] }