From be007ecc56809cc0b6d489ab09be656e2ced9c32 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Sun, 30 Mar 2014 16:22:13 +0100 Subject: style changes --- .../keychain/pgp/PgpKeyOperation.java | 53 +++++++++++----------- 1 file changed, 26 insertions(+), 27 deletions(-) (limited to 'OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain') diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index 05ca99578..592bdec73 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -217,7 +217,7 @@ public class PgpKeyOperation { PGPPrivateKey masterPrivateKey = masterKey.extractPrivateKey(keyDecryptor); updateProgress(R.string.progress_certifying_master_key, 20, 100); - int user_id_index = 0; + for (String userId : userIds) { PGPContentSignerBuilder signerBuilder = new JcaPGPContentSignerBuilder( masterPublicKey.getAlgorithm(), HashAlgorithmTags.SHA1) @@ -228,7 +228,6 @@ public class PgpKeyOperation { PGPSignature certification = sGen.generateCertification(userId, masterPublicKey); masterPublicKey = PGPPublicKey.addCertification(masterPublicKey, userId, certification); - user_id_index++; } PGPKeyPair masterKeyPair = new PGPKeyPair(masterPublicKey, masterPrivateKey); @@ -412,7 +411,7 @@ public class PgpKeyOperation { masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, delID); } - int user_id_index = 0; + int userIDIndex = 0; PGPSignatureSubpacketGenerator hashedPacketsGen = new PGPSignatureSubpacketGenerator(); PGPSignatureSubpacketGenerator unhashedPacketsGen = new PGPSignatureSubpacketGenerator(); @@ -442,12 +441,12 @@ public class PgpKeyOperation { anyIDChanged = true; ArrayList> sigList = new ArrayList>(); for (String userId : saveParcel.userIDs) { - String orig_id = saveParcel.originalIDs.get(user_id_index); - if (orig_id.equals(userId) && !userId.equals(saveParcel.originalPrimaryID) && user_id_index != 0) { - Iterator orig_sigs = masterPublicKey.getSignaturesForID(orig_id); //TODO: make sure this iterator only has signatures we are interested in - while (orig_sigs.hasNext()) { - PGPSignature orig_sig = orig_sigs.next(); - sigList.add(new Pair(orig_id, orig_sig)); + String origID = saveParcel.originalIDs.get(userIDIndex); + if (origID.equals(userId) && !userId.equals(saveParcel.originalPrimaryID) && userIDIndex != 0) { + Iterator origSigs = masterPublicKey.getSignaturesForID(origID); //TODO: make sure this iterator only has signatures we are interested in + while (origSigs.hasNext()) { + PGPSignature origSig = origSigs.next(); + sigList.add(new Pair(origID, origSig)); } } else { PGPContentSignerBuilder signerBuilder = new JcaPGPContentSignerBuilder( @@ -456,25 +455,25 @@ public class PgpKeyOperation { PGPSignatureGenerator sGen = new PGPSignatureGenerator(signerBuilder); sGen.init(PGPSignature.POSITIVE_CERTIFICATION, masterPrivateKey); - if (user_id_index == 0) { + if (userIDIndex == 0) { sGen.setHashedSubpackets(hashedPacketsGen.generate()); sGen.setUnhashedSubpackets(unhashedPacketsGen.generate()); } PGPSignature certification = sGen.generateCertification(userId, masterPublicKey); sigList.add(new Pair(userId, certification)); } - if (!orig_id.equals("")) { - masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, orig_id); + if (!origID.equals("")) { + masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, origID); } - user_id_index++; + userIDIndex++; } - for (Pair to_add : sigList) { - masterPublicKey = PGPPublicKey.addCertification(masterPublicKey, to_add.first, to_add.second); + for (Pair toAdd : sigList) { + masterPublicKey = PGPPublicKey.addCertification(masterPublicKey, toAdd.first, toAdd.second); } } else { for (String userId : saveParcel.userIDs) { - String orig_id = saveParcel.originalIDs.get(user_id_index); - if (!orig_id.equals(userId)) { + String origID = saveParcel.originalIDs.get(userIDIndex); + if (!origID.equals(userId)) { anyIDChanged = true; PGPContentSignerBuilder signerBuilder = new JcaPGPContentSignerBuilder( masterPublicKey.getAlgorithm(), HashAlgorithmTags.SHA1) @@ -482,26 +481,26 @@ public class PgpKeyOperation { PGPSignatureGenerator sGen = new PGPSignatureGenerator(signerBuilder); sGen.init(PGPSignature.POSITIVE_CERTIFICATION, masterPrivateKey); - if (user_id_index == 0) { + if (userIDIndex == 0) { sGen.setHashedSubpackets(hashedPacketsGen.generate()); sGen.setUnhashedSubpackets(unhashedPacketsGen.generate()); } PGPSignature certification = sGen.generateCertification(userId, masterPublicKey); - if (!orig_id.equals("")) { - masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, orig_id); + if (!origID.equals("")) { + masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, origID); } masterPublicKey = PGPPublicKey.addCertification(masterPublicKey, userId, certification); } - user_id_index++; + userIDIndex++; } } ArrayList> sigList = new ArrayList>(); if (saveParcel.moddedKeys[0]) { - user_id_index = 0; + userIDIndex = 0; for (String userId : saveParcel.userIDs) { - String orig_id = saveParcel.originalIDs.get(user_id_index); - if (!(orig_id.equals(saveParcel.originalPrimaryID) && !saveParcel.primaryIDChanged)) { + String origID = saveParcel.originalIDs.get(userIDIndex); + if (!(origID.equals(saveParcel.originalPrimaryID) && !saveParcel.primaryIDChanged)) { Iterator sigs = masterPublicKey.getSignaturesForID(userId); //TODO: make sure this iterator only has signatures we are interested in while (sigs.hasNext()) { PGPSignature sig = sigs.next(); @@ -511,7 +510,7 @@ public class PgpKeyOperation { if (!userId.equals("")) { masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, userId); } - user_id_index++; + userIDIndex++; } anyIDChanged = true; } @@ -623,8 +622,8 @@ public class PgpKeyOperation { //replace lost IDs if (saveParcel.moddedKeys[0]) { masterPublicKey = mKR.getPublicKey(); - for (Pair to_add : sigList) { - masterPublicKey = PGPPublicKey.addCertification(masterPublicKey, to_add.first, to_add.second); + for (Pair toAdd : sigList) { + masterPublicKey = PGPPublicKey.addCertification(masterPublicKey, toAdd.first, toAdd.second); } pKR = PGPPublicKeyRing.insertPublicKey(pKR, masterPublicKey); mKR = PGPSecretKeyRing.replacePublicKeys(mKR, pKR); -- cgit v1.2.3