fix linked id verification
This commit is contained in:
@@ -110,7 +110,6 @@ public class ViewKeyFragment extends LoaderFragment implements
|
|||||||
private ListView mLinkedIds;
|
private ListView mLinkedIds;
|
||||||
private CardView mLinkedIdsCard;
|
private CardView mLinkedIdsCard;
|
||||||
private TextView mLinkedIdsEmpty;
|
private TextView mLinkedIdsEmpty;
|
||||||
private byte[] mFingerprint;
|
|
||||||
private TextView mLinkedIdsExpander;
|
private TextView mLinkedIdsExpander;
|
||||||
|
|
||||||
KeyHealthCardView mKeyHealthCard;
|
KeyHealthCardView mKeyHealthCard;
|
||||||
@@ -198,7 +197,7 @@ public class ViewKeyFragment extends LoaderFragment implements
|
|||||||
private void showLinkedId(final int position) {
|
private void showLinkedId(final int position) {
|
||||||
final LinkedIdViewFragment frag;
|
final LinkedIdViewFragment frag;
|
||||||
try {
|
try {
|
||||||
frag = mLinkedIdsAdapter.getLinkedIdFragment(mDataUri, position, mFingerprint);
|
frag = mLinkedIdsAdapter.getLinkedIdFragment(mDataUri, position, mMasterKeyId);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(Constants.TAG, "IOException", e);
|
Log.e(Constants.TAG, "IOException", e);
|
||||||
return;
|
return;
|
||||||
@@ -516,9 +515,6 @@ public class ViewKeyFragment extends LoaderFragment implements
|
|||||||
mLinkedIdsAdapter.swapCursor(null);
|
mLinkedIdsAdapter.swapCursor(null);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LOADER_ID_SUBKEY_STATUS:
|
|
||||||
mKeyHealthPresenter.onLoaderReset(loader);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -189,14 +189,13 @@ public class LinkedIdsAdapter extends UserAttributesAdapter {
|
|||||||
UserIdsAdapter.USER_PACKETS_PROJECTION, LINKED_IDS_WHERE, null, null);
|
UserIdsAdapter.USER_PACKETS_PROJECTION, LINKED_IDS_WHERE, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LinkedIdViewFragment getLinkedIdFragment(Uri baseUri,
|
public LinkedIdViewFragment getLinkedIdFragment(Uri baseUri, int position, long masterKeyId) throws IOException {
|
||||||
int position, byte[] fingerprint) throws IOException {
|
|
||||||
Cursor c = getCursor();
|
Cursor c = getCursor();
|
||||||
c.moveToPosition(position);
|
c.moveToPosition(position);
|
||||||
int rank = c.getInt(UserIdsAdapter.INDEX_RANK);
|
int rank = c.getInt(UserIdsAdapter.INDEX_RANK);
|
||||||
|
|
||||||
Uri dataUri = UserPackets.buildLinkedIdsUri(baseUri);
|
Uri dataUri = UserPackets.buildLinkedIdsUri(baseUri);
|
||||||
return LinkedIdViewFragment.newInstance(dataUri, rank, mIsSecret, fingerprint);
|
return LinkedIdViewFragment.newInstance(dataUri, rank, mIsSecret, masterKeyId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ViewHolder {
|
public static class ViewHolder {
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import android.os.Bundle;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.v4.app.FragmentActivity;
|
||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
import android.support.v4.app.FragmentManager.OnBackStackChangedListener;
|
import android.support.v4.app.FragmentManager.OnBackStackChangedListener;
|
||||||
import android.support.v4.app.LoaderManager;
|
import android.support.v4.app.LoaderManager;
|
||||||
@@ -54,6 +55,8 @@ import org.sufficientlysecure.keychain.linked.LinkedAttribute;
|
|||||||
import org.sufficientlysecure.keychain.linked.LinkedResource;
|
import org.sufficientlysecure.keychain.linked.LinkedResource;
|
||||||
import org.sufficientlysecure.keychain.linked.UriAttribute;
|
import org.sufficientlysecure.keychain.linked.UriAttribute;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||||
|
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||||
|
import org.sufficientlysecure.keychain.provider.KeyRepository;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.Certs;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.Certs;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.UserPackets;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.UserPackets;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables;
|
import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables;
|
||||||
@@ -78,7 +81,7 @@ public class LinkedIdViewFragment extends CryptoOperationFragment implements
|
|||||||
private static final String ARG_DATA_URI = "data_uri";
|
private static final String ARG_DATA_URI = "data_uri";
|
||||||
private static final String ARG_LID_RANK = "rank";
|
private static final String ARG_LID_RANK = "rank";
|
||||||
private static final String ARG_IS_SECRET = "verified";
|
private static final String ARG_IS_SECRET = "verified";
|
||||||
private static final String ARG_FINGERPRINT = "fingerprint";
|
private static final String ARG_MASTER_KEY_ID = "master_key_id";
|
||||||
private static final int LOADER_ID_LINKED_ID = 1;
|
private static final int LOADER_ID_LINKED_ID = 1;
|
||||||
|
|
||||||
private UriAttribute mLinkedId;
|
private UriAttribute mLinkedId;
|
||||||
@@ -86,7 +89,7 @@ public class LinkedIdViewFragment extends CryptoOperationFragment implements
|
|||||||
private boolean mIsSecret;
|
private boolean mIsSecret;
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private byte[] mFingerprint;
|
private long mMasterKeyId;
|
||||||
|
|
||||||
private AsyncTask mInProgress;
|
private AsyncTask mInProgress;
|
||||||
|
|
||||||
@@ -97,14 +100,14 @@ public class LinkedIdViewFragment extends CryptoOperationFragment implements
|
|||||||
private long mCertifyKeyId;
|
private long mCertifyKeyId;
|
||||||
|
|
||||||
public static LinkedIdViewFragment newInstance(Uri dataUri, int rank,
|
public static LinkedIdViewFragment newInstance(Uri dataUri, int rank,
|
||||||
boolean isSecret, byte[] fingerprint) throws IOException {
|
boolean isSecret, long masterKeyId) throws IOException {
|
||||||
LinkedIdViewFragment frag = new LinkedIdViewFragment();
|
LinkedIdViewFragment frag = new LinkedIdViewFragment();
|
||||||
|
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putParcelable(ARG_DATA_URI, dataUri);
|
args.putParcelable(ARG_DATA_URI, dataUri);
|
||||||
args.putInt(ARG_LID_RANK, rank);
|
args.putInt(ARG_LID_RANK, rank);
|
||||||
args.putBoolean(ARG_IS_SECRET, isSecret);
|
args.putBoolean(ARG_IS_SECRET, isSecret);
|
||||||
args.putByteArray(ARG_FINGERPRINT, fingerprint);
|
args.putLong(ARG_MASTER_KEY_ID, masterKeyId);
|
||||||
frag.setArguments(args);
|
frag.setArguments(args);
|
||||||
|
|
||||||
return frag;
|
return frag;
|
||||||
@@ -125,7 +128,7 @@ public class LinkedIdViewFragment extends CryptoOperationFragment implements
|
|||||||
mLidRank = args.getInt(ARG_LID_RANK);
|
mLidRank = args.getInt(ARG_LID_RANK);
|
||||||
|
|
||||||
mIsSecret = args.getBoolean(ARG_IS_SECRET);
|
mIsSecret = args.getBoolean(ARG_IS_SECRET);
|
||||||
mFingerprint = args.getByteArray(ARG_FINGERPRINT);
|
mMasterKeyId = args.getLong(ARG_MASTER_KEY_ID);
|
||||||
|
|
||||||
mContext = getActivity();
|
mContext = getActivity();
|
||||||
|
|
||||||
@@ -477,8 +480,18 @@ public class LinkedIdViewFragment extends CryptoOperationFragment implements
|
|||||||
mInProgress = new AsyncTask<Void,Void,LinkedVerifyResult>() {
|
mInProgress = new AsyncTask<Void,Void,LinkedVerifyResult>() {
|
||||||
@Override
|
@Override
|
||||||
protected LinkedVerifyResult doInBackground(Void... params) {
|
protected LinkedVerifyResult doInBackground(Void... params) {
|
||||||
|
FragmentActivity activity = getActivity();
|
||||||
|
|
||||||
|
byte[] fingerprint;
|
||||||
|
try {
|
||||||
|
fingerprint = KeyRepository.createDatabaseInteractor(activity).getCachedPublicKeyRing(
|
||||||
|
mMasterKeyId).getFingerprint();
|
||||||
|
} catch (PgpKeyNotFoundException e) {
|
||||||
|
throw new IllegalStateException("Key to verify linked id for must exist in db!");
|
||||||
|
}
|
||||||
|
|
||||||
long timer = System.currentTimeMillis();
|
long timer = System.currentTimeMillis();
|
||||||
LinkedVerifyResult result = mLinkedResource.verify(getActivity(), mFingerprint);
|
LinkedVerifyResult result = mLinkedResource.verify(activity, fingerprint);
|
||||||
|
|
||||||
// ux flow: this operation should take at last a second
|
// ux flow: this operation should take at last a second
|
||||||
timer = System.currentTimeMillis() -timer;
|
timer = System.currentTimeMillis() -timer;
|
||||||
@@ -547,8 +560,7 @@ public class LinkedIdViewFragment extends CryptoOperationFragment implements
|
|||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public Parcelable createOperationInput() {
|
public Parcelable createOperationInput() {
|
||||||
long masterKeyId = KeyFormattingUtils.convertFingerprintToKeyId(mFingerprint);
|
CertifyAction action = new CertifyAction(mMasterKeyId, null,
|
||||||
CertifyAction action = new CertifyAction(masterKeyId, null,
|
|
||||||
Collections.singletonList(mLinkedId.toUserAttribute()));
|
Collections.singletonList(mLinkedId.toUserAttribute()));
|
||||||
|
|
||||||
// fill values for this action
|
// fill values for this action
|
||||||
|
|||||||
Reference in New Issue
Block a user