Merge pull request #2160 from open-keychain/remove-move-to-card
remove "Move to Card" action from subkey edit ui
This commit is contained in:
@@ -17,6 +17,9 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.ui;
|
package org.sufficientlysecure.keychain.ui;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
@@ -35,9 +38,6 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
|
||||||
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
|
|
||||||
import org.bouncycastle.asn1.nist.NISTNamedCurves;
|
|
||||||
import org.bouncycastle.bcpg.PublicKeyAlgorithmTags;
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround;
|
import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround;
|
||||||
@@ -49,9 +49,9 @@ import org.sufficientlysecure.keychain.pgp.KeyRing;
|
|||||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||||
import org.sufficientlysecure.keychain.provider.KeyRepository;
|
import org.sufficientlysecure.keychain.provider.KeyRepository;
|
||||||
|
import org.sufficientlysecure.keychain.provider.KeyRepository.NotFoundException;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.UserPackets;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.UserPackets;
|
||||||
import org.sufficientlysecure.keychain.provider.KeyRepository.NotFoundException;
|
|
||||||
import org.sufficientlysecure.keychain.service.ChangeUnlockParcel;
|
import org.sufficientlysecure.keychain.service.ChangeUnlockParcel;
|
||||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
||||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.SubkeyChange;
|
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.SubkeyChange;
|
||||||
@@ -71,8 +71,6 @@ import org.sufficientlysecure.keychain.ui.util.Notify;
|
|||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
import org.sufficientlysecure.keychain.util.Passphrase;
|
import org.sufficientlysecure.keychain.util.Passphrase;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public class EditKeyFragment extends QueueingCryptoOperationFragment<SaveKeyringParcel, OperationResult>
|
public class EditKeyFragment extends QueueingCryptoOperationFragment<SaveKeyringParcel, OperationResult>
|
||||||
implements LoaderManager.LoaderCallbacks<Cursor> {
|
implements LoaderManager.LoaderCallbacks<Cursor> {
|
||||||
|
|
||||||
@@ -438,52 +436,6 @@ public class EditKeyFragment extends QueueingCryptoOperationFragment<SaveKeyring
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EditSubkeyDialogFragment.MESSAGE_MOVE_KEY_TO_SECURITY_TOKEN: {
|
|
||||||
SecretKeyType secretKeyType = mSubkeysAdapter.getSecretKeyType(position);
|
|
||||||
if (secretKeyType == SecretKeyType.DIVERT_TO_CARD ||
|
|
||||||
secretKeyType == SecretKeyType.GNU_DUMMY) {
|
|
||||||
Notify.create(getActivity(), R.string.edit_key_error_bad_security_token_stripped, Notify.Style.ERROR)
|
|
||||||
.show();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (mSubkeysAdapter.getAlgorithm(position)) {
|
|
||||||
case PublicKeyAlgorithmTags.RSA_GENERAL:
|
|
||||||
case PublicKeyAlgorithmTags.RSA_ENCRYPT:
|
|
||||||
case PublicKeyAlgorithmTags.RSA_SIGN:
|
|
||||||
if (mSubkeysAdapter.getKeySize(position) < 2048) {
|
|
||||||
Notify.create(getActivity(), R.string.edit_key_error_bad_security_token_size, Notify.Style.ERROR)
|
|
||||||
.show();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PublicKeyAlgorithmTags.ECDH:
|
|
||||||
case PublicKeyAlgorithmTags.ECDSA:
|
|
||||||
final ASN1ObjectIdentifier curve = NISTNamedCurves.getOID(mSubkeysAdapter.getCurveOid(position));
|
|
||||||
if (!curve.equals(NISTNamedCurves.getByName("P-256")) &&
|
|
||||||
!curve.equals(NISTNamedCurves.getByName("P-384")) &&
|
|
||||||
!curve.equals(NISTNamedCurves.getByName("P-521"))) {
|
|
||||||
Notify.create(getActivity(), R.string.edit_key_error_bad_security_token_curve, Notify.Style.ERROR)
|
|
||||||
.show();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
Notify.create(getActivity(), R.string.edit_key_error_bad_security_token_algo, Notify.Style.ERROR)
|
|
||||||
.show();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
SubkeyChange change = mSkpBuilder.getSubkeyChange(keyId);
|
|
||||||
if (change == null || !change.getMoveKeyToSecurityToken()) {
|
|
||||||
mSkpBuilder.addOrReplaceSubkeyChange(
|
|
||||||
SubkeyChange.createMoveToSecurityTokenChange(keyId));
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
mSkpBuilder.removeSubkeyChange(change);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
getLoaderManager().getLoader(LOADER_ID_SUBKEYS).forceLoad();
|
getLoaderManager().getLoader(LOADER_ID_SUBKEYS).forceLoad();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.ui;
|
package org.sufficientlysecure.keychain.ui;
|
||||||
|
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
@@ -38,9 +39,6 @@ import android.widget.AdapterView;
|
|||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.ViewAnimator;
|
import android.widget.ViewAnimator;
|
||||||
|
|
||||||
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
|
|
||||||
import org.bouncycastle.asn1.nist.NISTNamedCurves;
|
|
||||||
import org.bouncycastle.bcpg.PublicKeyAlgorithmTags;
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround;
|
import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround;
|
||||||
@@ -56,7 +54,6 @@ import org.sufficientlysecure.keychain.ui.base.LoaderFragment;
|
|||||||
import org.sufficientlysecure.keychain.ui.dialog.AddSubkeyDialogFragment;
|
import org.sufficientlysecure.keychain.ui.dialog.AddSubkeyDialogFragment;
|
||||||
import org.sufficientlysecure.keychain.ui.dialog.EditSubkeyDialogFragment;
|
import org.sufficientlysecure.keychain.ui.dialog.EditSubkeyDialogFragment;
|
||||||
import org.sufficientlysecure.keychain.ui.dialog.EditSubkeyExpiryDialogFragment;
|
import org.sufficientlysecure.keychain.ui.dialog.EditSubkeyExpiryDialogFragment;
|
||||||
import org.sufficientlysecure.keychain.ui.util.Notify;
|
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
|
||||||
public class ViewKeyAdvSubkeysFragment extends LoaderFragment implements
|
public class ViewKeyAdvSubkeysFragment extends LoaderFragment implements
|
||||||
@@ -344,51 +341,6 @@ public class ViewKeyAdvSubkeysFragment extends LoaderFragment implements
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EditSubkeyDialogFragment.MESSAGE_MOVE_KEY_TO_SECURITY_TOKEN: {
|
|
||||||
SecretKeyType secretKeyType = mSubkeysAdapter.getSecretKeyType(position);
|
|
||||||
if (secretKeyType == SecretKeyType.DIVERT_TO_CARD ||
|
|
||||||
secretKeyType == SecretKeyType.GNU_DUMMY) {
|
|
||||||
Notify.create(getActivity(), R.string.edit_key_error_bad_security_token_stripped, Notify.Style.ERROR)
|
|
||||||
.show();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (mSubkeysAdapter.getAlgorithm(position)) {
|
|
||||||
case PublicKeyAlgorithmTags.RSA_GENERAL:
|
|
||||||
case PublicKeyAlgorithmTags.RSA_ENCRYPT:
|
|
||||||
case PublicKeyAlgorithmTags.RSA_SIGN:
|
|
||||||
if (mSubkeysAdapter.getKeySize(position) < 2048) {
|
|
||||||
Notify.create(getActivity(), R.string.edit_key_error_bad_security_token_size, Notify.Style.ERROR)
|
|
||||||
.show();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PublicKeyAlgorithmTags.ECDH:
|
|
||||||
case PublicKeyAlgorithmTags.ECDSA:
|
|
||||||
final ASN1ObjectIdentifier curve = NISTNamedCurves.getOID(mSubkeysAdapter.getCurveOid(position));
|
|
||||||
if (!curve.equals(NISTNamedCurves.getOID("P-256")) &&
|
|
||||||
!curve.equals(NISTNamedCurves.getOID("P-384")) &&
|
|
||||||
!curve.equals(NISTNamedCurves.getOID("P-521"))) {
|
|
||||||
Notify.create(getActivity(), R.string.edit_key_error_bad_security_token_curve, Notify.Style.ERROR)
|
|
||||||
.show();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
Notify.create(getActivity(), R.string.edit_key_error_bad_security_token_algo, Notify.Style.ERROR)
|
|
||||||
.show();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
SubkeyChange change = mEditModeSkpBuilder.getSubkeyChange(keyId);
|
|
||||||
if (change == null || !change.getMoveKeyToSecurityToken()) {
|
|
||||||
mEditModeSkpBuilder.addOrReplaceSubkeyChange(
|
|
||||||
SubkeyChange.createMoveToSecurityTokenChange(keyId));
|
|
||||||
} else {
|
|
||||||
mEditModeSkpBuilder.removeSubkeyChange(change);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
getLoaderManager().getLoader(LOADER_ID_SUBKEYS).forceLoad();
|
getLoaderManager().getLoader(LOADER_ID_SUBKEYS).forceLoad();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,11 +35,9 @@ public class EditSubkeyDialogFragment extends DialogFragment {
|
|||||||
public static final int MESSAGE_CHANGE_EXPIRY = 1;
|
public static final int MESSAGE_CHANGE_EXPIRY = 1;
|
||||||
public static final int MESSAGE_REVOKE = 2;
|
public static final int MESSAGE_REVOKE = 2;
|
||||||
public static final int MESSAGE_STRIP = 3;
|
public static final int MESSAGE_STRIP = 3;
|
||||||
public static final int MESSAGE_MOVE_KEY_TO_SECURITY_TOKEN = 4;
|
|
||||||
public static final int SUBKEY_MENU_CHANGE_EXPIRY = 0;
|
public static final int SUBKEY_MENU_CHANGE_EXPIRY = 0;
|
||||||
public static final int SUBKEY_MENU_REVOKE_SUBKEY = 1;
|
public static final int SUBKEY_MENU_REVOKE_SUBKEY = 1;
|
||||||
public static final int SUBKEY_MENU_STRIP_SUBKEY = 2;
|
public static final int SUBKEY_MENU_STRIP_SUBKEY = 2;
|
||||||
public static final int SUBKEY_MENU_MOVE_TO_SECURITY_TOKEN = 3;
|
|
||||||
|
|
||||||
private Messenger mMessenger;
|
private Messenger mMessenger;
|
||||||
|
|
||||||
@@ -81,9 +79,6 @@ public class EditSubkeyDialogFragment extends DialogFragment {
|
|||||||
case SUBKEY_MENU_STRIP_SUBKEY:
|
case SUBKEY_MENU_STRIP_SUBKEY:
|
||||||
showAlertDialog();
|
showAlertDialog();
|
||||||
break;
|
break;
|
||||||
case SUBKEY_MENU_MOVE_TO_SECURITY_TOKEN:
|
|
||||||
sendMessageToHandler(MESSAGE_MOVE_KEY_TO_SECURITY_TOKEN, null);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -779,7 +779,6 @@
|
|||||||
<item>"Change Expiry"</item>
|
<item>"Change Expiry"</item>
|
||||||
<item>"Revoke Subkey"</item>
|
<item>"Revoke Subkey"</item>
|
||||||
<item>"Strip Subkey"</item>
|
<item>"Strip Subkey"</item>
|
||||||
<item>"Move Subkey to Security Token"</item>
|
|
||||||
</string-array>
|
</string-array>
|
||||||
<string name="edit_key_new_subkey">"new subkey"</string>
|
<string name="edit_key_new_subkey">"new subkey"</string>
|
||||||
<string name="edit_key_select_usage">"Please select key usage!"</string>
|
<string name="edit_key_select_usage">"Please select key usage!"</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user