mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-12-25 00:18:51 -05:00
enable nfc in import dialog as well
This commit is contained in:
parent
212bba1869
commit
2e838e4cce
@ -38,6 +38,7 @@ import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
|||||||
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.ui.base.BaseActivity;
|
import org.sufficientlysecure.keychain.ui.base.BaseActivity;
|
||||||
|
import org.sufficientlysecure.keychain.ui.base.BaseNfcActivity;
|
||||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||||
import org.sufficientlysecure.keychain.ui.util.Notify;
|
import org.sufficientlysecure.keychain.ui.util.Notify;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
@ -47,7 +48,8 @@ import org.sufficientlysecure.keychain.util.ParcelableFileCache.IteratorWithSize
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class ImportKeysActivity extends BaseActivity {
|
public class ImportKeysActivity extends BaseNfcActivity {
|
||||||
|
|
||||||
public static final String ACTION_IMPORT_KEY = OpenKeychainIntents.IMPORT_KEY;
|
public static final String ACTION_IMPORT_KEY = OpenKeychainIntents.IMPORT_KEY;
|
||||||
public static final String ACTION_IMPORT_KEY_FROM_KEYSERVER = OpenKeychainIntents.IMPORT_KEY_FROM_KEYSERVER;
|
public static final String ACTION_IMPORT_KEY_FROM_KEYSERVER = OpenKeychainIntents.IMPORT_KEY_FROM_KEYSERVER;
|
||||||
public static final String ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_RESULT =
|
public static final String ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_RESULT =
|
||||||
|
@ -559,7 +559,7 @@ public class ViewKeyActivity extends BaseNfcActivity implements
|
|||||||
CachedPublicKeyRing ring = mProviderHelper.getCachedPublicKeyRing(masterKeyId);
|
CachedPublicKeyRing ring = mProviderHelper.getCachedPublicKeyRing(masterKeyId);
|
||||||
ring.getMasterKeyId();
|
ring.getMasterKeyId();
|
||||||
|
|
||||||
Notify.create(this, "Different key stored on Yubikey!", Notify.LENGTH_LONG,
|
Notify.create(this, R.string.snack_yubi_other, Notify.LENGTH_LONG,
|
||||||
Style.WARN, new ActionListener() {
|
Style.WARN, new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onAction() {
|
public void onAction() {
|
||||||
@ -576,7 +576,7 @@ public class ViewKeyActivity extends BaseNfcActivity implements
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
} catch (PgpKeyNotFoundException e) {
|
} catch (PgpKeyNotFoundException e) {
|
||||||
Notify.create(this, "Different key stored on Yubikey!", Notify.LENGTH_LONG,
|
Notify.create(this, R.string.snack_yubi_other, Notify.LENGTH_LONG,
|
||||||
Style.WARN, new ActionListener() {
|
Style.WARN, new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onAction() {
|
public void onAction() {
|
||||||
|
@ -16,9 +16,20 @@ import android.widget.Toast;
|
|||||||
import org.spongycastle.bcpg.HashAlgorithmTags;
|
import org.spongycastle.bcpg.HashAlgorithmTags;
|
||||||
import org.spongycastle.util.encoders.Hex;
|
import org.spongycastle.util.encoders.Hex;
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
|
import org.sufficientlysecure.keychain.R;
|
||||||
|
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||||
|
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||||
|
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||||
|
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||||
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
|
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
|
||||||
|
import org.sufficientlysecure.keychain.ui.CreateKeyActivity;
|
||||||
import org.sufficientlysecure.keychain.ui.PassphraseDialogActivity;
|
import org.sufficientlysecure.keychain.ui.PassphraseDialogActivity;
|
||||||
|
import org.sufficientlysecure.keychain.ui.ViewKeyActivity;
|
||||||
|
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||||
|
import org.sufficientlysecure.keychain.ui.util.Notify;
|
||||||
|
import org.sufficientlysecure.keychain.ui.util.Notify.ActionListener;
|
||||||
|
import org.sufficientlysecure.keychain.ui.util.Notify.Style;
|
||||||
import org.sufficientlysecure.keychain.util.Iso7816TLV;
|
import org.sufficientlysecure.keychain.util.Iso7816TLV;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
import org.sufficientlysecure.keychain.util.Passphrase;
|
import org.sufficientlysecure.keychain.util.Passphrase;
|
||||||
@ -190,7 +201,38 @@ public abstract class BaseNfcActivity extends BaseActivity {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void onNfcPerform() throws IOException;
|
protected void onNfcPerform() throws IOException {
|
||||||
|
|
||||||
|
final byte[] nfcFingerprints = nfcGetFingerprints();
|
||||||
|
final String nfcUserId = nfcGetUserId();
|
||||||
|
final byte[] nfcAid = nfcGetAid();
|
||||||
|
|
||||||
|
String fp = KeyFormattingUtils.convertFingerprintToHex(nfcFingerprints);
|
||||||
|
final long masterKeyId = KeyFormattingUtils.getKeyIdFromFingerprint(nfcFingerprints);
|
||||||
|
|
||||||
|
try {
|
||||||
|
CachedPublicKeyRing ring = new ProviderHelper(this).getCachedPublicKeyRing(masterKeyId);
|
||||||
|
ring.getMasterKeyId();
|
||||||
|
|
||||||
|
Intent intent = new Intent(
|
||||||
|
BaseNfcActivity.this, ViewKeyActivity.class);
|
||||||
|
intent.setData(KeyRings.buildGenericKeyRingUri(masterKeyId));
|
||||||
|
intent.putExtra(ViewKeyActivity.EXTRA_NFC_AID, nfcAid);
|
||||||
|
intent.putExtra(ViewKeyActivity.EXTRA_NFC_USER_ID, nfcUserId);
|
||||||
|
intent.putExtra(ViewKeyActivity.EXTRA_NFC_FINGERPRINTS, nfcFingerprints);
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
} catch (PgpKeyNotFoundException e) {
|
||||||
|
Intent intent = new Intent(
|
||||||
|
BaseNfcActivity.this, CreateKeyActivity.class);
|
||||||
|
intent.putExtra(CreateKeyActivity.EXTRA_NFC_AID, nfcAid);
|
||||||
|
intent.putExtra(CreateKeyActivity.EXTRA_NFC_USER_ID, nfcUserId);
|
||||||
|
intent.putExtra(CreateKeyActivity.EXTRA_NFC_FINGERPRINTS, nfcFingerprints);
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/** Return the key id from application specific data stored on tag, or null
|
/** Return the key id from application specific data stored on tag, or null
|
||||||
* if it doesn't exist.
|
* if it doesn't exist.
|
||||||
@ -242,7 +284,7 @@ public abstract class BaseNfcActivity extends BaseActivity {
|
|||||||
// return the master key fingerprint
|
// return the master key fingerprint
|
||||||
ByteBuffer fpbuf = ByteBuffer.wrap(data);
|
ByteBuffer fpbuf = ByteBuffer.wrap(data);
|
||||||
byte[] fp = new byte[20];
|
byte[] fp = new byte[20];
|
||||||
fpbuf.position(idx*20);
|
fpbuf.position(idx * 20);
|
||||||
fpbuf.get(fp, 0, 20);
|
fpbuf.get(fp, 0, 20);
|
||||||
|
|
||||||
return fp;
|
return fp;
|
||||||
|
@ -1273,9 +1273,10 @@
|
|||||||
<string name="yubikey_serno">"Serial No: %s"</string>
|
<string name="yubikey_serno">"Serial No: %s"</string>
|
||||||
<string name="yubikey_key_holder">"Key holder: "</string>
|
<string name="yubikey_key_holder">"Key holder: "</string>
|
||||||
<string name="yubikey_key_holder_unset">"Key holder: <unset>"</string>
|
<string name="yubikey_key_holder_unset">"Key holder: <unset>"</string>
|
||||||
<string name="yubikey_status_bound">"Yubikey matches, bound to key"</string>
|
<string name="yubikey_status_bound">"Yubikey matches and is bound to key"</string>
|
||||||
<string name="yubikey_status_unbound">"Yubikey matches, can be bound to key"</string>
|
<string name="yubikey_status_unbound">"Yubikey matches, can be bound to key"</string>
|
||||||
<string name="yubikey_status_partly">"Yubikey matches, partly bound to key"</string>
|
<string name="yubikey_status_partly">"Yubikey matches, partly bound to key"</string>
|
||||||
<string name="btn_import">"Import"</string>
|
<string name="btn_import">"Import"</string>
|
||||||
|
<string name="snack_yubi_other">Different key stored on Yubikey!</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user