mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-16 05:45:04 -05:00
Merge branch 'jacobshack-certify' of github.com:open-keychain/open-keychain into jacobshack-certify
This commit is contained in:
commit
84c624517c
@ -73,7 +73,10 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
|||||||
}
|
}
|
||||||
dest.writeString(mFingerprintHex);
|
dest.writeString(mFingerprintHex);
|
||||||
dest.writeString(mKeyIdHex);
|
dest.writeString(mKeyIdHex);
|
||||||
dest.writeInt(mBitStrength);
|
dest.writeInt(mBitStrength == null ? 0 : 1);
|
||||||
|
if (mBitStrength != null) {
|
||||||
|
dest.writeInt(mBitStrength);
|
||||||
|
}
|
||||||
dest.writeString(mAlgorithm);
|
dest.writeString(mAlgorithm);
|
||||||
dest.writeByte((byte) (mSecretKey ? 1 : 0));
|
dest.writeByte((byte) (mSecretKey ? 1 : 0));
|
||||||
dest.writeByte((byte) (mSelected ? 1 : 0));
|
dest.writeByte((byte) (mSelected ? 1 : 0));
|
||||||
@ -94,7 +97,7 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
|||||||
vr.mDate = source.readInt() != 0 ? new Date(source.readLong()) : null;
|
vr.mDate = source.readInt() != 0 ? new Date(source.readLong()) : null;
|
||||||
vr.mFingerprintHex = source.readString();
|
vr.mFingerprintHex = source.readString();
|
||||||
vr.mKeyIdHex = source.readString();
|
vr.mKeyIdHex = source.readString();
|
||||||
vr.mBitStrength = source.readInt();
|
vr.mBitStrength = source.readInt() != 0 ? source.readInt() : null;
|
||||||
vr.mAlgorithm = source.readString();
|
vr.mAlgorithm = source.readString();
|
||||||
vr.mSecretKey = source.readByte() == 1;
|
vr.mSecretKey = source.readByte() == 1;
|
||||||
vr.mSelected = source.readByte() == 1;
|
vr.mSelected = source.readByte() == 1;
|
||||||
|
@ -81,7 +81,9 @@ public class AddKeysActivity extends ActionBarActivity implements
|
|||||||
|
|
||||||
byte[] mImportBytes;
|
byte[] mImportBytes;
|
||||||
|
|
||||||
private static final int REQUEST_CODE_SAFE_SLINGER = 1;
|
private static final int REQUEST_CODE_RESULT = 0;
|
||||||
|
private static final int REQUEST_CODE_RESULT_TO_LIST = 1;
|
||||||
|
private static final int REQUEST_CODE_SAFE_SLINGER = 2;
|
||||||
|
|
||||||
private static final int LOADER_ID_BYTES = 0;
|
private static final int LOADER_ID_BYTES = 0;
|
||||||
|
|
||||||
@ -130,7 +132,7 @@ public class AddKeysActivity extends ActionBarActivity implements
|
|||||||
// show nfc help
|
// show nfc help
|
||||||
Intent intent = new Intent(AddKeysActivity.this, HelpActivity.class);
|
Intent intent = new Intent(AddKeysActivity.this, HelpActivity.class);
|
||||||
intent.putExtra(HelpActivity.EXTRA_SELECTED_TAB, HelpActivity.TAB_NFC);
|
intent.putExtra(HelpActivity.EXTRA_SELECTED_TAB, HelpActivity.TAB_NFC);
|
||||||
startActivityForResult(intent, 0);
|
startActivityForResult(intent, REQUEST_CODE_RESULT);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -177,55 +179,62 @@ public class AddKeysActivity extends ActionBarActivity implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
// if a result has been returned, display a notify
|
switch (requestCode) {
|
||||||
if (data != null && data.hasExtra(OperationResult.EXTRA_RESULT)) {
|
case REQUEST_CODE_RESULT: {
|
||||||
OperationResult result = data.getParcelableExtra(OperationResult.EXTRA_RESULT);
|
if (data != null && data.hasExtra(OperationResult.EXTRA_RESULT)) {
|
||||||
result.createNotify(this).show();
|
OperationResult result = data.getParcelableExtra(OperationResult.EXTRA_RESULT);
|
||||||
} else {
|
result.createNotify(this).show();
|
||||||
switch (requestCode) {
|
|
||||||
case REQUEST_CODE_SAFE_SLINGER: {
|
|
||||||
switch (resultCode) {
|
|
||||||
case ExchangeActivity.RESULT_EXCHANGE_OK:
|
|
||||||
// import exchanged keys
|
|
||||||
mImportBytes = getSlingedKeys(data);
|
|
||||||
getSupportLoaderManager().restartLoader(LOADER_ID_BYTES, null, this);
|
|
||||||
break;
|
|
||||||
case ExchangeActivity.RESULT_EXCHANGE_CANCELED:
|
|
||||||
// do nothing
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case IntentIntegratorSupportV4.REQUEST_CODE: {
|
|
||||||
IntentResult scanResult = IntentIntegratorSupportV4.parseActivityResult(requestCode,
|
|
||||||
resultCode, data);
|
|
||||||
if (scanResult != null && scanResult.getFormatName() != null) {
|
|
||||||
String scannedContent = scanResult.getContents();
|
|
||||||
|
|
||||||
Log.d(Constants.TAG, "scannedContent: " + scannedContent);
|
|
||||||
|
|
||||||
// look if it's fingerprint only
|
|
||||||
if (scannedContent.toLowerCase(Locale.ENGLISH).startsWith(Constants.FINGERPRINT_SCHEME)) {
|
|
||||||
importKeys(null, getFingerprintFromUri(Uri.parse(scanResult.getContents())));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// is this a full key encoded as qr code?
|
|
||||||
if (scannedContent.startsWith("-----BEGIN PGP")) {
|
|
||||||
// TODO
|
|
||||||
// mImportActivity.loadCallback(new ImportKeysListFragment.BytesLoaderState(scannedContent.getBytes(), null));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// fail...
|
|
||||||
Notify.showNotify(this, R.string.import_qr_code_wrong, Notify.Style.ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case REQUEST_CODE_RESULT_TO_LIST: {
|
||||||
|
// give it down...
|
||||||
|
setResult(0, data);
|
||||||
|
finish();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case REQUEST_CODE_SAFE_SLINGER: {
|
||||||
|
switch (resultCode) {
|
||||||
|
case ExchangeActivity.RESULT_EXCHANGE_OK:
|
||||||
|
// import exchanged keys
|
||||||
|
mImportBytes = getSlingedKeys(data);
|
||||||
|
getSupportLoaderManager().restartLoader(LOADER_ID_BYTES, null, this);
|
||||||
|
break;
|
||||||
|
case ExchangeActivity.RESULT_EXCHANGE_CANCELED:
|
||||||
|
// do nothing
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case IntentIntegratorSupportV4.REQUEST_CODE: {
|
||||||
|
IntentResult scanResult = IntentIntegratorSupportV4.parseActivityResult(requestCode,
|
||||||
|
resultCode, data);
|
||||||
|
if (scanResult != null && scanResult.getFormatName() != null) {
|
||||||
|
String scannedContent = scanResult.getContents();
|
||||||
|
|
||||||
|
Log.d(Constants.TAG, "scannedContent: " + scannedContent);
|
||||||
|
|
||||||
|
// look if it's fingerprint only
|
||||||
|
if (scannedContent.toLowerCase(Locale.ENGLISH).startsWith(Constants.FINGERPRINT_SCHEME)) {
|
||||||
|
importKeys(null, getFingerprintFromUri(Uri.parse(scanResult.getContents())));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// is this a full key encoded as qr code?
|
||||||
|
if (scannedContent.startsWith("-----BEGIN PGP")) {
|
||||||
|
// TODO
|
||||||
|
// mImportActivity.loadCallback(new ImportKeysListFragment.BytesLoaderState(scannedContent.getBytes(), null));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// fail...
|
||||||
|
Notify.showNotify(this, R.string.import_qr_code_wrong, Notify.Style.ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
|
||||||
}
|
}
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getFingerprintFromUri(Uri dataUri) {
|
private String getFingerprintFromUri(Uri dataUri) {
|
||||||
@ -383,14 +392,11 @@ public class AddKeysActivity extends ActionBarActivity implements
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
finish();
|
|
||||||
Intent certifyIntent = new Intent(AddKeysActivity.this, MultiCertifyKeyActivity.class);
|
Intent certifyIntent = new Intent(AddKeysActivity.this, MultiCertifyKeyActivity.class);
|
||||||
certifyIntent.putExtra(MultiCertifyKeyActivity.EXTRA_RESULT, result);
|
certifyIntent.putExtra(MultiCertifyKeyActivity.EXTRA_RESULT, result);
|
||||||
certifyIntent.putExtra(MultiCertifyKeyActivity.EXTRA_KEY_IDS, result.getImportedMasterKeyIds());
|
certifyIntent.putExtra(MultiCertifyKeyActivity.EXTRA_KEY_IDS, result.getImportedMasterKeyIds());
|
||||||
certifyIntent.putExtra(MultiCertifyKeyActivity.EXTRA_CERTIFY_KEY_ID, mExchangeMasterKeyId);
|
certifyIntent.putExtra(MultiCertifyKeyActivity.EXTRA_CERTIFY_KEY_ID, mExchangeMasterKeyId);
|
||||||
startActivity(certifyIntent);
|
startActivityForResult(certifyIntent, REQUEST_CODE_RESULT_TO_LIST);
|
||||||
|
|
||||||
result.createNotify(AddKeysActivity.this).show();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -449,7 +455,6 @@ public class AddKeysActivity extends ActionBarActivity implements
|
|||||||
|
|
||||||
final ImportKeysListEntry keyEntry = new ImportKeysListEntry();
|
final ImportKeysListEntry keyEntry = new ImportKeysListEntry();
|
||||||
keyEntry.setFingerprintHex(fingerprint);
|
keyEntry.setFingerprintHex(fingerprint);
|
||||||
keyEntry.setBitStrength(1337); // TODO: make optional!
|
|
||||||
keyEntry.addOrigin(cloudPrefs.keyserver);
|
keyEntry.addOrigin(cloudPrefs.keyserver);
|
||||||
ArrayList<ImportKeysListEntry> selectedEntries = new ArrayList<ImportKeysListEntry>();
|
ArrayList<ImportKeysListEntry> selectedEntries = new ArrayList<ImportKeysListEntry>();
|
||||||
selectedEntries.add(keyEntry);
|
selectedEntries.add(keyEntry);
|
||||||
|
@ -28,16 +28,16 @@ import android.view.MenuItem;
|
|||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.util.ExportHelper;
|
|
||||||
import org.sufficientlysecure.keychain.util.Preferences;
|
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainDatabase;
|
import org.sufficientlysecure.keychain.provider.KeychainDatabase;
|
||||||
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
||||||
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResult;
|
|
||||||
import org.sufficientlysecure.keychain.service.results.ConsolidateResult;
|
import org.sufficientlysecure.keychain.service.results.ConsolidateResult;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.service.results.OperationResult;
|
||||||
import org.sufficientlysecure.keychain.ui.util.Notify;
|
import org.sufficientlysecure.keychain.ui.util.Notify;
|
||||||
|
import org.sufficientlysecure.keychain.util.ExportHelper;
|
||||||
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
import org.sufficientlysecure.keychain.util.Preferences;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@ -59,7 +59,6 @@ public class KeyUpdateHelper {
|
|||||||
for (String fprint : providerHelper.getAllFingerprints(KeychainContract.KeyRings.buildUnifiedKeyRingsUri())) {
|
for (String fprint : providerHelper.getAllFingerprints(KeychainContract.KeyRings.buildUnifiedKeyRingsUri())) {
|
||||||
ImportKeysListEntry key = new ImportKeysListEntry();
|
ImportKeysListEntry key = new ImportKeysListEntry();
|
||||||
key.setFingerprintHex(fprint);
|
key.setFingerprintHex(fprint);
|
||||||
key.setBitStrength(1337);
|
|
||||||
key.addOrigin(servers[0]);
|
key.addOrigin(servers[0]);
|
||||||
keys.add(key);
|
keys.add(key);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user