mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-12-25 00:18:51 -05:00
SaveKeyringParcel: follow attribute m prefix coding guideline
This commit is contained in:
parent
bb92fe2804
commit
1436ab8d90
@ -49,16 +49,16 @@ public class PgpKeyOperationTest {
|
|||||||
|
|
||||||
@BeforeClass public static void setUpOnce() throws Exception {
|
@BeforeClass public static void setUpOnce() throws Exception {
|
||||||
SaveKeyringParcel parcel = new SaveKeyringParcel();
|
SaveKeyringParcel parcel = new SaveKeyringParcel();
|
||||||
parcel.addSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
||||||
Constants.choice.algorithm.rsa, 1024, KeyFlags.CERTIFY_OTHER, null));
|
Constants.choice.algorithm.rsa, 1024, KeyFlags.CERTIFY_OTHER, null));
|
||||||
parcel.addSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
||||||
Constants.choice.algorithm.rsa, 1024, KeyFlags.SIGN_DATA, null));
|
Constants.choice.algorithm.rsa, 1024, KeyFlags.SIGN_DATA, null));
|
||||||
parcel.addSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
||||||
Constants.choice.algorithm.rsa, 1024, KeyFlags.ENCRYPT_COMMS, null));
|
Constants.choice.algorithm.rsa, 1024, KeyFlags.ENCRYPT_COMMS, null));
|
||||||
|
|
||||||
parcel.addUserIds.add("twi");
|
parcel.mAddUserIds.add("twi");
|
||||||
parcel.addUserIds.add("pink");
|
parcel.mAddUserIds.add("pink");
|
||||||
parcel.newPassphrase = "swag";
|
parcel.mNewPassphrase = "swag";
|
||||||
PgpKeyOperation op = new PgpKeyOperation(null);
|
PgpKeyOperation op = new PgpKeyOperation(null);
|
||||||
|
|
||||||
OperationResultParcel.OperationLog log = new OperationResultParcel.OperationLog();
|
OperationResultParcel.OperationLog log = new OperationResultParcel.OperationLog();
|
||||||
@ -85,9 +85,9 @@ public class PgpKeyOperationTest {
|
|||||||
// subkey binding certificates
|
// subkey binding certificates
|
||||||
public void testMasterFlags() throws Exception {
|
public void testMasterFlags() throws Exception {
|
||||||
SaveKeyringParcel parcel = new SaveKeyringParcel();
|
SaveKeyringParcel parcel = new SaveKeyringParcel();
|
||||||
parcel.addSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
|
||||||
Constants.choice.algorithm.rsa, 1024, KeyFlags.CERTIFY_OTHER | KeyFlags.SIGN_DATA, null));
|
Constants.choice.algorithm.rsa, 1024, KeyFlags.CERTIFY_OTHER | KeyFlags.SIGN_DATA, null));
|
||||||
parcel.addUserIds.add("luna");
|
parcel.mAddUserIds.add("luna");
|
||||||
OperationResultParcel.OperationLog log = new OperationResultParcel.OperationLog();
|
OperationResultParcel.OperationLog log = new OperationResultParcel.OperationLog();
|
||||||
ring = op.createSecretKeyRing(parcel, log, 0);
|
ring = op.createSecretKeyRing(parcel, log, 0);
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ public class PgpKeyOperationTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testSubkeyAdd() throws Exception {
|
public void testSubkeyAdd() throws Exception {
|
||||||
|
|
||||||
parcel.addSubKeys.add(new SubkeyAdd(algorithm.rsa, 1024, KeyFlags.SIGN_DATA, null));
|
parcel.mAddSubKeys.add(new SubkeyAdd(algorithm.rsa, 1024, KeyFlags.SIGN_DATA, null));
|
||||||
|
|
||||||
applyModificationWithChecks(parcel, ring, onlyA, onlyB);
|
applyModificationWithChecks(parcel, ring, onlyA, onlyB);
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ public class PgpKeyOperationTest {
|
|||||||
{
|
{
|
||||||
Iterator<UncachedPublicKey> it = ring.getPublicKeys();
|
Iterator<UncachedPublicKey> it = ring.getPublicKeys();
|
||||||
it.next();
|
it.next();
|
||||||
parcel.revokeSubKeys.add(it.next().getKeyId());
|
parcel.mRevokeSubKeys.add(it.next().getKeyId());
|
||||||
}
|
}
|
||||||
|
|
||||||
applyModificationWithChecks(parcel, ring, onlyA, onlyB);
|
applyModificationWithChecks(parcel, ring, onlyA, onlyB);
|
||||||
@ -199,7 +199,7 @@ public class PgpKeyOperationTest {
|
|||||||
|
|
||||||
{ // revoke second user id
|
{ // revoke second user id
|
||||||
|
|
||||||
parcel.revokeUserIds.add(uid);
|
parcel.mRevokeUserIds.add(uid);
|
||||||
|
|
||||||
modified = applyModificationWithChecks(parcel, ring, onlyA, onlyB);
|
modified = applyModificationWithChecks(parcel, ring, onlyA, onlyB);
|
||||||
|
|
||||||
@ -221,7 +221,7 @@ public class PgpKeyOperationTest {
|
|||||||
{ // re-add second user id
|
{ // re-add second user id
|
||||||
// new parcel
|
// new parcel
|
||||||
parcel.reset();
|
parcel.reset();
|
||||||
parcel.addUserIds.add(uid);
|
parcel.mAddUserIds.add(uid);
|
||||||
|
|
||||||
applyModificationWithChecks(parcel, modified, onlyA, onlyB, true, false);
|
applyModificationWithChecks(parcel, modified, onlyA, onlyB, true, false);
|
||||||
|
|
||||||
@ -257,7 +257,7 @@ public class PgpKeyOperationTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testUserIdAdd() throws Exception {
|
public void testUserIdAdd() throws Exception {
|
||||||
|
|
||||||
parcel.addUserIds.add("rainbow");
|
parcel.mAddUserIds.add("rainbow");
|
||||||
|
|
||||||
UncachedKeyRing modified = applyModificationWithChecks(parcel, ring, onlyA, onlyB);
|
UncachedKeyRing modified = applyModificationWithChecks(parcel, ring, onlyA, onlyB);
|
||||||
|
|
||||||
@ -293,8 +293,8 @@ public class PgpKeyOperationTest {
|
|||||||
String uid = ring.getPublicKey().getUnorderedUserIds().get(1);
|
String uid = ring.getPublicKey().getUnorderedUserIds().get(1);
|
||||||
|
|
||||||
{ // first part, add new user id which is also primary
|
{ // first part, add new user id which is also primary
|
||||||
parcel.addUserIds.add("jack");
|
parcel.mAddUserIds.add("jack");
|
||||||
parcel.changePrimaryUserId = "jack";
|
parcel.mChangePrimaryUserId = "jack";
|
||||||
|
|
||||||
modified = applyModificationWithChecks(parcel, modified, onlyA, onlyB);
|
modified = applyModificationWithChecks(parcel, modified, onlyA, onlyB);
|
||||||
|
|
||||||
@ -304,7 +304,7 @@ public class PgpKeyOperationTest {
|
|||||||
|
|
||||||
{ // second part, change primary to a different one
|
{ // second part, change primary to a different one
|
||||||
parcel.reset();
|
parcel.reset();
|
||||||
parcel.changePrimaryUserId = uid;
|
parcel.mChangePrimaryUserId = uid;
|
||||||
|
|
||||||
modified = applyModificationWithChecks(parcel, modified, onlyA, onlyB);
|
modified = applyModificationWithChecks(parcel, modified, onlyA, onlyB);
|
||||||
|
|
||||||
@ -318,7 +318,7 @@ public class PgpKeyOperationTest {
|
|||||||
{ // third part, change primary to a non-existent one
|
{ // third part, change primary to a non-existent one
|
||||||
parcel.reset();
|
parcel.reset();
|
||||||
//noinspection SpellCheckingInspection
|
//noinspection SpellCheckingInspection
|
||||||
parcel.changePrimaryUserId = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
|
parcel.mChangePrimaryUserId = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
|
||||||
|
|
||||||
WrappedSecretKeyRing secretRing = new WrappedSecretKeyRing(ring.getEncoded(), false, 0);
|
WrappedSecretKeyRing secretRing = new WrappedSecretKeyRing(ring.getEncoded(), false, 0);
|
||||||
OperationResultParcel.OperationLog log = new OperationResultParcel.OperationLog();
|
OperationResultParcel.OperationLog log = new OperationResultParcel.OperationLog();
|
||||||
|
@ -170,12 +170,12 @@ public class PgpKeyOperation {
|
|||||||
indent += 1;
|
indent += 1;
|
||||||
updateProgress(R.string.progress_building_key, 0, 100);
|
updateProgress(R.string.progress_building_key, 0, 100);
|
||||||
|
|
||||||
if (saveParcel.addSubKeys == null || saveParcel.addSubKeys.isEmpty()) {
|
if (saveParcel.mAddSubKeys == null || saveParcel.mAddSubKeys.isEmpty()) {
|
||||||
log.add(LogLevel.ERROR, LogType.MSG_CR_ERROR_NO_MASTER, indent);
|
log.add(LogLevel.ERROR, LogType.MSG_CR_ERROR_NO_MASTER, indent);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
SubkeyAdd add = saveParcel.addSubKeys.remove(0);
|
SubkeyAdd add = saveParcel.mAddSubKeys.remove(0);
|
||||||
if ((add.mFlags & KeyFlags.CERTIFY_OTHER) != KeyFlags.CERTIFY_OTHER) {
|
if ((add.mFlags & KeyFlags.CERTIFY_OTHER) != KeyFlags.CERTIFY_OTHER) {
|
||||||
log.add(LogLevel.ERROR, LogType.MSG_CR_ERROR_NO_CERTIFY, indent);
|
log.add(LogLevel.ERROR, LogType.MSG_CR_ERROR_NO_CERTIFY, indent);
|
||||||
return null;
|
return null;
|
||||||
@ -299,7 +299,7 @@ public class PgpKeyOperation {
|
|||||||
PGPPublicKey modifiedPublicKey = masterPublicKey;
|
PGPPublicKey modifiedPublicKey = masterPublicKey;
|
||||||
|
|
||||||
// 2a. Add certificates for new user ids
|
// 2a. Add certificates for new user ids
|
||||||
for (String userId : saveParcel.addUserIds) {
|
for (String userId : saveParcel.mAddUserIds) {
|
||||||
log.add(LogLevel.INFO, LogType.MSG_MF_UID_ADD, indent);
|
log.add(LogLevel.INFO, LogType.MSG_MF_UID_ADD, indent);
|
||||||
|
|
||||||
// this operation supersedes all previous binding and revocation certificates,
|
// this operation supersedes all previous binding and revocation certificates,
|
||||||
@ -324,8 +324,8 @@ public class PgpKeyOperation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if it's supposed to be primary, we can do that here as well
|
// if it's supposed to be primary, we can do that here as well
|
||||||
boolean isPrimary = saveParcel.changePrimaryUserId != null
|
boolean isPrimary = saveParcel.mChangePrimaryUserId != null
|
||||||
&& userId.equals(saveParcel.changePrimaryUserId);
|
&& userId.equals(saveParcel.mChangePrimaryUserId);
|
||||||
// generate and add new certificate
|
// generate and add new certificate
|
||||||
PGPSignature cert = generateUserIdSignature(masterPrivateKey,
|
PGPSignature cert = generateUserIdSignature(masterPrivateKey,
|
||||||
masterPublicKey, userId, isPrimary, masterKeyFlags);
|
masterPublicKey, userId, isPrimary, masterKeyFlags);
|
||||||
@ -333,7 +333,7 @@ public class PgpKeyOperation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 2b. Add revocations for revoked user ids
|
// 2b. Add revocations for revoked user ids
|
||||||
for (String userId : saveParcel.revokeUserIds) {
|
for (String userId : saveParcel.mRevokeUserIds) {
|
||||||
log.add(LogLevel.INFO, LogType.MSG_MF_UID_REVOKE, indent);
|
log.add(LogLevel.INFO, LogType.MSG_MF_UID_REVOKE, indent);
|
||||||
// a duplicate revocatin will be removed during canonicalization, so no need to
|
// a duplicate revocatin will be removed during canonicalization, so no need to
|
||||||
// take care of that here.
|
// take care of that here.
|
||||||
@ -343,7 +343,7 @@ public class PgpKeyOperation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 3. If primary user id changed, generate new certificates for both old and new
|
// 3. If primary user id changed, generate new certificates for both old and new
|
||||||
if (saveParcel.changePrimaryUserId != null) {
|
if (saveParcel.mChangePrimaryUserId != null) {
|
||||||
|
|
||||||
// keep track if we actually changed one
|
// keep track if we actually changed one
|
||||||
boolean ok = false;
|
boolean ok = false;
|
||||||
@ -387,7 +387,7 @@ public class PgpKeyOperation {
|
|||||||
// we definitely should not update certifications of revoked keys, so just leave it.
|
// we definitely should not update certifications of revoked keys, so just leave it.
|
||||||
if (isRevoked) {
|
if (isRevoked) {
|
||||||
// revoked user ids cannot be primary!
|
// revoked user ids cannot be primary!
|
||||||
if (userId.equals(saveParcel.changePrimaryUserId)) {
|
if (userId.equals(saveParcel.mChangePrimaryUserId)) {
|
||||||
log.add(LogLevel.ERROR, LogType.MSG_MF_ERROR_REVOKED_PRIMARY, indent);
|
log.add(LogLevel.ERROR, LogType.MSG_MF_ERROR_REVOKED_PRIMARY, indent);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -397,7 +397,7 @@ public class PgpKeyOperation {
|
|||||||
// if this is~ the/a primary user id
|
// if this is~ the/a primary user id
|
||||||
if (currentCert.hasSubpackets() && currentCert.getHashedSubPackets().isPrimaryUserID()) {
|
if (currentCert.hasSubpackets() && currentCert.getHashedSubPackets().isPrimaryUserID()) {
|
||||||
// if it's the one we want, just leave it as is
|
// if it's the one we want, just leave it as is
|
||||||
if (userId.equals(saveParcel.changePrimaryUserId)) {
|
if (userId.equals(saveParcel.mChangePrimaryUserId)) {
|
||||||
ok = true;
|
ok = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -415,7 +415,7 @@ public class PgpKeyOperation {
|
|||||||
// if we are here, this is not currently a primary user id
|
// if we are here, this is not currently a primary user id
|
||||||
|
|
||||||
// if it should be
|
// if it should be
|
||||||
if (userId.equals(saveParcel.changePrimaryUserId)) {
|
if (userId.equals(saveParcel.mChangePrimaryUserId)) {
|
||||||
// add shiny new primary user id certificate
|
// add shiny new primary user id certificate
|
||||||
log.add(LogLevel.DEBUG, LogType.MSG_MF_PRIMARY_NEW, indent);
|
log.add(LogLevel.DEBUG, LogType.MSG_MF_PRIMARY_NEW, indent);
|
||||||
modifiedPublicKey = PGPPublicKey.removeCertification(
|
modifiedPublicKey = PGPPublicKey.removeCertification(
|
||||||
@ -447,7 +447,7 @@ public class PgpKeyOperation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 4a. For each subkey change, generate new subkey binding certificate
|
// 4a. For each subkey change, generate new subkey binding certificate
|
||||||
for (SaveKeyringParcel.SubkeyChange change : saveParcel.changeSubKeys) {
|
for (SaveKeyringParcel.SubkeyChange change : saveParcel.mChangeSubKeys) {
|
||||||
log.add(LogLevel.INFO, LogType.MSG_MF_SUBKEY_CHANGE,
|
log.add(LogLevel.INFO, LogType.MSG_MF_SUBKEY_CHANGE,
|
||||||
indent, PgpKeyHelper.convertKeyIdToHex(change.mKeyId));
|
indent, PgpKeyHelper.convertKeyIdToHex(change.mKeyId));
|
||||||
PGPSecretKey sKey = sKR.getSecretKey(change.mKeyId);
|
PGPSecretKey sKey = sKR.getSecretKey(change.mKeyId);
|
||||||
@ -473,7 +473,7 @@ public class PgpKeyOperation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 4b. For each subkey revocation, generate new subkey revocation certificate
|
// 4b. For each subkey revocation, generate new subkey revocation certificate
|
||||||
for (long revocation : saveParcel.revokeSubKeys) {
|
for (long revocation : saveParcel.mRevokeSubKeys) {
|
||||||
log.add(LogLevel.INFO, LogType.MSG_MF_SUBKEY_REVOKE,
|
log.add(LogLevel.INFO, LogType.MSG_MF_SUBKEY_REVOKE,
|
||||||
indent, PgpKeyHelper.convertKeyIdToHex(revocation));
|
indent, PgpKeyHelper.convertKeyIdToHex(revocation));
|
||||||
PGPSecretKey sKey = sKR.getSecretKey(revocation);
|
PGPSecretKey sKey = sKR.getSecretKey(revocation);
|
||||||
@ -492,7 +492,7 @@ public class PgpKeyOperation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 5. Generate and add new subkeys
|
// 5. Generate and add new subkeys
|
||||||
for (SaveKeyringParcel.SubkeyAdd add : saveParcel.addSubKeys) {
|
for (SaveKeyringParcel.SubkeyAdd add : saveParcel.mAddSubKeys) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (add.mExpiry != null && new Date(add.mExpiry).before(new Date())) {
|
if (add.mExpiry != null && new Date(add.mExpiry).before(new Date())) {
|
||||||
@ -537,7 +537,7 @@ public class PgpKeyOperation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 6. If requested, change passphrase
|
// 6. If requested, change passphrase
|
||||||
if (saveParcel.newPassphrase != null) {
|
if (saveParcel.mNewPassphrase != null) {
|
||||||
log.add(LogLevel.INFO, LogType.MSG_MF_PASSPHRASE, indent);
|
log.add(LogLevel.INFO, LogType.MSG_MF_PASSPHRASE, indent);
|
||||||
PGPDigestCalculator sha1Calc = new JcaPGPDigestCalculatorProviderBuilder().build()
|
PGPDigestCalculator sha1Calc = new JcaPGPDigestCalculatorProviderBuilder().build()
|
||||||
.get(HashAlgorithmTags.SHA1);
|
.get(HashAlgorithmTags.SHA1);
|
||||||
@ -547,7 +547,7 @@ public class PgpKeyOperation {
|
|||||||
PBESecretKeyEncryptor keyEncryptorNew = new JcePBESecretKeyEncryptorBuilder(
|
PBESecretKeyEncryptor keyEncryptorNew = new JcePBESecretKeyEncryptorBuilder(
|
||||||
PGPEncryptedData.CAST5, sha1Calc)
|
PGPEncryptedData.CAST5, sha1Calc)
|
||||||
.setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(
|
.setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(
|
||||||
saveParcel.newPassphrase.toCharArray());
|
saveParcel.mNewPassphrase.toCharArray());
|
||||||
|
|
||||||
sKR = PGPSecretKeyRing.copyWithNewPassword(sKR, keyDecryptor, keyEncryptorNew);
|
sKR = PGPSecretKeyRing.copyWithNewPassword(sKR, keyDecryptor, keyEncryptorNew);
|
||||||
}
|
}
|
||||||
|
@ -349,9 +349,9 @@ public class KeychainIntentService extends IntentService
|
|||||||
providerHelper.saveSecretKeyRing(ring, new ProgressScaler(this, 10, 95, 100));
|
providerHelper.saveSecretKeyRing(ring, new ProgressScaler(this, 10, 95, 100));
|
||||||
|
|
||||||
// cache new passphrase
|
// cache new passphrase
|
||||||
if (saveParcel.newPassphrase != null) {
|
if (saveParcel.mNewPassphrase != null) {
|
||||||
PassphraseCacheService.addCachedPassphrase(this, ring.getMasterKeyId(),
|
PassphraseCacheService.addCachedPassphrase(this, ring.getMasterKeyId(),
|
||||||
saveParcel.newPassphrase);
|
saveParcel.mNewPassphrase);
|
||||||
}
|
}
|
||||||
} catch (ProviderHelper.NotFoundException e) {
|
} catch (ProviderHelper.NotFoundException e) {
|
||||||
sendErrorToHandler(e);
|
sendErrorToHandler(e);
|
||||||
|
@ -27,16 +27,16 @@ public class SaveKeyringParcel implements Parcelable {
|
|||||||
// the key fingerprint, for safety. MUST be null for a new key.
|
// the key fingerprint, for safety. MUST be null for a new key.
|
||||||
public byte[] mFingerprint;
|
public byte[] mFingerprint;
|
||||||
|
|
||||||
public String newPassphrase;
|
public String mNewPassphrase;
|
||||||
|
|
||||||
public ArrayList<String> addUserIds;
|
public ArrayList<String> mAddUserIds;
|
||||||
public ArrayList<SubkeyAdd> addSubKeys;
|
public ArrayList<SubkeyAdd> mAddSubKeys;
|
||||||
|
|
||||||
public ArrayList<SubkeyChange> changeSubKeys;
|
public ArrayList<SubkeyChange> mChangeSubKeys;
|
||||||
public String changePrimaryUserId;
|
public String mChangePrimaryUserId;
|
||||||
|
|
||||||
public ArrayList<String> revokeUserIds;
|
public ArrayList<String> mRevokeUserIds;
|
||||||
public ArrayList<Long> revokeSubKeys;
|
public ArrayList<Long> mRevokeSubKeys;
|
||||||
|
|
||||||
public SaveKeyringParcel() {
|
public SaveKeyringParcel() {
|
||||||
reset();
|
reset();
|
||||||
@ -49,13 +49,13 @@ public class SaveKeyringParcel implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
newPassphrase = null;
|
mNewPassphrase = null;
|
||||||
addUserIds = new ArrayList<String>();
|
mAddUserIds = new ArrayList<String>();
|
||||||
addSubKeys = new ArrayList<SubkeyAdd>();
|
mAddSubKeys = new ArrayList<SubkeyAdd>();
|
||||||
changePrimaryUserId = null;
|
mChangePrimaryUserId = null;
|
||||||
changeSubKeys = new ArrayList<SubkeyChange>();
|
mChangeSubKeys = new ArrayList<SubkeyChange>();
|
||||||
revokeUserIds = new ArrayList<String>();
|
mRevokeUserIds = new ArrayList<String>();
|
||||||
revokeSubKeys = new ArrayList<Long>();
|
mRevokeSubKeys = new ArrayList<Long>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// performance gain for using Parcelable here would probably be negligible,
|
// performance gain for using Parcelable here would probably be negligible,
|
||||||
@ -88,16 +88,16 @@ public class SaveKeyringParcel implements Parcelable {
|
|||||||
mMasterKeyId = source.readInt() != 0 ? source.readLong() : null;
|
mMasterKeyId = source.readInt() != 0 ? source.readLong() : null;
|
||||||
mFingerprint = source.createByteArray();
|
mFingerprint = source.createByteArray();
|
||||||
|
|
||||||
newPassphrase = source.readString();
|
mNewPassphrase = source.readString();
|
||||||
|
|
||||||
addUserIds = source.createStringArrayList();
|
mAddUserIds = source.createStringArrayList();
|
||||||
addSubKeys = (ArrayList<SubkeyAdd>) source.readSerializable();
|
mAddSubKeys = (ArrayList<SubkeyAdd>) source.readSerializable();
|
||||||
|
|
||||||
changeSubKeys = (ArrayList<SubkeyChange>) source.readSerializable();
|
mChangeSubKeys = (ArrayList<SubkeyChange>) source.readSerializable();
|
||||||
changePrimaryUserId = source.readString();
|
mChangePrimaryUserId = source.readString();
|
||||||
|
|
||||||
revokeUserIds = source.createStringArrayList();
|
mRevokeUserIds = source.createStringArrayList();
|
||||||
revokeSubKeys = (ArrayList<Long>) source.readSerializable();
|
mRevokeSubKeys = (ArrayList<Long>) source.readSerializable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -108,16 +108,16 @@ public class SaveKeyringParcel implements Parcelable {
|
|||||||
}
|
}
|
||||||
destination.writeByteArray(mFingerprint);
|
destination.writeByteArray(mFingerprint);
|
||||||
|
|
||||||
destination.writeString(newPassphrase);
|
destination.writeString(mNewPassphrase);
|
||||||
|
|
||||||
destination.writeStringList(addUserIds);
|
destination.writeStringList(mAddUserIds);
|
||||||
destination.writeSerializable(addSubKeys);
|
destination.writeSerializable(mAddSubKeys);
|
||||||
|
|
||||||
destination.writeSerializable(changeSubKeys);
|
destination.writeSerializable(mChangeSubKeys);
|
||||||
destination.writeString(changePrimaryUserId);
|
destination.writeString(mChangePrimaryUserId);
|
||||||
|
|
||||||
destination.writeStringList(revokeUserIds);
|
destination.writeStringList(mRevokeUserIds);
|
||||||
destination.writeSerializable(revokeSubKeys);
|
destination.writeSerializable(mRevokeSubKeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Creator<SaveKeyringParcel> CREATOR = new Creator<SaveKeyringParcel>() {
|
public static final Creator<SaveKeyringParcel> CREATOR = new Creator<SaveKeyringParcel>() {
|
||||||
|
@ -556,7 +556,7 @@ public class EditKeyActivityOld extends ActionBarActivity implements EditorListe
|
|||||||
saveParams.deletedKeys = mKeysView.getDeletedKeys();
|
saveParams.deletedKeys = mKeysView.getDeletedKeys();
|
||||||
saveParams.keysExpiryDates = getKeysExpiryDates(mKeysView);
|
saveParams.keysExpiryDates = getKeysExpiryDates(mKeysView);
|
||||||
saveParams.keysUsages = getKeysUsages(mKeysView);
|
saveParams.keysUsages = getKeysUsages(mKeysView);
|
||||||
saveParams.newPassphrase = mNewPassphrase;
|
saveParams.mNewPassphrase = mNewPassphrase;
|
||||||
saveParams.oldPassphrase = mCurrentPassphrase;
|
saveParams.oldPassphrase = mCurrentPassphrase;
|
||||||
saveParams.newKeys = toPrimitiveArray(mKeysView.getNewKeysArray());
|
saveParams.newKeys = toPrimitiveArray(mKeysView.getNewKeysArray());
|
||||||
saveParams.keys = getKeys(mKeysView);
|
saveParams.keys = getKeys(mKeysView);
|
||||||
|
@ -217,7 +217,7 @@ public class EditKeyFragment extends LoaderFragment implements
|
|||||||
mSubkeysAdapter = new SubkeysAdapter(getActivity(), null, 0);
|
mSubkeysAdapter = new SubkeysAdapter(getActivity(), null, 0);
|
||||||
mSubkeysList.setAdapter(mSubkeysAdapter);
|
mSubkeysList.setAdapter(mSubkeysAdapter);
|
||||||
|
|
||||||
mSubkeysAddedAdapter = new SubkeysAddedAdapter(getActivity(), mSaveKeyringParcel.addSubKeys);
|
mSubkeysAddedAdapter = new SubkeysAddedAdapter(getActivity(), mSaveKeyringParcel.mAddSubKeys);
|
||||||
mSubkeysAddedList.setAdapter(mSubkeysAddedAdapter);
|
mSubkeysAddedList.setAdapter(mSubkeysAddedAdapter);
|
||||||
|
|
||||||
// Prepare the loaders. Either re-connect with an existing ones,
|
// Prepare the loaders. Either re-connect with an existing ones,
|
||||||
@ -287,7 +287,7 @@ public class EditKeyFragment extends LoaderFragment implements
|
|||||||
Bundle data = message.getData();
|
Bundle data = message.getData();
|
||||||
|
|
||||||
// cache new returned passphrase!
|
// cache new returned passphrase!
|
||||||
mSaveKeyringParcel.newPassphrase = data
|
mSaveKeyringParcel.mNewPassphrase = data
|
||||||
.getString(SetPassphraseDialogFragment.MESSAGE_NEW_PASSPHRASE);
|
.getString(SetPassphraseDialogFragment.MESSAGE_NEW_PASSPHRASE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -309,19 +309,19 @@ public class EditKeyFragment extends LoaderFragment implements
|
|||||||
switch (message.what) {
|
switch (message.what) {
|
||||||
case EditUserIdDialogFragment.MESSAGE_CHANGE_PRIMARY_USER_ID:
|
case EditUserIdDialogFragment.MESSAGE_CHANGE_PRIMARY_USER_ID:
|
||||||
// toggle
|
// toggle
|
||||||
if (mSaveKeyringParcel.changePrimaryUserId != null
|
if (mSaveKeyringParcel.mChangePrimaryUserId != null
|
||||||
&& mSaveKeyringParcel.changePrimaryUserId.equals(userId)) {
|
&& mSaveKeyringParcel.mChangePrimaryUserId.equals(userId)) {
|
||||||
mSaveKeyringParcel.changePrimaryUserId = null;
|
mSaveKeyringParcel.mChangePrimaryUserId = null;
|
||||||
} else {
|
} else {
|
||||||
mSaveKeyringParcel.changePrimaryUserId = userId;
|
mSaveKeyringParcel.mChangePrimaryUserId = userId;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EditUserIdDialogFragment.MESSAGE_REVOKE:
|
case EditUserIdDialogFragment.MESSAGE_REVOKE:
|
||||||
// toggle
|
// toggle
|
||||||
if (mSaveKeyringParcel.revokeUserIds.contains(userId)) {
|
if (mSaveKeyringParcel.mRevokeUserIds.contains(userId)) {
|
||||||
mSaveKeyringParcel.revokeUserIds.remove(userId);
|
mSaveKeyringParcel.mRevokeUserIds.remove(userId);
|
||||||
} else {
|
} else {
|
||||||
mSaveKeyringParcel.revokeUserIds.add(userId);
|
mSaveKeyringParcel.mRevokeUserIds.add(userId);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -374,9 +374,9 @@ public class EditKeyFragment extends LoaderFragment implements
|
|||||||
|
|
||||||
private void save(String passphrase) {
|
private void save(String passphrase) {
|
||||||
Log.d(Constants.TAG, "add userids to parcel: " + mUserIdsAddedAdapter.getDataAsStringList());
|
Log.d(Constants.TAG, "add userids to parcel: " + mUserIdsAddedAdapter.getDataAsStringList());
|
||||||
Log.d(Constants.TAG, "mSaveKeyringParcel.newPassphrase: " + mSaveKeyringParcel.newPassphrase);
|
Log.d(Constants.TAG, "mSaveKeyringParcel.mNewPassphrase: " + mSaveKeyringParcel.mNewPassphrase);
|
||||||
|
|
||||||
mSaveKeyringParcel.addUserIds = mUserIdsAddedAdapter.getDataAsStringList();
|
mSaveKeyringParcel.mAddUserIds = mUserIdsAddedAdapter.getDataAsStringList();
|
||||||
|
|
||||||
// Message is received after importing is done in KeychainIntentService
|
// Message is received after importing is done in KeychainIntentService
|
||||||
KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(
|
KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(
|
||||||
|
@ -32,8 +32,6 @@ import org.sufficientlysecure.keychain.Constants;
|
|||||||
import org.sufficientlysecure.keychain.Constants.choice.algorithm;
|
import org.sufficientlysecure.keychain.Constants.choice.algorithm;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.helper.ExportHelper;
|
import org.sufficientlysecure.keychain.helper.ExportHelper;
|
||||||
import org.sufficientlysecure.keychain.helper.OtherHelper;
|
|
||||||
import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry;
|
|
||||||
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;
|
||||||
@ -43,7 +41,6 @@ import org.sufficientlysecure.keychain.service.SaveKeyringParcel.SubkeyAdd;
|
|||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class KeyListActivity extends DrawerActivity {
|
public class KeyListActivity extends DrawerActivity {
|
||||||
|
|
||||||
@ -153,10 +150,10 @@ public class KeyListActivity extends DrawerActivity {
|
|||||||
Bundle data = new Bundle();
|
Bundle data = new Bundle();
|
||||||
|
|
||||||
SaveKeyringParcel parcel = new SaveKeyringParcel();
|
SaveKeyringParcel parcel = new SaveKeyringParcel();
|
||||||
parcel.addSubKeys.add(new SubkeyAdd(algorithm.rsa, 1024, KeyFlags.CERTIFY_OTHER, null));
|
parcel.mAddSubKeys.add(new SubkeyAdd(algorithm.rsa, 1024, KeyFlags.CERTIFY_OTHER, null));
|
||||||
parcel.addSubKeys.add(new SubkeyAdd(algorithm.rsa, 1024, KeyFlags.SIGN_DATA, null));
|
parcel.mAddSubKeys.add(new SubkeyAdd(algorithm.rsa, 1024, KeyFlags.SIGN_DATA, null));
|
||||||
parcel.addUserIds.add("swagerinho");
|
parcel.mAddUserIds.add("swagerinho");
|
||||||
parcel.newPassphrase = "swag";
|
parcel.mNewPassphrase = "swag";
|
||||||
|
|
||||||
// get selected key entries
|
// get selected key entries
|
||||||
data.putParcelable(KeychainIntentService.SAVE_KEYRING_PARCEL, parcel);
|
data.putParcelable(KeychainIntentService.SAVE_KEYRING_PARCEL, parcel);
|
||||||
|
@ -328,7 +328,7 @@ public class WizardActivity extends ActionBarActivity {
|
|||||||
&& isEditTextNotEmpty(this, passphraseEdit)) {
|
&& isEditTextNotEmpty(this, passphraseEdit)) {
|
||||||
|
|
||||||
// SaveKeyringParcel newKey = new SaveKeyringParcel();
|
// SaveKeyringParcel newKey = new SaveKeyringParcel();
|
||||||
// newKey.addUserIds.add(nameEdit.getText().toString() + " <"
|
// newKey.mAddUserIds.add(nameEdit.getText().toString() + " <"
|
||||||
// + emailEdit.getText().toString() + ">");
|
// + emailEdit.getText().toString() + ">");
|
||||||
|
|
||||||
|
|
||||||
|
@ -134,10 +134,10 @@ public class UserIdsAdapter extends CursorAdapter implements AdapterView.OnItemC
|
|||||||
|
|
||||||
// for edit key
|
// for edit key
|
||||||
if (mSaveKeyringParcel != null) {
|
if (mSaveKeyringParcel != null) {
|
||||||
boolean changeAnyPrimaryUserId = (mSaveKeyringParcel.changePrimaryUserId != null);
|
boolean changeAnyPrimaryUserId = (mSaveKeyringParcel.mChangePrimaryUserId != null);
|
||||||
boolean changeThisPrimaryUserId = (mSaveKeyringParcel.changePrimaryUserId != null
|
boolean changeThisPrimaryUserId = (mSaveKeyringParcel.mChangePrimaryUserId != null
|
||||||
&& mSaveKeyringParcel.changePrimaryUserId.equals(userId));
|
&& mSaveKeyringParcel.mChangePrimaryUserId.equals(userId));
|
||||||
boolean revokeThisUserId = (mSaveKeyringParcel.revokeUserIds.contains(userId));
|
boolean revokeThisUserId = (mSaveKeyringParcel.mRevokeUserIds.contains(userId));
|
||||||
|
|
||||||
if (changeAnyPrimaryUserId) {
|
if (changeAnyPrimaryUserId) {
|
||||||
// change all user ids, only this one should be primary
|
// change all user ids, only this one should be primary
|
||||||
|
Loading…
Reference in New Issue
Block a user