use autovalue for CertifyActionsParcel
This commit is contained in:
@@ -76,7 +76,7 @@ public class CertifyOperation extends BaseReadWriteOperation<CertifyActionsParce
|
|||||||
|
|
||||||
// Retrieve and unlock secret key
|
// Retrieve and unlock secret key
|
||||||
CanonicalizedSecretKey certificationKey;
|
CanonicalizedSecretKey certificationKey;
|
||||||
long masterKeyId = parcel.mMasterKeyId;
|
long masterKeyId = parcel.getMasterKeyId();
|
||||||
try {
|
try {
|
||||||
|
|
||||||
log.add(LogType.MSG_CRT_MASTER_FETCH, 1);
|
log.add(LogType.MSG_CRT_MASTER_FETCH, 1);
|
||||||
@@ -121,7 +121,7 @@ public class CertifyOperation extends BaseReadWriteOperation<CertifyActionsParce
|
|||||||
|
|
||||||
// Get actual secret key
|
// Get actual secret key
|
||||||
CanonicalizedSecretKeyRing secretKeyRing =
|
CanonicalizedSecretKeyRing secretKeyRing =
|
||||||
mKeyRepository.getCanonicalizedSecretKeyRing(parcel.mMasterKeyId);
|
mKeyRepository.getCanonicalizedSecretKeyRing(parcel.getMasterKeyId());
|
||||||
certificationKey = secretKeyRing.getSecretKey();
|
certificationKey = secretKeyRing.getSecretKey();
|
||||||
|
|
||||||
log.add(LogType.MSG_CRT_UNLOCK, 1);
|
log.add(LogType.MSG_CRT_UNLOCK, 1);
|
||||||
@@ -148,7 +148,7 @@ public class CertifyOperation extends BaseReadWriteOperation<CertifyActionsParce
|
|||||||
cryptoInput.getSignatureTime(), masterKeyId, masterKeyId);
|
cryptoInput.getSignatureTime(), masterKeyId, masterKeyId);
|
||||||
|
|
||||||
// Work through all requested certifications
|
// Work through all requested certifications
|
||||||
for (CertifyAction action : parcel.mCertifyActions) {
|
for (CertifyAction action : parcel.getCertifyActions()) {
|
||||||
|
|
||||||
// Check if we were cancelled
|
// Check if we were cancelled
|
||||||
if (checkCancelled()) {
|
if (checkCancelled()) {
|
||||||
@@ -158,14 +158,14 @@ public class CertifyOperation extends BaseReadWriteOperation<CertifyActionsParce
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (action.mMasterKeyId == parcel.mMasterKeyId) {
|
if (action.getMasterKeyId() == parcel.getMasterKeyId()) {
|
||||||
log.add(LogType.MSG_CRT_ERROR_SELF, 2);
|
log.add(LogType.MSG_CRT_ERROR_SELF, 2);
|
||||||
certifyError += 1;
|
certifyError += 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
CanonicalizedPublicKeyRing publicRing =
|
CanonicalizedPublicKeyRing publicRing =
|
||||||
mKeyRepository.getCanonicalizedPublicKeyRing(action.mMasterKeyId);
|
mKeyRepository.getCanonicalizedPublicKeyRing(action.getMasterKeyId());
|
||||||
|
|
||||||
PgpCertifyOperation op = new PgpCertifyOperation();
|
PgpCertifyOperation op = new PgpCertifyOperation();
|
||||||
PgpCertifyResult result = op.certify(certificationKey, publicRing,
|
PgpCertifyResult result = op.certify(certificationKey, publicRing,
|
||||||
@@ -205,7 +205,7 @@ public class CertifyOperation extends BaseReadWriteOperation<CertifyActionsParce
|
|||||||
|
|
||||||
// these variables are used inside the following loop, but they need to be created only once
|
// these variables are used inside the following loop, but they need to be created only once
|
||||||
UploadOperation uploadOperation = null;
|
UploadOperation uploadOperation = null;
|
||||||
if (parcel.keyServerUri != null) {
|
if (parcel.getParcelableKeyServer() != null) {
|
||||||
uploadOperation = new UploadOperation(mContext, mKeyRepository, mProgressable, mCancelled);
|
uploadOperation = new UploadOperation(mContext, mKeyRepository, mProgressable, mCancelled);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,8 +226,8 @@ public class CertifyOperation extends BaseReadWriteOperation<CertifyActionsParce
|
|||||||
SaveKeyringResult result = mKeyWritableRepository.savePublicKeyRing(certifiedKey);
|
SaveKeyringResult result = mKeyWritableRepository.savePublicKeyRing(certifiedKey);
|
||||||
|
|
||||||
if (uploadOperation != null) {
|
if (uploadOperation != null) {
|
||||||
UploadKeyringParcel uploadInput =
|
UploadKeyringParcel uploadInput = UploadKeyringParcel.createWithKeyId(
|
||||||
new UploadKeyringParcel(parcel.keyServerUri, certifiedKey.getMasterKeyId());
|
parcel.getParcelableKeyServer(), certifiedKey.getMasterKeyId());
|
||||||
UploadResult uploadResult = uploadOperation.execute(uploadInput, cryptoInput);
|
UploadResult uploadResult = uploadOperation.execute(uploadInput, cryptoInput);
|
||||||
log.add(uploadResult, 2);
|
log.add(uploadResult, 2);
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ package org.sufficientlysecure.keychain.pgp;
|
|||||||
|
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -80,12 +81,13 @@ public class PgpCertifyOperation {
|
|||||||
publicKey.getKeyID(), publicKey.getKeyID());
|
publicKey.getKeyID(), publicKey.getKeyID());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (action.mUserIds != null) {
|
ArrayList<String> userIds = action.getUserIds();
|
||||||
log.add(LogType.MSG_CRT_CERTIFY_UIDS, 2, action.mUserIds.size(),
|
if (userIds != null && !userIds.isEmpty()) {
|
||||||
KeyFormattingUtils.convertKeyIdToHex(action.mMasterKeyId));
|
log.add(LogType.MSG_CRT_CERTIFY_UIDS, 2, userIds.size(),
|
||||||
|
KeyFormattingUtils.convertKeyIdToHex(action.getMasterKeyId()));
|
||||||
|
|
||||||
// fetch public key ring, add the certification and return it
|
// fetch public key ring, add the certification and return it
|
||||||
for (String userId : action.mUserIds) {
|
for (String userId : userIds) {
|
||||||
try {
|
try {
|
||||||
PGPSignature sig = signatureGenerator.generateCertification(userId, publicKey);
|
PGPSignature sig = signatureGenerator.generateCertification(userId, publicKey);
|
||||||
publicKey = PGPPublicKey.addCertification(publicKey, userId, sig);
|
publicKey = PGPPublicKey.addCertification(publicKey, userId, sig);
|
||||||
@@ -96,12 +98,13 @@ public class PgpCertifyOperation {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action.mUserAttributes != null) {
|
ArrayList<WrappedUserAttribute> userAttributes = action.getUserAttributes();
|
||||||
log.add(LogType.MSG_CRT_CERTIFY_UATS, 2, action.mUserAttributes.size(),
|
if (userAttributes != null && !userAttributes.isEmpty()) {
|
||||||
KeyFormattingUtils.convertKeyIdToHex(action.mMasterKeyId));
|
log.add(LogType.MSG_CRT_CERTIFY_UATS, 2, userAttributes.size(),
|
||||||
|
KeyFormattingUtils.convertKeyIdToHex(action.getMasterKeyId()));
|
||||||
|
|
||||||
// fetch public key ring, add the certification and return it
|
// fetch public key ring, add the certification and return it
|
||||||
for (WrappedUserAttribute userAttribute : action.mUserAttributes) {
|
for (WrappedUserAttribute userAttribute : userAttributes) {
|
||||||
PGPUserAttributeSubpacketVector vector = userAttribute.getVector();
|
PGPUserAttributeSubpacketVector vector = userAttribute.getVector();
|
||||||
try {
|
try {
|
||||||
PGPSignature sig = signatureGenerator.generateCertification(vector, publicKey);
|
PGPSignature sig = signatureGenerator.generateCertification(vector, publicKey);
|
||||||
|
|||||||
@@ -18,99 +18,80 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.service;
|
package org.sufficientlysecure.keychain.service;
|
||||||
|
|
||||||
import android.os.Parcel;
|
|
||||||
import android.os.Parcelable;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.pgp.WrappedUserAttribute;
|
import android.os.Parcelable;
|
||||||
|
import android.support.annotation.CheckResult;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.google.auto.value.AutoValue;
|
||||||
import org.sufficientlysecure.keychain.keyimport.ParcelableHkpKeyserver;
|
import org.sufficientlysecure.keychain.keyimport.ParcelableHkpKeyserver;
|
||||||
|
import org.sufficientlysecure.keychain.pgp.WrappedUserAttribute;
|
||||||
|
|
||||||
|
|
||||||
/**
|
@AutoValue
|
||||||
* This class is a a transferable representation for a number of keyrings to
|
public abstract class CertifyActionsParcel implements Parcelable {
|
||||||
* be certified.
|
public abstract long getMasterKeyId();
|
||||||
*/
|
public abstract ArrayList<CertifyAction> getCertifyActions();
|
||||||
public class CertifyActionsParcel implements Parcelable {
|
@Nullable
|
||||||
|
public abstract ParcelableHkpKeyserver getParcelableKeyServer();
|
||||||
|
|
||||||
// the master key id to certify with
|
public static Builder builder(long masterKeyId) {
|
||||||
final public long mMasterKeyId;
|
return new AutoValue_CertifyActionsParcel.Builder()
|
||||||
public CertifyLevel mLevel;
|
.setMasterKeyId(masterKeyId)
|
||||||
|
.setCertifyActions(new ArrayList<CertifyAction>());
|
||||||
public ArrayList<CertifyAction> mCertifyActions = new ArrayList<>();
|
|
||||||
|
|
||||||
public ParcelableHkpKeyserver keyServerUri;
|
|
||||||
|
|
||||||
public CertifyActionsParcel(long masterKeyId) {
|
|
||||||
mMasterKeyId = masterKeyId;
|
|
||||||
mLevel = CertifyLevel.DEFAULT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CertifyActionsParcel(Parcel source) {
|
@AutoValue.Builder
|
||||||
mMasterKeyId = source.readLong();
|
public abstract static class Builder {
|
||||||
// just like parcelables, this is meant for ad-hoc IPC only and is NOT portable!
|
abstract Builder setMasterKeyId(long masterKeyId);
|
||||||
mLevel = CertifyLevel.values()[source.readInt()];
|
public abstract Builder setCertifyActions(ArrayList<CertifyAction> certifyActions);
|
||||||
keyServerUri = source.readParcelable(ParcelableHkpKeyserver.class.getClassLoader());
|
public abstract Builder setParcelableKeyServer(ParcelableHkpKeyserver uri);
|
||||||
|
|
||||||
mCertifyActions = (ArrayList<CertifyAction>) source.readSerializable();
|
abstract ArrayList<CertifyAction> getCertifyActions();
|
||||||
|
|
||||||
|
public void addAction(CertifyAction action) {
|
||||||
|
getCertifyActions().add(action);
|
||||||
|
}
|
||||||
|
public void addActions(Collection<CertifyAction> certifyActions) {
|
||||||
|
getCertifyActions().addAll(certifyActions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(CertifyAction action) {
|
public abstract CertifyActionsParcel build();
|
||||||
mCertifyActions.add(action);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@AutoValue
|
||||||
public void writeToParcel(Parcel destination, int flags) {
|
public abstract static class CertifyAction implements Parcelable {
|
||||||
destination.writeLong(mMasterKeyId);
|
public abstract long getMasterKeyId();
|
||||||
destination.writeInt(mLevel.ordinal());
|
@Nullable
|
||||||
destination.writeParcelable(keyServerUri, flags);
|
public abstract ArrayList<String> getUserIds();
|
||||||
|
@Nullable
|
||||||
|
public abstract ArrayList<WrappedUserAttribute> getUserAttributes();
|
||||||
|
|
||||||
destination.writeSerializable(mCertifyActions);
|
public static CertifyAction createForUserIds(long masterKeyId, List<String> userIds) {
|
||||||
|
return new AutoValue_CertifyActionsParcel_CertifyAction(masterKeyId, new ArrayList<>(userIds), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Creator<CertifyActionsParcel> CREATOR = new Creator<CertifyActionsParcel>() {
|
public static CertifyAction createForUserAttributes(long masterKeyId, List<WrappedUserAttribute> attributes) {
|
||||||
public CertifyActionsParcel createFromParcel(final Parcel source) {
|
return new AutoValue_CertifyActionsParcel_CertifyAction(masterKeyId, null, new ArrayList<>(attributes));
|
||||||
return new CertifyActionsParcel(source);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CertifyActionsParcel[] newArray(final int size) {
|
@CheckResult
|
||||||
return new CertifyActionsParcel[size];
|
public CertifyAction withAddedUserIds(ArrayList<String> addedUserIds) {
|
||||||
}
|
if (getUserAttributes() != null) {
|
||||||
};
|
throw new IllegalStateException("Can't add user ids to user attribute certification parcel!");
|
||||||
|
|
||||||
// TODO make this parcelable
|
|
||||||
public static class CertifyAction implements Serializable {
|
|
||||||
final public long mMasterKeyId;
|
|
||||||
|
|
||||||
final public ArrayList<String> mUserIds;
|
|
||||||
final public ArrayList<WrappedUserAttribute> mUserAttributes;
|
|
||||||
|
|
||||||
public CertifyAction(long masterKeyId, List<String> userIds, List<WrappedUserAttribute> attributes) {
|
|
||||||
mMasterKeyId = masterKeyId;
|
|
||||||
mUserIds = userIds == null ? null : new ArrayList<>(userIds);
|
|
||||||
mUserAttributes = attributes == null ? null : new ArrayList<>(attributes);
|
|
||||||
}
|
}
|
||||||
|
ArrayList<String> prevUserIds = getUserIds();
|
||||||
|
if (prevUserIds == null) {
|
||||||
|
throw new IllegalStateException("Can't add user ids to user attribute certification parcel!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
ArrayList<String> userIds = new ArrayList<>(prevUserIds);
|
||||||
public int describeContents() {
|
userIds.addAll(addedUserIds);
|
||||||
return 0;
|
return new AutoValue_CertifyActionsParcel_CertifyAction(getMasterKeyId(), userIds, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
String out = "mMasterKeyId: " + mMasterKeyId + "\n";
|
|
||||||
out += "mLevel: " + mLevel + "\n";
|
|
||||||
out += "mCertifyActions: " + mCertifyActions + "\n";
|
|
||||||
|
|
||||||
return out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// All supported algorithms
|
|
||||||
public enum CertifyLevel {
|
|
||||||
DEFAULT, NONE, CASUAL, POSITIVE
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,18 +140,17 @@ public class CertifyKeyFragment
|
|||||||
long selectedKeyId = mCertifyKeySpinner.getSelectedKeyId();
|
long selectedKeyId = mCertifyKeySpinner.getSelectedKeyId();
|
||||||
|
|
||||||
// fill values for this action
|
// fill values for this action
|
||||||
CertifyActionsParcel actionsParcel = new CertifyActionsParcel(selectedKeyId);
|
CertifyActionsParcel.Builder actionsParcel = CertifyActionsParcel.builder(selectedKeyId);
|
||||||
actionsParcel.mCertifyActions.addAll(certifyActions);
|
actionsParcel.addActions(certifyActions);
|
||||||
|
|
||||||
if (mUploadKeyCheckbox.isChecked()) {
|
if (mUploadKeyCheckbox.isChecked()) {
|
||||||
actionsParcel.keyServerUri = Preferences.getPreferences(getActivity())
|
actionsParcel.setParcelableKeyServer(Preferences.getPreferences(getActivity()).getPreferredKeyserver());
|
||||||
.getPreferredKeyserver();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// cached for next cryptoOperation loop
|
// cache for next cryptoOperation loop
|
||||||
cacheActionsParcel(actionsParcel);
|
CertifyActionsParcel certifyActionsParcel = actionsParcel.build();
|
||||||
|
cacheActionsParcel(certifyActionsParcel);
|
||||||
return actionsParcel;
|
return certifyActionsParcel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -17,6 +17,9 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.ui.adapter;
|
package org.sufficientlysecure.keychain.ui.adapter;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
@@ -35,8 +38,6 @@ import org.sufficientlysecure.keychain.R;
|
|||||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||||
import org.sufficientlysecure.keychain.service.CertifyActionsParcel.CertifyAction;
|
import org.sufficientlysecure.keychain.service.CertifyActionsParcel.CertifyAction;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class MultiUserIdsAdapter extends CursorAdapter {
|
public class MultiUserIdsAdapter extends CursorAdapter {
|
||||||
private LayoutInflater mInflater;
|
private LayoutInflater mInflater;
|
||||||
private final ArrayList<Boolean> mCheckStates;
|
private final ArrayList<Boolean> mCheckStates;
|
||||||
@@ -178,11 +179,12 @@ public class MultiUserIdsAdapter extends CursorAdapter {
|
|||||||
p.recycle();
|
p.recycle();
|
||||||
|
|
||||||
CertifyAction action = actions.get(keyId);
|
CertifyAction action = actions.get(keyId);
|
||||||
if (actions.get(keyId) == null) {
|
if (action == null) {
|
||||||
actions.put(keyId, new CertifyAction(keyId, uids, null));
|
action = CertifyAction.createForUserIds(keyId, uids);
|
||||||
} else {
|
} else {
|
||||||
action.mUserIds.addAll(uids);
|
action = action.withAddedUserIds(uids);
|
||||||
}
|
}
|
||||||
|
actions.put(keyId, action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -542,14 +542,14 @@ public class LinkedIdViewFragment extends CryptoOperationFragment implements
|
|||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public Parcelable createOperationInput() {
|
public Parcelable createOperationInput() {
|
||||||
CertifyAction action = new CertifyAction(mMasterKeyId, null,
|
CertifyAction action = CertifyAction.createForUserAttributes(mMasterKeyId,
|
||||||
Collections.singletonList(mLinkedId.toUserAttribute()));
|
Collections.singletonList(mLinkedId.toUserAttribute()));
|
||||||
|
|
||||||
// fill values for this action
|
// fill values for this action
|
||||||
CertifyActionsParcel parcel = new CertifyActionsParcel(mCertifyKeyId);
|
CertifyActionsParcel.Builder builder = CertifyActionsParcel.builder(mCertifyKeyId);
|
||||||
parcel.mCertifyActions.addAll(Collections.singletonList(action));
|
builder.addActions(Collections.singletonList(action));
|
||||||
|
|
||||||
return parcel;
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -153,10 +153,10 @@ public class CertifyOperationTest {
|
|||||||
Certs.UNVERIFIED, ring.getVerified());
|
Certs.UNVERIFIED, ring.getVerified());
|
||||||
}
|
}
|
||||||
|
|
||||||
CertifyActionsParcel actions = new CertifyActionsParcel(mStaticRing1.getMasterKeyId());
|
CertifyActionsParcel.Builder actions = CertifyActionsParcel.builder(mStaticRing1.getMasterKeyId());
|
||||||
actions.add(new CertifyAction(mStaticRing2.getMasterKeyId(),
|
actions.addAction(CertifyAction.createForUserIds(mStaticRing2.getMasterKeyId(),
|
||||||
mStaticRing2.getPublicKey().getUnorderedUserIds(), null));
|
mStaticRing2.getPublicKey().getUnorderedUserIds()));
|
||||||
CertifyResult result = op.execute(actions, CryptoInputParcel.createCryptoInputParcel(new Date(), mKeyPhrase1));
|
CertifyResult result = op.execute(actions.build(), CryptoInputParcel.createCryptoInputParcel(new Date(), mKeyPhrase1));
|
||||||
|
|
||||||
Assert.assertTrue("certification must succeed", result.success());
|
Assert.assertTrue("certification must succeed", result.success());
|
||||||
|
|
||||||
@@ -181,10 +181,10 @@ public class CertifyOperationTest {
|
|||||||
Certs.UNVERIFIED, ring.getVerified());
|
Certs.UNVERIFIED, ring.getVerified());
|
||||||
}
|
}
|
||||||
|
|
||||||
CertifyActionsParcel actions = new CertifyActionsParcel(mStaticRing1.getMasterKeyId());
|
CertifyActionsParcel.Builder actions = CertifyActionsParcel.builder(mStaticRing1.getMasterKeyId());
|
||||||
actions.add(new CertifyAction(mStaticRing2.getMasterKeyId(), null,
|
actions.addAction(CertifyAction.createForUserAttributes(mStaticRing2.getMasterKeyId(),
|
||||||
mStaticRing2.getPublicKey().getUnorderedUserAttributes()));
|
mStaticRing2.getPublicKey().getUnorderedUserAttributes()));
|
||||||
CertifyResult result = op.execute(actions, CryptoInputParcel.createCryptoInputParcel(new Date(), mKeyPhrase1));
|
CertifyResult result = op.execute(actions.build(), CryptoInputParcel.createCryptoInputParcel(new Date(), mKeyPhrase1));
|
||||||
|
|
||||||
Assert.assertTrue("certification must succeed", result.success());
|
Assert.assertTrue("certification must succeed", result.success());
|
||||||
|
|
||||||
@@ -203,11 +203,11 @@ public class CertifyOperationTest {
|
|||||||
CertifyOperation op = new CertifyOperation(RuntimeEnvironment.application,
|
CertifyOperation op = new CertifyOperation(RuntimeEnvironment.application,
|
||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
|
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
|
||||||
|
|
||||||
CertifyActionsParcel actions = new CertifyActionsParcel(mStaticRing1.getMasterKeyId());
|
CertifyActionsParcel.Builder actions = CertifyActionsParcel.builder(mStaticRing1.getMasterKeyId());
|
||||||
actions.add(new CertifyAction(mStaticRing1.getMasterKeyId(),
|
actions.addAction(CertifyAction.createForUserIds(mStaticRing1.getMasterKeyId(),
|
||||||
mStaticRing2.getPublicKey().getUnorderedUserIds(), null));
|
mStaticRing2.getPublicKey().getUnorderedUserIds()));
|
||||||
|
|
||||||
CertifyResult result = op.execute(actions, CryptoInputParcel.createCryptoInputParcel(new Date(), mKeyPhrase1));
|
CertifyResult result = op.execute(actions.build(), CryptoInputParcel.createCryptoInputParcel(new Date(), mKeyPhrase1));
|
||||||
|
|
||||||
Assert.assertFalse("certification with itself must fail!", result.success());
|
Assert.assertFalse("certification with itself must fail!", result.success());
|
||||||
Assert.assertTrue("error msg must be about self certification",
|
Assert.assertTrue("error msg must be about self certification",
|
||||||
@@ -221,12 +221,12 @@ public class CertifyOperationTest {
|
|||||||
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
|
KeyWritableRepository.createDatabaseReadWriteInteractor(RuntimeEnvironment.application), null, null);
|
||||||
|
|
||||||
{
|
{
|
||||||
CertifyActionsParcel actions = new CertifyActionsParcel(mStaticRing1.getMasterKeyId());
|
CertifyActionsParcel.Builder actions = CertifyActionsParcel.builder(mStaticRing1.getMasterKeyId());
|
||||||
ArrayList<String> uids = new ArrayList<String>();
|
ArrayList<String> uids = new ArrayList<String>();
|
||||||
uids.add("nonexistent");
|
uids.add("nonexistent");
|
||||||
actions.add(new CertifyAction(1234L, uids, null));
|
actions.addAction(CertifyAction.createForUserIds(1234L, uids));
|
||||||
|
|
||||||
CertifyResult result = op.execute(actions, CryptoInputParcel.createCryptoInputParcel(new Date(),
|
CertifyResult result = op.execute(actions.build(), CryptoInputParcel.createCryptoInputParcel(new Date(),
|
||||||
mKeyPhrase1));
|
mKeyPhrase1));
|
||||||
|
|
||||||
Assert.assertFalse("certification of nonexistent key must fail", result.success());
|
Assert.assertFalse("certification of nonexistent key must fail", result.success());
|
||||||
@@ -235,11 +235,11 @@ public class CertifyOperationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
CertifyActionsParcel actions = new CertifyActionsParcel(1234L);
|
CertifyActionsParcel.Builder actions = CertifyActionsParcel.builder(1234L);
|
||||||
actions.add(new CertifyAction(mStaticRing1.getMasterKeyId(),
|
actions.addAction(CertifyAction.createForUserIds(mStaticRing1.getMasterKeyId(),
|
||||||
mStaticRing2.getPublicKey().getUnorderedUserIds(), null));
|
mStaticRing2.getPublicKey().getUnorderedUserIds()));
|
||||||
|
|
||||||
CertifyResult result = op.execute(actions, CryptoInputParcel.createCryptoInputParcel(new Date(),
|
CertifyResult result = op.execute(actions.build(), CryptoInputParcel.createCryptoInputParcel(new Date(),
|
||||||
mKeyPhrase1));
|
mKeyPhrase1));
|
||||||
|
|
||||||
Assert.assertFalse("certification of nonexistent key must fail", result.success());
|
Assert.assertFalse("certification of nonexistent key must fail", result.success());
|
||||||
|
|||||||
@@ -18,6 +18,14 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.pgp;
|
package org.sufficientlysecure.keychain.pgp;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.security.Security;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import org.bouncycastle.bcpg.BCPGInputStream;
|
import org.bouncycastle.bcpg.BCPGInputStream;
|
||||||
import org.bouncycastle.bcpg.PacketTags;
|
import org.bouncycastle.bcpg.PacketTags;
|
||||||
import org.bouncycastle.bcpg.S2K;
|
import org.bouncycastle.bcpg.S2K;
|
||||||
@@ -304,7 +312,8 @@ public class UncachedKeyringMergeTest {
|
|||||||
ringB.getEncoded(), 0).getSecretKey();
|
ringB.getEncoded(), 0).getSecretKey();
|
||||||
secretKey.unlock(new Passphrase());
|
secretKey.unlock(new Passphrase());
|
||||||
PgpCertifyOperation op = new PgpCertifyOperation();
|
PgpCertifyOperation op = new PgpCertifyOperation();
|
||||||
CertifyAction action = new CertifyAction(pubRing.getMasterKeyId(), publicRing.getPublicKey().getUnorderedUserIds(), null);
|
CertifyAction action = CertifyAction.createForUserIds(
|
||||||
|
pubRing.getMasterKeyId(), publicRing.getPublicKey().getUnorderedUserIds());
|
||||||
// sign all user ids
|
// sign all user ids
|
||||||
PgpCertifyResult result = op.certify(secretKey, publicRing, new OperationLog(), 0, action, null, new Date());
|
PgpCertifyResult result = op.certify(secretKey, publicRing, new OperationLog(), 0, action, null, new Date());
|
||||||
Assert.assertTrue("certification must succeed", result.success());
|
Assert.assertTrue("certification must succeed", result.success());
|
||||||
|
|||||||
@@ -194,11 +194,12 @@ public class KeychainExternalProviderTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void certifyKey(long secretMasterKeyId, long publicMasterKeyId, String userId) {
|
private void certifyKey(long secretMasterKeyId, long publicMasterKeyId, String userId) {
|
||||||
CertifyActionsParcel certifyActionsParcel = new CertifyActionsParcel(secretMasterKeyId);
|
CertifyActionsParcel.Builder certifyActionsParcel = CertifyActionsParcel.builder(secretMasterKeyId);
|
||||||
certifyActionsParcel.add(new CertifyAction(publicMasterKeyId, Collections.singletonList(userId), null));
|
certifyActionsParcel.addAction(
|
||||||
|
CertifyAction.createForUserIds(publicMasterKeyId, Collections.singletonList(userId)));
|
||||||
CertifyOperation op = new CertifyOperation(
|
CertifyOperation op = new CertifyOperation(
|
||||||
RuntimeEnvironment.application, databaseInteractor, new ProgressScaler(), null);
|
RuntimeEnvironment.application, databaseInteractor, new ProgressScaler(), null);
|
||||||
CertifyResult certifyResult = op.execute(certifyActionsParcel, CryptoInputParcel.createCryptoInputParcel());
|
CertifyResult certifyResult = op.execute(certifyActionsParcel.build(), CryptoInputParcel.createCryptoInputParcel());
|
||||||
|
|
||||||
assertTrue(certifyResult.success());
|
assertTrue(certifyResult.success());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user