+ /**
+ * Trust this the identity with this safety number
+ *
+ * @param name username of the identity
+ * @param safetyNumber Safety number
+ */
+ public boolean trustIdentityVerifiedSafetyNumber(String name, String safetyNumber) {
+ List<JsonIdentityKeyStore.Identity> ids = signalProtocolStore.getIdentities(name);
+ if (ids == null) {
+ return false;
+ }
+ for (JsonIdentityKeyStore.Identity id : ids) {
+ if (!safetyNumber.equals(computeSafetyNumber(name, id.identityKey))) {
+ continue;
+ }
+
+ signalProtocolStore.saveIdentity(name, id.identityKey, TrustLevel.TRUSTED_VERIFIED);
+ save();
+ return true;
+ }
+ return false;
+ }
+