Switch to a more heavily TOFU model for identity keys.
1) There is no longer a concept of "verified" or "unverified." Only "what we saw last time" and "different from last time." 2) Let's eliminate "verify session," since we're all about identity keys now. 3) Mark manually processed key exchanges as processed.pull/1/head
parent
ef7977128b
commit
24fc93e9ae
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
Binary file not shown.
After Width: | Height: | Size: 596 B |
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
@ -1,59 +1,48 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView android:id="@+id/ScrollView"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="10dip">
|
||||
|
||||
<TextView android:id="@+id/description_text"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="17dip"
|
||||
android:layout_marginBottom="5dip" />
|
||||
|
||||
<TextView android:id="@+id/signature_text"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="17dip"
|
||||
android:textStyle="italic"
|
||||
android:layout_marginBottom="10dip" />
|
||||
|
||||
<LinearLayout android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button android:id="@+id/verify_session_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/receive_key_activity__session"
|
||||
android:visibility="gone"
|
||||
android:gravity="center" />
|
||||
|
||||
<Button android:id="@+id/verify_identity_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/receive_key_activity__identities"
|
||||
android:visibility="gone"
|
||||
android:gravity="center" />
|
||||
|
||||
<Button android:id="@+id/ok_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/receive_key_activity__complete_exchange"
|
||||
android:gravity="center"/>
|
||||
|
||||
<Button android:id="@+id/cancel_button"
|
||||
android:text="@android:string/cancel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:fillViewport="true"
|
||||
android:background="@drawable/background_pattern_repeat">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:gravity="center">
|
||||
|
||||
<LinearLayout android:paddingRight="16dip"
|
||||
android:paddingLeft="16dip"
|
||||
android:paddingTop="10dip"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView style="@style/Registration.Description"
|
||||
android:id="@+id/description_text"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_marginBottom="16dip"
|
||||
android:layout_marginTop="16dip"
|
||||
android:text="@string/receive_key_activity__the_signature_on_this_key_exchange_is_different"/>
|
||||
|
||||
<LinearLayout android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_marginBottom="7dip"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button android:id="@+id/cancel_button"
|
||||
android:text="@android:string/cancel"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<Button android:id="@+id/ok_button"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/receive_key_activity__complete"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
</ScrollView>
|
||||
|
||||
|
||||
|
@ -1,24 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="16dip"
|
||||
android:paddingRight="16dip">
|
||||
|
||||
<ListView android:id="@android:id/list"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:drawSelectorOnTop="false"
|
||||
android:scrollbarStyle="insideOverlay"
|
||||
android:fadingEdgeLength="16dip" />
|
||||
|
||||
<TextView android:id="@id/android:empty"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/review_identities__you_don_t_currently_have_any_identity_keys_in_your_trust_database"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:padding="20dip" />
|
||||
|
||||
</LinearLayout>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
<fragment android:id="@+id/fragment_content"
|
||||
android:name="org.thoughtcrime.securesms.ReviewIdentitiesFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
</FrameLayout>
|
||||
|
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="16dip"
|
||||
android:paddingRight="16dip">
|
||||
|
||||
<ListView android:id="@android:id/list"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:drawSelectorOnTop="false"
|
||||
android:scrollbarStyle="insideOverlay"
|
||||
android:fadingEdgeLength="16dip" />
|
||||
|
||||
<TextView android:id="@id/android:empty"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/review_identities__you_don_t_currently_have_any_identity_keys_in_your_trust_database"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:padding="20dip" />
|
||||
|
||||
</LinearLayout>
|
@ -1,40 +0,0 @@
|
||||
package org.thoughtcrime.securesms;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.actionbarsherlock.view.Menu;
|
||||
import com.actionbarsherlock.view.MenuInflater;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
|
||||
public abstract class KeyVerifyingActivity extends KeyScanningActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
this.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
super.onPrepareOptionsMenu(menu);
|
||||
|
||||
MenuInflater inflater = this.getSupportMenuInflater();
|
||||
inflater.inflate(R.menu.verify_keys, menu);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
super.onOptionsItemSelected(item);
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_session_verified: handleVerified(); return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected abstract void handleVerified();
|
||||
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
package org.thoughtcrime.securesms;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.LoaderManager;
|
||||
import android.support.v4.content.Loader;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CursorAdapter;
|
||||
import android.widget.ListView;
|
||||
|
||||
import com.actionbarsherlock.app.SherlockListFragment;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.IdentityDatabase;
|
||||
import org.thoughtcrime.securesms.database.loaders.IdentityLoader;
|
||||
|
||||
public class ReviewIdentitiesFragment extends SherlockListFragment
|
||||
implements LoaderManager.LoaderCallbacks<Cursor>
|
||||
{
|
||||
private MasterSecret masterSecret;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
|
||||
return inflater.inflate(R.layout.review_identities_fragment, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle bundle) {
|
||||
super.onActivityCreated(bundle);
|
||||
this.masterSecret = getSherlockActivity().getIntent().getParcelableExtra("master_secret");
|
||||
|
||||
initializeListAdapter();
|
||||
getLoaderManager().initLoader(0, null, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListItemClick(ListView listView, View view, int position, long id) {
|
||||
Intent viewIntent = new Intent(getActivity(), ViewIdentityActivity.class);
|
||||
viewIntent.putExtra("identity_key", ((IdentityKeyView)view).getIdentityKey());
|
||||
startActivity(viewIntent);
|
||||
}
|
||||
|
||||
private void initializeListAdapter() {
|
||||
this.setListAdapter(new IdentitiesListAdapter(getActivity(), null, masterSecret));
|
||||
getLoaderManager().restartLoader(0, null, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
||||
return new IdentityLoader(getActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
|
||||
((CursorAdapter)getListAdapter()).changeCursor(cursor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoaderReset(Loader<Cursor> loader) {
|
||||
((CursorAdapter)getListAdapter()).changeCursor(null);
|
||||
}
|
||||
|
||||
private class IdentitiesListAdapter extends CursorAdapter {
|
||||
private final MasterSecret masterSecret;
|
||||
|
||||
public IdentitiesListAdapter(Context context, Cursor cursor, MasterSecret masterSecret) {
|
||||
super(context, cursor);
|
||||
this.masterSecret = masterSecret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindView(View view, Context context, Cursor cursor) {
|
||||
IdentityDatabase.Reader reader = DatabaseFactory.getIdentityDatabase(context)
|
||||
.readerFor(masterSecret, cursor);
|
||||
|
||||
((IdentityKeyView)view).set(reader.getCurrent());
|
||||
}
|
||||
|
||||
@Override
|
||||
public View newView(Context context, Cursor cursor, ViewGroup parent) {
|
||||
IdentityKeyView identityKeyView = new IdentityKeyView(context);
|
||||
bindView(identityKeyView, context, cursor);
|
||||
return identityKeyView;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,123 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2011 Whisper Systems
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.thoughtcrime.securesms;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.thoughtcrime.securesms.crypto.IdentityKey;
|
||||
import org.thoughtcrime.securesms.crypto.InvalidKeyException;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.util.MemoryCleaner;
|
||||
|
||||
/**
|
||||
* Activity that provides interface for users to save
|
||||
* identity keys they receive.
|
||||
*
|
||||
* @author Moxie Marlinspike
|
||||
*/
|
||||
public class SaveIdentityActivity extends PassphraseRequiredSherlockActivity {
|
||||
|
||||
private MasterSecret masterSecret;
|
||||
private IdentityKey identityKey;
|
||||
|
||||
private EditText identityName;
|
||||
private Button okButton;
|
||||
private Button cancelButton;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
setContentView(R.layout.save_identity_activity);
|
||||
|
||||
initializeResources();
|
||||
initializeListeners();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
MemoryCleaner.clean(masterSecret);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
private void initializeResources() {
|
||||
String nameSuggestion = getIntent().getStringExtra("name_suggestion");
|
||||
|
||||
this.masterSecret = (MasterSecret)getIntent().getParcelableExtra("master_secret");
|
||||
this.identityKey = (IdentityKey)getIntent().getParcelableExtra("identity_key");
|
||||
this.identityName = (EditText)findViewById(R.id.identity_name);
|
||||
this.okButton = (Button)findViewById(R.id.ok_button);
|
||||
this.cancelButton = (Button)findViewById(R.id.cancel_button);
|
||||
|
||||
if ((nameSuggestion != null) && (nameSuggestion.trim().length() > 0)) {
|
||||
this.identityName.setText(nameSuggestion);
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeListeners() {
|
||||
this.okButton.setOnClickListener(new OkListener());
|
||||
this.cancelButton.setOnClickListener(new CancelListener());
|
||||
}
|
||||
|
||||
private class OkListener implements View.OnClickListener {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (identityName.getText() == null || identityName.getText().toString().trim().length() == 0) {
|
||||
Toast.makeText(SaveIdentityActivity.this,
|
||||
R.string.SaveIdentityActivity_you_must_specify_a_name_for_this_identity_exclamation,
|
||||
Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
DatabaseFactory.getIdentityDatabase(SaveIdentityActivity.this).saveIdentity(masterSecret, identityKey, identityName.getText().toString());
|
||||
} catch (InvalidKeyException e) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(SaveIdentityActivity.this);
|
||||
builder.setTitle(R.string.SaveIdentityActivity_identity_name_exists_exclamation);
|
||||
builder.setMessage(R.string.SaveIdentityActivity_an_identity_key_with_the_specified_name_already_exists);
|
||||
builder.setPositiveButton(R.string.SaveIdentityActivity_manage_identities,
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Intent intent = new Intent(SaveIdentityActivity.this, ReviewIdentitiesActivity.class);
|
||||
intent.putExtra("master_secret", masterSecret);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(android.R.string.cancel, null);
|
||||
builder.show();
|
||||
return;
|
||||
}
|
||||
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
private class CancelListener implements View.OnClickListener {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,180 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2011 Whisper Systems
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.thoughtcrime.securesms;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.thoughtcrime.securesms.crypto.IdentityKey;
|
||||
import org.thoughtcrime.securesms.crypto.InvalidKeyException;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.util.Dialogs;
|
||||
import org.thoughtcrime.securesms.util.MemoryCleaner;
|
||||
|
||||
/**
|
||||
* Activity for verifying identities keys as they are imported.
|
||||
*
|
||||
* @author Moxie Marlinspike
|
||||
*/
|
||||
|
||||
public class VerifyImportedIdentityActivity extends KeyScanningActivity {
|
||||
|
||||
private MasterSecret masterSecret;
|
||||
private String contactName;
|
||||
private IdentityKey identityKey;
|
||||
private EditText identityName;
|
||||
private TextView identityFingerprint;
|
||||
|
||||
private Button compareButton;
|
||||
private Button verifiedButton;
|
||||
private Button cancelButton;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle state) {
|
||||
super.onCreate(state);
|
||||
setContentView(R.layout.verify_imported_identity_activity);
|
||||
|
||||
initializeResources();
|
||||
initializeFingerprints();
|
||||
initializeListeners();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
MemoryCleaner.clean(masterSecret);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
private void initializeListeners() {
|
||||
verifiedButton.setOnClickListener(new VerifiedButtonListener());
|
||||
cancelButton.setOnClickListener(new CancelButtonListener());
|
||||
compareButton.setOnClickListener(new CompareButtonListener());
|
||||
}
|
||||
|
||||
private void initializeFingerprints() {
|
||||
if (contactName != null)
|
||||
identityName.setText(contactName);
|
||||
identityFingerprint.setText(identityKey.getFingerprint());
|
||||
}
|
||||
|
||||
private void initializeResources() {
|
||||
masterSecret = (MasterSecret)this.getIntent().getParcelableExtra("master_secret");
|
||||
identityFingerprint = (TextView)findViewById(R.id.imported_identity);
|
||||
identityName = (EditText)findViewById(R.id.identity_name);
|
||||
identityKey = (IdentityKey)this.getIntent().getParcelableExtra("identity_key");
|
||||
contactName = (String)this.getIntent().getStringExtra("contact_name");
|
||||
verifiedButton = (Button)findViewById(R.id.verified_button);
|
||||
cancelButton = (Button)findViewById(R.id.cancel_button);
|
||||
compareButton = (Button)findViewById(R.id.compare_button);
|
||||
}
|
||||
|
||||
private class CancelButtonListener implements View.OnClickListener {
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
private class CompareButtonListener implements View.OnClickListener {
|
||||
public void onClick(View v) {
|
||||
registerForContextMenu(compareButton);
|
||||
compareButton.showContextMenu();
|
||||
}
|
||||
}
|
||||
|
||||
private class VerifiedButtonListener implements View.OnClickListener {
|
||||
public void onClick(View v) {
|
||||
if (identityName.getText() == null || identityName.getText().length() == 0) {
|
||||
Toast.makeText(VerifyImportedIdentityActivity.this,
|
||||
R.string.VerifyImportedIdentityActivity_you_must_specify_a_name_for_this_contact_exclamation,
|
||||
Toast.LENGTH_LONG);
|
||||
return;
|
||||
}
|
||||
|
||||
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(VerifyImportedIdentityActivity.this);
|
||||
dialogBuilder.setTitle(R.string.VerifyImportedIdentityActivity_save_identity_key_question);
|
||||
dialogBuilder.setIcon(android.R.drawable.ic_dialog_info);
|
||||
dialogBuilder.setMessage(String.format(getString(R.string.VerifyImportedIdentityActivity_are_you_sure_that_you_would_like_to_mark_this_as_a_valid_identity_key_for_all_future_correspondence_with_s), identityName.getText()));
|
||||
dialogBuilder.setCancelable(true);
|
||||
dialogBuilder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface arg0, int arg1) {
|
||||
try {
|
||||
DatabaseFactory.getIdentityDatabase(VerifyImportedIdentityActivity.this).saveIdentity(masterSecret, identityKey, identityName.getText().toString());
|
||||
} catch (InvalidKeyException ike) {
|
||||
Log.w("VerifiedButtonListener", ike);
|
||||
Dialogs.displayAlert(VerifyImportedIdentityActivity.this,
|
||||
getString(R.string.VerifyImportedIdentityActivity_error_saving_identity_key_exclamation),
|
||||
getString(R.string.VerifyImportedIdentityActivity_this_identity_key_or_an_identity_key_with_the_same_name_already_exists_please_edit_your_key_database),
|
||||
android.R.drawable.ic_dialog_alert);
|
||||
return;
|
||||
}
|
||||
|
||||
finish();
|
||||
}
|
||||
});
|
||||
dialogBuilder.setNegativeButton(R.string.no, null);
|
||||
dialogBuilder.show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getScanString() {
|
||||
return getString(R.string.VerifyImportedIdentityActivity_scan_to_compare);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDisplayString() {
|
||||
return getString(R.string.VerifyImportedIdentityActivity_get_scanned_to_compare);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IdentityKey getIdentityKeyToCompare() {
|
||||
return identityKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IdentityKey getIdentityKeyToDisplay() {
|
||||
return identityKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getNotVerifiedMessage() {
|
||||
return getString(R.string.VerifyImportedIdentityActivity_warning_the_scanned_key_does_not_match_exclamation);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getNotVerifiedTitle() {
|
||||
return getString(R.string.VerifyImportedIdentityActivity_not_verified_exclamation);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getVerifiedMessage() {
|
||||
return getString(R.string.VerifyImportedIdentityActivity_the_scanned_key_matches_exclamation);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getVerifiedTitle() {
|
||||
return getString(R.string.VerifyImportedIdentityActivity_verified_exclamation);
|
||||
}
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2011 Whisper Systems
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.thoughtcrime.securesms.crypto;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.keys.SessionRecord;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
|
||||
public class AuthenticityCalculator {
|
||||
|
||||
private static boolean isAuthenticatedIdentity(Context context,
|
||||
MasterSecret masterSecret,
|
||||
IdentityKey identityKey)
|
||||
{
|
||||
String identityName = DatabaseFactory.getIdentityDatabase(context)
|
||||
.getNameForIdentity(masterSecret, identityKey);
|
||||
|
||||
if (identityName == null) return false;
|
||||
else return true;
|
||||
}
|
||||
|
||||
public static String getAuthenticatedName(Context context,
|
||||
Recipient recipient,
|
||||
MasterSecret masterSecret)
|
||||
{
|
||||
SessionRecord session = new SessionRecord(context, masterSecret, recipient);
|
||||
return DatabaseFactory.getIdentityDatabase(context)
|
||||
.getNameForIdentity(masterSecret, session.getIdentityKey());
|
||||
}
|
||||
|
||||
public static boolean isAuthenticated(Context context,
|
||||
Recipient recipient,
|
||||
MasterSecret masterSecret)
|
||||
{
|
||||
SessionRecord session = new SessionRecord(context, masterSecret, recipient);
|
||||
|
||||
if (session.isVerifiedSession()) {
|
||||
return true;
|
||||
} else if (session.getIdentityKey() != null) {
|
||||
return isAuthenticatedIdentity(context, masterSecret, session.getIdentityKey());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package org.thoughtcrime.securesms.database.loaders;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.support.v4.content.AsyncTaskLoader;
|
||||
import android.support.v4.content.CursorLoader;
|
||||
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.IdentityDatabase;
|
||||
|
||||
public class IdentityLoader extends CursorLoader {
|
||||
|
||||
private final Context context;
|
||||
|
||||
public IdentityLoader(Context context) {
|
||||
super(context);
|
||||
this.context = context.getApplicationContext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cursor loadInBackground() {
|
||||
return DatabaseFactory.getIdentityDatabase(context).getIdentities();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue