Shifted duplicate method implementations from KeyRing to openpgp-api submodule
This commit is contained in:
@@ -21,6 +21,7 @@ import android.content.Context;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
||||
@@ -318,7 +319,7 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
||||
public void updateMergedUserIds() {
|
||||
mMergedUserIds = new HashMap<>();
|
||||
for (String userId : mUserIds) {
|
||||
KeyRing.UserId userIdSplit = KeyRing.splitUserId(userId);
|
||||
OpenPgpUtils.UserId userIdSplit = KeyRing.splitUserId(userId);
|
||||
|
||||
// TODO: comment field?
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@ package org.sufficientlysecure.keychain.pgp;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||
import org.openintents.openpgp.util.OpenPgpUtils.UserId;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -45,7 +47,7 @@ public abstract class KeyRing {
|
||||
|
||||
abstract public String getPrimaryUserIdWithFallback() throws PgpKeyNotFoundException;
|
||||
|
||||
public UserId getSplitPrimaryUserIdWithFallback() throws PgpKeyNotFoundException {
|
||||
public OpenPgpUtils.UserId getSplitPrimaryUserIdWithFallback() throws PgpKeyNotFoundException {
|
||||
return splitUserId(getPrimaryUserIdWithFallback());
|
||||
}
|
||||
|
||||
@@ -59,10 +61,6 @@ public abstract class KeyRing {
|
||||
|
||||
abstract public int getVerified() throws PgpKeyNotFoundException;
|
||||
|
||||
private static final Pattern USER_ID_PATTERN = Pattern.compile("^(.*?)(?: \\((.*)\\))?(?: <(.*)>)?$");
|
||||
|
||||
private static final Pattern EMAIL_PATTERN = Pattern.compile("^.*@.*\\..*$");
|
||||
|
||||
/**
|
||||
* Splits userId string into naming part, email part, and comment part
|
||||
* <p/>
|
||||
@@ -70,53 +68,15 @@ public abstract class KeyRing {
|
||||
* http://fiddle.re/t4p6f
|
||||
*/
|
||||
public static UserId splitUserId(final String userId) {
|
||||
if (!TextUtils.isEmpty(userId)) {
|
||||
final Matcher matcher = USER_ID_PATTERN.matcher(userId);
|
||||
if (matcher.matches()) {
|
||||
String name = matcher.group(1).isEmpty() ? null : matcher.group(1);
|
||||
String comment = matcher.group(2);
|
||||
String email = matcher.group(3);
|
||||
if (comment == null && email == null && name != null && EMAIL_PATTERN.matcher(name).matches()) {
|
||||
email = name;
|
||||
name = null;
|
||||
}
|
||||
return new UserId(name, email, comment);
|
||||
}
|
||||
}
|
||||
return new UserId(null, null, null);
|
||||
return OpenPgpUtils.splitUserId(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a composed user id. Returns null if name, email and comment are empty.
|
||||
*/
|
||||
public static String createUserId(UserId userId) {
|
||||
StringBuilder userIdBuilder = new StringBuilder();
|
||||
if (!TextUtils.isEmpty(userId.name)) {
|
||||
userIdBuilder.append(userId.name);
|
||||
}
|
||||
if (!TextUtils.isEmpty(userId.comment)) {
|
||||
userIdBuilder.append(" (");
|
||||
userIdBuilder.append(userId.comment);
|
||||
userIdBuilder.append(")");
|
||||
}
|
||||
if (!TextUtils.isEmpty(userId.email)) {
|
||||
userIdBuilder.append(" <");
|
||||
userIdBuilder.append(userId.email);
|
||||
userIdBuilder.append(">");
|
||||
}
|
||||
return userIdBuilder.length() == 0 ? null : userIdBuilder.toString();
|
||||
return OpenPgpUtils.createUserId(userId);
|
||||
}
|
||||
|
||||
public static class UserId implements Serializable {
|
||||
public final String name;
|
||||
public final String email;
|
||||
public final String comment;
|
||||
|
||||
public UserId(String name, String email, String comment) {
|
||||
this.name = name;
|
||||
this.email = email;
|
||||
this.comment = comment;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import android.os.RemoteException;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.util.LongSparseArray;
|
||||
|
||||
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
|
||||
@@ -454,7 +455,7 @@ public class ProviderHelper {
|
||||
String userId = Utf8Util.fromUTF8ByteArrayReplaceBadEncoding(rawUserId);
|
||||
UserPacketItem item = new UserPacketItem();
|
||||
uids.add(item);
|
||||
KeyRing.UserId splitUserId = KeyRing.splitUserId(userId);
|
||||
OpenPgpUtils.UserId splitUserId = KeyRing.splitUserId(userId);
|
||||
item.userId = userId;
|
||||
item.name = splitUserId.name;
|
||||
item.email = splitUserId.email;
|
||||
|
||||
@@ -53,6 +53,7 @@ import org.openintents.openpgp.OpenPgpError;
|
||||
import org.openintents.openpgp.OpenPgpMetadata;
|
||||
import org.openintents.openpgp.OpenPgpSignatureResult;
|
||||
import org.openintents.openpgp.util.OpenPgpApi;
|
||||
import org.openintents.openpgp.util.OpenPgpUtils.UserId;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.operations.BackupOperation;
|
||||
import org.sufficientlysecure.keychain.operations.results.DecryptVerifyResult;
|
||||
@@ -61,7 +62,6 @@ import org.sufficientlysecure.keychain.operations.results.OperationResult.LogEnt
|
||||
import org.sufficientlysecure.keychain.operations.results.PgpSignEncryptResult;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing.UserId;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyInputParcel;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyOperation;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpSecurityConstants;
|
||||
|
||||
@@ -26,6 +26,7 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.operations.results.EditKeyResult;
|
||||
@@ -92,7 +93,7 @@ public class AccountSettingsFragment extends Fragment {
|
||||
}
|
||||
|
||||
private void createKey() {
|
||||
KeyRing.UserId userId = KeyRing.splitUserId(mAccSettings.getAccountName());
|
||||
OpenPgpUtils.UserId userId = KeyRing.splitUserId(mAccSettings.getAccountName());
|
||||
|
||||
Intent intent = new Intent(getActivity(), CreateKeyActivity.class);
|
||||
intent.putExtra(CreateKeyActivity.EXTRA_NAME, userId.name);
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.openintents.openpgp.util.OpenPgpApi;
|
||||
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||
@@ -90,7 +91,7 @@ public class SelectSignKeyIdActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
private void createKey(String userId) {
|
||||
KeyRing.UserId userIdSplit = KeyRing.splitUserId(userId);
|
||||
OpenPgpUtils.UserId userIdSplit = KeyRing.splitUserId(userId);
|
||||
|
||||
Intent intent = new Intent(this, CreateKeyActivity.class);
|
||||
intent.putExtra(CreateKeyActivity.EXTRA_NAME, userIdSplit.name);
|
||||
|
||||
@@ -34,6 +34,7 @@ import android.widget.CheckBox;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.bouncycastle.bcpg.sig.KeyFlags;
|
||||
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.operations.results.EditKeyResult;
|
||||
@@ -305,7 +306,7 @@ public class CreateKeyFinalFragment extends Fragment {
|
||||
}
|
||||
}
|
||||
String userId = KeyRing.createUserId(
|
||||
new KeyRing.UserId(createKeyActivity.mName, createKeyActivity.mEmail, null)
|
||||
new OpenPgpUtils.UserId(createKeyActivity.mName, createKeyActivity.mEmail, null)
|
||||
);
|
||||
saveKeyringParcel.mAddUserIds.add(userId);
|
||||
saveKeyringParcel.mChangePrimaryUserId = userId;
|
||||
@@ -313,7 +314,7 @@ public class CreateKeyFinalFragment extends Fragment {
|
||||
&& createKeyActivity.mAdditionalEmails.size() > 0) {
|
||||
for (String email : createKeyActivity.mAdditionalEmails) {
|
||||
String thisUserId = KeyRing.createUserId(
|
||||
new KeyRing.UserId(createKeyActivity.mName, email, null)
|
||||
new OpenPgpUtils.UserId(createKeyActivity.mName, email, null)
|
||||
);
|
||||
saveKeyringParcel.mAddUserIds.add(thisUserId);
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ import android.widget.ViewAnimator;
|
||||
|
||||
import org.openintents.openpgp.OpenPgpDecryptionResult;
|
||||
import org.openintents.openpgp.OpenPgpSignatureResult;
|
||||
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
|
||||
@@ -308,7 +309,7 @@ public abstract class DecryptFragment extends Fragment implements LoaderManager.
|
||||
long signatureKeyId = mSignatureResult.getKeyId();
|
||||
|
||||
String userId = data.getString(INDEX_USER_ID);
|
||||
KeyRing.UserId userIdSplit = KeyRing.splitUserId(userId);
|
||||
OpenPgpUtils.UserId userIdSplit = KeyRing.splitUserId(userId);
|
||||
if (userIdSplit.name != null) {
|
||||
mSignatureName.setText(userIdSplit.name);
|
||||
} else {
|
||||
@@ -418,7 +419,7 @@ public abstract class DecryptFragment extends Fragment implements LoaderManager.
|
||||
}
|
||||
|
||||
String userId = mSignatureResult.getPrimaryUserId();
|
||||
KeyRing.UserId userIdSplit = KeyRing.splitUserId(userId);
|
||||
OpenPgpUtils.UserId userIdSplit = KeyRing.splitUserId(userId);
|
||||
if (userIdSplit.name != null) {
|
||||
mSignatureName.setText(userIdSplit.name);
|
||||
} else {
|
||||
|
||||
@@ -35,6 +35,7 @@ import android.widget.AdapterView;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.operations.results.DeleteResult;
|
||||
@@ -100,7 +101,7 @@ public class DeleteKeyDialogActivity extends FragmentActivity {
|
||||
);
|
||||
|
||||
String name;
|
||||
KeyRing.UserId mainUserId = KeyRing.splitUserId(
|
||||
OpenPgpUtils.UserId mainUserId = KeyRing.splitUserId(
|
||||
(String) data.get(KeychainContract.KeyRings.USER_ID));
|
||||
if (mainUserId.name != null) {
|
||||
name = mainUserId.name;
|
||||
@@ -280,7 +281,7 @@ public class DeleteKeyDialogActivity extends FragmentActivity {
|
||||
}
|
||||
);
|
||||
String name;
|
||||
KeyRing.UserId mainUserId = KeyRing.splitUserId((String) data.get(KeychainContract.KeyRings.USER_ID));
|
||||
OpenPgpUtils.UserId mainUserId = KeyRing.splitUserId((String) data.get(KeychainContract.KeyRings.USER_ID));
|
||||
if (mainUserId.name != null) {
|
||||
name = mainUserId.name;
|
||||
} else {
|
||||
|
||||
@@ -58,6 +58,7 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.operations.results.SignEncryptResult;
|
||||
@@ -704,7 +705,7 @@ public class EncryptFilesFragment
|
||||
|
||||
Set<String> users = new HashSet<>();
|
||||
for (String user : encryptionUserIds) {
|
||||
KeyRing.UserId userId = KeyRing.splitUserId(user);
|
||||
OpenPgpUtils.UserId userId = KeyRing.splitUserId(user);
|
||||
if (userId.email != null) {
|
||||
users.add(userId.email);
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.operations.results.SignEncryptResult;
|
||||
@@ -326,7 +327,7 @@ public class EncryptTextFragment
|
||||
|
||||
Set<String> users = new HashSet<>();
|
||||
for (String user : encryptionUserIds) {
|
||||
KeyRing.UserId userId = KeyRing.splitUserId(user);
|
||||
OpenPgpUtils.UserId userId = KeyRing.splitUserId(user);
|
||||
if (userId.email != null) {
|
||||
users.add(userId.email);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ListView;
|
||||
|
||||
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
@@ -151,7 +152,7 @@ public class MultiUserIdsFragment extends Fragment implements LoaderManager.Load
|
||||
while (!data.isAfterLast()) {
|
||||
long masterKeyId = data.getLong(INDEX_MASTER_KEY_ID);
|
||||
String userId = data.getString(INDEX_USER_ID);
|
||||
KeyRing.UserId pieces = KeyRing.splitUserId(userId);
|
||||
OpenPgpUtils.UserId pieces = KeyRing.splitUserId(userId);
|
||||
|
||||
// Two cases:
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.widget.ViewAnimator;
|
||||
|
||||
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey;
|
||||
@@ -236,7 +237,7 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
||||
// above can't be statically verified to have been set in all cases because
|
||||
// the catch clause doesn't return.
|
||||
String mainUserId = cachedPublicKeyRing.getPrimaryUserIdWithFallback();
|
||||
KeyRing.UserId mainUserIdSplit = KeyRing.splitUserId(mainUserId);
|
||||
OpenPgpUtils.UserId mainUserIdSplit = KeyRing.splitUserId(mainUserId);
|
||||
if (mainUserIdSplit.name != null) {
|
||||
userId = mainUserIdSplit.name;
|
||||
} else {
|
||||
|
||||
@@ -67,6 +67,7 @@ import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
|
||||
@@ -877,7 +878,7 @@ public class ViewKeyActivity extends BaseSecurityTokenActivity implements
|
||||
|
||||
if (data.moveToFirst()) {
|
||||
// get name, email, and comment from USER_ID
|
||||
KeyRing.UserId mainUserId = KeyRing.splitUserId(data.getString(INDEX_USER_ID));
|
||||
OpenPgpUtils.UserId mainUserId = KeyRing.splitUserId(data.getString(INDEX_USER_ID));
|
||||
if (mainUserId.name != null) {
|
||||
mCollapsingToolbarLayout.setTitle(mainUserId.name);
|
||||
} else {
|
||||
|
||||
@@ -41,6 +41,7 @@ import android.widget.Toast;
|
||||
|
||||
import com.astuetz.PagerSlidingTabStrip;
|
||||
|
||||
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||
@@ -213,7 +214,7 @@ public class ViewKeyAdvActivity extends BaseActivity implements
|
||||
case LOADER_ID_UNIFIED: {
|
||||
if (data.moveToFirst()) {
|
||||
// get name, email, and comment from USER_ID
|
||||
KeyRing.UserId mainUserId = KeyRing.splitUserId(data.getString(INDEX_USER_ID));
|
||||
OpenPgpUtils.UserId mainUserId = KeyRing.splitUserId(data.getString(INDEX_USER_ID));
|
||||
if (mainUserId.name != null) {
|
||||
setTitle(mainUserId.name);
|
||||
} else {
|
||||
|
||||
@@ -32,6 +32,7 @@ import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
@@ -237,7 +238,7 @@ public class ViewKeyAdvCertsFragment extends LoaderFragment implements
|
||||
TextView wSignStatus = (TextView) view.findViewById(R.id.signStatus);
|
||||
|
||||
String signerKeyId = KeyFormattingUtils.beautifyKeyIdWithPrefix(getActivity(), cursor.getLong(mIndexSignerKeyId));
|
||||
KeyRing.UserId userId = KeyRing.splitUserId(cursor.getString(mIndexSignerUserId));
|
||||
OpenPgpUtils.UserId userId = KeyRing.splitUserId(cursor.getString(mIndexSignerUserId));
|
||||
if (userId.name != null) {
|
||||
wSignerName.setText(userId.name);
|
||||
} else {
|
||||
|
||||
@@ -51,6 +51,7 @@ import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
@@ -247,7 +248,7 @@ public class ViewKeyAdvShareFragment extends LoaderFragment implements
|
||||
TemporaryFileProvider shareFileProv = new TemporaryFileProvider();
|
||||
|
||||
String filename = KeyFormattingUtils.convertFingerprintToHex(mFingerprint);
|
||||
KeyRing.UserId mainUserId = KeyRing.splitUserId(mUserId);
|
||||
OpenPgpUtils.UserId mainUserId = KeyRing.splitUserId(mUserId);
|
||||
if (mainUserId.name != null) {
|
||||
filename = mainUserId.name;
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry;
|
||||
import org.sufficientlysecure.keychain.operations.ImportOperation;
|
||||
@@ -141,7 +142,7 @@ public class ImportKeysAdapter extends ArrayAdapter<ImportKeysListEntry> {
|
||||
|
||||
// main user id
|
||||
String userId = entry.getUserIds().get(0);
|
||||
KeyRing.UserId userIdSplit = KeyRing.splitUserId(userId);
|
||||
OpenPgpUtils.UserId userIdSplit = KeyRing.splitUserId(userId);
|
||||
|
||||
// name
|
||||
if (userIdSplit.name != null) {
|
||||
|
||||
@@ -38,6 +38,7 @@ import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKey;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing;
|
||||
@@ -125,7 +126,7 @@ public class KeyAdapter extends CursorAdapter {
|
||||
mDisplayedItem = item;
|
||||
|
||||
{ // set name and stuff, common to both key types
|
||||
KeyRing.UserId userIdSplit = item.mUserId;
|
||||
OpenPgpUtils.UserId userIdSplit = item.mUserId;
|
||||
if (userIdSplit.name != null) {
|
||||
mMainUserId.setText(highlighter.highlight(userIdSplit.name));
|
||||
} else {
|
||||
@@ -288,7 +289,7 @@ public class KeyAdapter extends CursorAdapter {
|
||||
public static class KeyItem implements Serializable {
|
||||
|
||||
public final String mUserIdFull;
|
||||
public final KeyRing.UserId mUserId;
|
||||
public final OpenPgpUtils.UserId mUserId;
|
||||
public final long mKeyId;
|
||||
public final boolean mHasDuplicate;
|
||||
public final boolean mHasEncrypt;
|
||||
|
||||
@@ -30,6 +30,7 @@ import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
import org.sufficientlysecure.keychain.service.CertifyActionsParcel.CertifyAction;
|
||||
@@ -87,7 +88,7 @@ public class MultiUserIdsAdapter extends CursorAdapter {
|
||||
|
||||
{ // first one
|
||||
String userId = uids.get(0);
|
||||
KeyRing.UserId splitUserId = KeyRing.splitUserId(userId);
|
||||
OpenPgpUtils.UserId splitUserId = KeyRing.splitUserId(userId);
|
||||
if (splitUserId.name != null) {
|
||||
vName.setText(splitUserId.name);
|
||||
} else {
|
||||
@@ -112,7 +113,7 @@ public class MultiUserIdsAdapter extends CursorAdapter {
|
||||
|
||||
StringBuilder lines = new StringBuilder();
|
||||
for (String uid : uids) {
|
||||
KeyRing.UserId splitUserId = KeyRing.splitUserId(uid);
|
||||
OpenPgpUtils.UserId splitUserId = KeyRing.splitUserId(uid);
|
||||
if (splitUserId.email == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
@@ -118,7 +119,7 @@ abstract public class SelectKeyCursorAdapter extends CursorAdapter {
|
||||
ViewHolderItem h = (ViewHolderItem) view.getTag();
|
||||
|
||||
String userId = cursor.getString(mIndexUserId);
|
||||
KeyRing.UserId userIdSplit = KeyRing.splitUserId(userId);
|
||||
OpenPgpUtils.UserId userIdSplit = KeyRing.splitUserId(userId);
|
||||
|
||||
if (userIdSplit.name != null) {
|
||||
h.mainUserId.setText(highlighter.highlight(userIdSplit.name));
|
||||
|
||||
@@ -32,6 +32,7 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.ViewAnimator;
|
||||
|
||||
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.Certs;
|
||||
@@ -70,7 +71,7 @@ public class UserIdsAdapter extends UserAttributesAdapter {
|
||||
vDeleteButton.setVisibility(View.GONE); // not used
|
||||
|
||||
String userId = cursor.getString(INDEX_USER_ID);
|
||||
KeyRing.UserId splitUserId = KeyRing.splitUserId(userId);
|
||||
OpenPgpUtils.UserId splitUserId = KeyRing.splitUserId(userId);
|
||||
if (splitUserId.name != null) {
|
||||
vName.setText(splitUserId.name);
|
||||
} else {
|
||||
|
||||
@@ -28,6 +28,7 @@ import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
|
||||
@@ -92,7 +93,7 @@ public class UserIdsAddedAdapter extends ArrayAdapter<String> {
|
||||
// save reference to model item
|
||||
holder.mModel = getItem(position);
|
||||
|
||||
KeyRing.UserId splitUserId = KeyRing.splitUserId(holder.mModel);
|
||||
OpenPgpUtils.UserId splitUserId = KeyRing.splitUserId(holder.mModel);
|
||||
if (splitUserId.name != null) {
|
||||
holder.vName.setText(splitUserId.name);
|
||||
} else {
|
||||
|
||||
@@ -38,6 +38,7 @@ import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.TextView.OnEditorActionListener;
|
||||
|
||||
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
@@ -110,7 +111,7 @@ public class AddUserIdDialogFragment extends DialogFragment implements OnEditorA
|
||||
|
||||
// return new user id back to activity
|
||||
Bundle data = new Bundle();
|
||||
String userId = KeyRing.createUserId(new KeyRing.UserId(mName.getText().toString(),
|
||||
String userId = KeyRing.createUserId(new OpenPgpUtils.UserId(mName.getText().toString(),
|
||||
mEmail.getText().toString(), mComment.getText().toString()));
|
||||
data.putString(MESSAGE_DATA_USER_ID, userId);
|
||||
sendMessageToHandler(MESSAGE_OKAY, data);
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.bouncycastle.asn1.nist.NISTNamedCurves;
|
||||
import org.bouncycastle.asn1.teletrust.TeleTrusTNamedCurves;
|
||||
import org.bouncycastle.bcpg.PublicKeyAlgorithmTags;
|
||||
import org.bouncycastle.util.encoders.Hex;
|
||||
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.operations.results.DecryptVerifyResult;
|
||||
@@ -593,7 +594,7 @@ public class KeyFormattingUtils {
|
||||
holder.getSignatureAction().setDisplayedChild(sigActionDisplayedChild);
|
||||
|
||||
String userId = result.getSignatureResult().getPrimaryUserId();
|
||||
KeyRing.UserId userIdSplit = KeyRing.splitUserId(userId);
|
||||
OpenPgpUtils.UserId userIdSplit = KeyRing.splitUserId(userId);
|
||||
if (userIdSplit.name != null) {
|
||||
holder.getSignatureUserName().setText(userIdSplit.name);
|
||||
} else {
|
||||
|
||||
@@ -34,6 +34,7 @@ import android.provider.ContactsContract;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.util.Patterns;
|
||||
|
||||
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
@@ -503,7 +504,7 @@ public class ContactHelper {
|
||||
if (cursor != null) {
|
||||
while (cursor.moveToNext()) {
|
||||
long masterKeyId = cursor.getLong(INDEX_MASTER_KEY_ID);
|
||||
KeyRing.UserId userIdSplit = KeyRing.splitUserId(cursor.getString(INDEX_USER_ID));
|
||||
OpenPgpUtils.UserId userIdSplit = KeyRing.splitUserId(cursor.getString(INDEX_USER_ID));
|
||||
boolean isExpired = cursor.getInt(INDEX_IS_EXPIRED) != 0;
|
||||
boolean isRevoked = cursor.getInt(INDEX_IS_REVOKED) > 0;
|
||||
boolean isVerified = cursor.getInt(INDEX_VERIFIED) > 0;
|
||||
@@ -578,7 +579,7 @@ public class ContactHelper {
|
||||
long masterKeyId = cursor.getLong(INDEX_MASTER_KEY_ID);
|
||||
boolean isExpired = cursor.getInt(INDEX_IS_EXPIRED) != 0;
|
||||
boolean isRevoked = cursor.getInt(INDEX_IS_REVOKED) > 0;
|
||||
KeyRing.UserId userIdSplit = KeyRing.splitUserId(cursor.getString(INDEX_USER_ID));
|
||||
OpenPgpUtils.UserId userIdSplit = KeyRing.splitUserId(cursor.getString(INDEX_USER_ID));
|
||||
|
||||
if (!isExpired && !isRevoked && userIdSplit.name != null) {
|
||||
// if expired or revoked will not be removed from keysToDelete or inserted
|
||||
@@ -840,7 +841,7 @@ public class ContactHelper {
|
||||
null, null);
|
||||
if (ids != null) {
|
||||
while (ids.moveToNext()) {
|
||||
KeyRing.UserId userId = KeyRing.splitUserId(ids.getString(0));
|
||||
OpenPgpUtils.UserId userId = KeyRing.splitUserId(ids.getString(0));
|
||||
if (userId.email != null) {
|
||||
ops.add(referenceRawContact(
|
||||
ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI),
|
||||
|
||||
@@ -20,6 +20,7 @@ package org.sufficientlysecure.keychain.pgp;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||
import org.robolectric.RobolectricGradleTestRunner;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.annotation.Config;
|
||||
@@ -32,7 +33,7 @@ public class SplitUserIdTest {
|
||||
|
||||
@Test
|
||||
public void splitCompleteUserIdShouldReturnAll3Components() throws Exception {
|
||||
KeyRing.UserId info = KeyRing.splitUserId("Max Mustermann (this is a comment) <max@example.com>");
|
||||
OpenPgpUtils.UserId info = KeyRing.splitUserId("Max Mustermann (this is a comment) <max@example.com>");
|
||||
Assert.assertEquals("Max Mustermann", info.name);
|
||||
Assert.assertEquals("this is a comment", info.comment);
|
||||
Assert.assertEquals("max@example.com", info.email);
|
||||
@@ -40,7 +41,7 @@ public class SplitUserIdTest {
|
||||
|
||||
@Test
|
||||
public void splitUserIdWithAllButCommentShouldReturnNameAndEmail() throws Exception {
|
||||
KeyRing.UserId info = KeyRing.splitUserId("Max Mustermann <max@example.com>");
|
||||
OpenPgpUtils.UserId info = KeyRing.splitUserId("Max Mustermann <max@example.com>");
|
||||
Assert.assertEquals("Max Mustermann", info.name);
|
||||
Assert.assertNull(info.comment);
|
||||
Assert.assertEquals("max@example.com", info.email);
|
||||
@@ -48,7 +49,7 @@ public class SplitUserIdTest {
|
||||
|
||||
@Test
|
||||
public void splitUserIdWithAllButEmailShouldReturnNameAndComment() throws Exception {
|
||||
KeyRing.UserId info = KeyRing.splitUserId("Max Mustermann (this is a comment)");
|
||||
OpenPgpUtils.UserId info = KeyRing.splitUserId("Max Mustermann (this is a comment)");
|
||||
Assert.assertEquals("Max Mustermann", info.name);
|
||||
Assert.assertEquals("this is a comment", info.comment);
|
||||
Assert.assertNull(info.email);
|
||||
@@ -56,7 +57,7 @@ public class SplitUserIdTest {
|
||||
|
||||
@Test
|
||||
public void splitUserIdWithCommentAndEmailShouldReturnCommentAndEmail() throws Exception {
|
||||
KeyRing.UserId info = KeyRing.splitUserId(" (this is a comment) <max@example.com>");
|
||||
OpenPgpUtils.UserId info = KeyRing.splitUserId(" (this is a comment) <max@example.com>");
|
||||
Assert.assertNull(info.name);
|
||||
Assert.assertEquals("this is a comment", info.comment);
|
||||
Assert.assertEquals("max@example.com", info.email);
|
||||
@@ -64,7 +65,7 @@ public class SplitUserIdTest {
|
||||
|
||||
@Test
|
||||
public void splitUserIdWithEmailShouldReturnEmail() throws Exception {
|
||||
KeyRing.UserId info = KeyRing.splitUserId("max@example.com");
|
||||
OpenPgpUtils.UserId info = KeyRing.splitUserId("max@example.com");
|
||||
Assert.assertNull(info.name);
|
||||
Assert.assertNull(info.comment);
|
||||
Assert.assertEquals("max@example.com", info.email);
|
||||
@@ -72,7 +73,7 @@ public class SplitUserIdTest {
|
||||
|
||||
@Test
|
||||
public void splitUserIdWithNameShouldReturnName() throws Exception {
|
||||
KeyRing.UserId info = KeyRing.splitUserId("Max Mustermann");
|
||||
OpenPgpUtils.UserId info = KeyRing.splitUserId("Max Mustermann");
|
||||
Assert.assertEquals("Max Mustermann", info.name);
|
||||
Assert.assertNull(info.comment);
|
||||
Assert.assertNull(info.email);
|
||||
@@ -80,7 +81,7 @@ public class SplitUserIdTest {
|
||||
|
||||
@Test
|
||||
public void splitUserIdWithCommentShouldReturnComment() throws Exception {
|
||||
KeyRing.UserId info = KeyRing.splitUserId(" (this is a comment)");
|
||||
OpenPgpUtils.UserId info = KeyRing.splitUserId(" (this is a comment)");
|
||||
Assert.assertNull(info.name);
|
||||
Assert.assertEquals("this is a comment", info.comment);
|
||||
Assert.assertNull(info.email);
|
||||
|
||||
2
extern/openpgp-api-lib
vendored
2
extern/openpgp-api-lib
vendored
Submodule extern/openpgp-api-lib updated: e61c349b9e...32794ee94f
Reference in New Issue
Block a user