use of org.whispersystems.libsignal.IdentityKey in project Signal-Android by WhisperSystems.
the class WebRtcCallActivity method handleUntrustedIdentity.
private void handleUntrustedIdentity(@NonNull WebRtcViewModel event) {
final IdentityKey theirIdentity = event.getIdentityKey();
final Recipient recipient = event.getRecipient();
callScreen.setUntrustedIdentity(recipient, theirIdentity);
callScreen.setAcceptIdentityListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
IdentityDatabase identityDatabase = DatabaseFactory.getIdentityDatabase(WebRtcCallActivity.this);
identityDatabase.saveIdentity(recipient.getRecipientId(), theirIdentity);
Intent intent = new Intent(WebRtcCallActivity.this, WebRtcCallService.class);
intent.putExtra(WebRtcCallService.EXTRA_REMOTE_NUMBER, recipient.getNumber());
intent.setAction(WebRtcCallService.ACTION_OUTGOING_CALL);
startService(intent);
}
});
callScreen.setCancelIdentityButton(new View.OnClickListener() {
@Override
public void onClick(View v) {
handleTerminate(recipient);
}
});
}
use of org.whispersystems.libsignal.IdentityKey in project Signal-Android by WhisperSystems.
the class IdentityDatabase method isValidIdentity.
public boolean isValidIdentity(long recipientId, IdentityKey theirIdentity) {
SQLiteDatabase database = databaseHelper.getReadableDatabase();
Cursor cursor = null;
try {
cursor = database.query(TABLE_NAME, null, RECIPIENT + " = ?", new String[] { recipientId + "" }, null, null, null);
if (cursor != null && cursor.moveToFirst()) {
String serializedIdentity = cursor.getString(cursor.getColumnIndexOrThrow(IDENTITY_KEY));
IdentityKey ourIdentity = new IdentityKey(Base64.decode(serializedIdentity), 0);
return ourIdentity.equals(theirIdentity);
} else {
return true;
}
} catch (IOException e) {
Log.w("IdentityDatabase", e);
return false;
} catch (InvalidKeyException e) {
Log.w("IdentityDatabase", e);
return false;
} finally {
if (cursor != null) {
cursor.close();
}
}
}
use of org.whispersystems.libsignal.IdentityKey in project Signal-Android by WhisperSystems.
the class IdentityUtil method getRemoteIdentityKey.
@UiThread
public static ListenableFuture<Optional<IdentityKey>> getRemoteIdentityKey(final Context context, final MasterSecret masterSecret, final Recipient recipient) {
final SettableFuture<Optional<IdentityKey>> future = new SettableFuture<>();
new AsyncTask<Recipient, Void, Optional<IdentityKey>>() {
@Override
protected Optional<IdentityKey> doInBackground(Recipient... recipient) {
SessionStore sessionStore = new TextSecureSessionStore(context, masterSecret);
SignalProtocolAddress axolotlAddress = new SignalProtocolAddress(recipient[0].getNumber(), SignalServiceAddress.DEFAULT_DEVICE_ID);
SessionRecord record = sessionStore.loadSession(axolotlAddress);
if (record == null) {
return Optional.absent();
}
return Optional.fromNullable(record.getSessionState().getRemoteIdentityKey());
}
@Override
protected void onPostExecute(Optional<IdentityKey> result) {
future.set(result);
}
}.execute(recipient);
return future;
}
Aggregations