/** All known replies. */
private Set<String> knownReplies = new HashSet<String>();
+ /** Trusted identities, sorted by own identities. */
+ private Map<OwnIdentity, Set<Identity>> trustedIdentities = Collections.synchronizedMap(new HashMap<OwnIdentity, Set<Identity>>());
+
/**
* Creates a new core.
*
}
/**
+ * Returns whether the target Sone is trusted by the origin Sone.
+ *
+ * @param origin
+ * The origin Sone
+ * @param target
+ * The target Sone
+ * @return {@code true} if the target Sone is trusted by the origin Sone
+ */
+ public boolean isSoneTrusted(Sone origin, Sone target) {
+ return trustedIdentities.containsKey(origin) && trustedIdentities.get(origin.getIdentity()).contains(target);
+ }
+
+ /**
* Returns the post with the given ID.
*
* @param postId
public void ownIdentityAdded(OwnIdentity ownIdentity) {
logger.log(Level.FINEST, "Adding OwnIdentity: " + ownIdentity);
if (ownIdentity.hasContext("Sone")) {
+ trustedIdentities.put(ownIdentity, Collections.synchronizedSet(new HashSet<Identity>()));
addLocalSone(ownIdentity);
}
}
@Override
public void ownIdentityRemoved(OwnIdentity ownIdentity) {
logger.log(Level.FINEST, "Removing OwnIdentity: " + ownIdentity);
+ trustedIdentities.remove(ownIdentity);
}
/**
@Override
public void identityAdded(OwnIdentity ownIdentity, Identity identity) {
logger.log(Level.FINEST, "Adding Identity: " + identity);
+ trustedIdentities.get(ownIdentity).add(identity);
addRemoteSone(identity);
}
*/
@Override
public void identityRemoved(OwnIdentity ownIdentity, Identity identity) {
- /* TODO */
+ trustedIdentities.get(ownIdentity).remove(identity);
}
}