mirror of
https://github.com/moparisthebest/open-keychain
synced 2025-01-31 07:00:24 -05:00
Merge branch 'master' of github.com:open-keychain/open-keychain
This commit is contained in:
commit
a67854ca6a
@ -67,6 +67,7 @@ import java.io.InputStream;
|
|||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.security.SignatureException;
|
import java.security.SignatureException;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -410,11 +411,18 @@ public class PgpDecryptVerify {
|
|||||||
// go through all signatures
|
// go through all signatures
|
||||||
// and find out for which signature we have a key in our database
|
// and find out for which signature we have a key in our database
|
||||||
Long masterKeyId = null;
|
Long masterKeyId = null;
|
||||||
|
String primaryUserId = null;
|
||||||
for (int i = 0; i < sigList.size(); ++i) {
|
for (int i = 0; i < sigList.size(); ++i) {
|
||||||
try {
|
try {
|
||||||
Uri uri = KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(
|
Uri uri = KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(
|
||||||
Long.toString(sigList.get(i).getKeyID()));
|
Long.toString(sigList.get(i).getKeyID()));
|
||||||
masterKeyId = mProviderHelper.getMasterKeyId(uri);
|
Map<String, Object> data = mProviderHelper.getGenericData(uri,
|
||||||
|
new String[] { KeyRings.MASTER_KEY_ID, KeyRings.USER_ID },
|
||||||
|
new int[] { ProviderHelper.FIELD_TYPE_INTEGER,
|
||||||
|
ProviderHelper.FIELD_TYPE_STRING }
|
||||||
|
);
|
||||||
|
masterKeyId = (Long) data.get(KeyRings.MASTER_KEY_ID);
|
||||||
|
primaryUserId = (String) data.get(KeyRings.USER_ID);
|
||||||
signatureIndex = i;
|
signatureIndex = i;
|
||||||
} catch (ProviderHelper.NotFoundException e) {
|
} catch (ProviderHelper.NotFoundException e) {
|
||||||
Log.d(Constants.TAG, "key not found!");
|
Log.d(Constants.TAG, "key not found!");
|
||||||
@ -439,9 +447,8 @@ public class PgpDecryptVerify {
|
|||||||
|
|
||||||
signatureResultBuilder.signatureAvailable(true);
|
signatureResultBuilder.signatureAvailable(true);
|
||||||
signatureResultBuilder.knownKey(true);
|
signatureResultBuilder.knownKey(true);
|
||||||
// TODO: uses the first user id not primary user id
|
signatureResultBuilder.userId(primaryUserId);
|
||||||
signatureResultBuilder.userId(PgpKeyHelper.getMainUserId(publicKeyRing.getPublicKey()));
|
signatureResultBuilder.keyId(masterKeyId);
|
||||||
signatureResultBuilder.keyId(publicKeyRing.getPublicKey().getKeyID());
|
|
||||||
|
|
||||||
JcaPGPContentVerifierBuilderProvider contentVerifierBuilderProvider =
|
JcaPGPContentVerifierBuilderProvider contentVerifierBuilderProvider =
|
||||||
new JcaPGPContentVerifierBuilderProvider()
|
new JcaPGPContentVerifierBuilderProvider()
|
||||||
@ -449,11 +456,16 @@ public class PgpDecryptVerify {
|
|||||||
signature.init(contentVerifierBuilderProvider, signatureKey);
|
signature.init(contentVerifierBuilderProvider, signatureKey);
|
||||||
|
|
||||||
// get certification status of this key
|
// get certification status of this key
|
||||||
|
boolean isSignatureKeyCertified;
|
||||||
|
try {
|
||||||
Object data = mProviderHelper.getGenericData(
|
Object data = mProviderHelper.getGenericData(
|
||||||
KeychainContract.KeyRings.buildUnifiedKeyRingUri(Long.toString(masterKeyId)),
|
KeychainContract.KeyRings.buildUnifiedKeyRingUri(Long.toString(masterKeyId)),
|
||||||
KeyRings.VERIFIED,
|
KeyRings.VERIFIED,
|
||||||
ProviderHelper.FIELD_TYPE_INTEGER);
|
ProviderHelper.FIELD_TYPE_INTEGER);
|
||||||
boolean isSignatureKeyCertified = ((Long) data > 0);
|
isSignatureKeyCertified = ((Long) data > 0);
|
||||||
|
} catch (ProviderHelper.NotFoundException e) {
|
||||||
|
isSignatureKeyCertified = false;
|
||||||
|
}
|
||||||
signatureResultBuilder.signatureKeyCertified(isSignatureKeyCertified);
|
signatureResultBuilder.signatureKeyCertified(isSignatureKeyCertified);
|
||||||
} else {
|
} else {
|
||||||
// no key in our database -> return "unknown pub key" status including the first key id
|
// no key in our database -> return "unknown pub key" status including the first key id
|
||||||
@ -608,12 +620,19 @@ public class PgpDecryptVerify {
|
|||||||
// go through all signatures
|
// go through all signatures
|
||||||
// and find out for which signature we have a key in our database
|
// and find out for which signature we have a key in our database
|
||||||
Long masterKeyId = null;
|
Long masterKeyId = null;
|
||||||
|
String primaryUserId = null;
|
||||||
int signatureIndex = 0;
|
int signatureIndex = 0;
|
||||||
for (int i = 0; i < sigList.size(); ++i) {
|
for (int i = 0; i < sigList.size(); ++i) {
|
||||||
try {
|
try {
|
||||||
Uri uri = KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(
|
Uri uri = KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(
|
||||||
Long.toString(sigList.get(i).getKeyID()));
|
Long.toString(sigList.get(i).getKeyID()));
|
||||||
masterKeyId = mProviderHelper.getMasterKeyId(uri);
|
Map<String, Object> data = mProviderHelper.getGenericData(uri,
|
||||||
|
new String[] { KeyRings.MASTER_KEY_ID, KeyRings.USER_ID },
|
||||||
|
new int[] { ProviderHelper.FIELD_TYPE_INTEGER,
|
||||||
|
ProviderHelper.FIELD_TYPE_STRING }
|
||||||
|
);
|
||||||
|
masterKeyId = (Long) data.get(KeyRings.MASTER_KEY_ID);
|
||||||
|
primaryUserId = (String) data.get(KeyRings.USER_ID);
|
||||||
signatureIndex = i;
|
signatureIndex = i;
|
||||||
} catch (ProviderHelper.NotFoundException e) {
|
} catch (ProviderHelper.NotFoundException e) {
|
||||||
Log.d(Constants.TAG, "key not found!");
|
Log.d(Constants.TAG, "key not found!");
|
||||||
@ -640,9 +659,8 @@ public class PgpDecryptVerify {
|
|||||||
|
|
||||||
signatureResultBuilder.signatureAvailable(true);
|
signatureResultBuilder.signatureAvailable(true);
|
||||||
signatureResultBuilder.knownKey(true);
|
signatureResultBuilder.knownKey(true);
|
||||||
// TODO: uses the first user id not primary user id
|
signatureResultBuilder.userId(primaryUserId);
|
||||||
signatureResultBuilder.userId(PgpKeyHelper.getMainUserId(publicKeyRing.getPublicKey()));
|
signatureResultBuilder.keyId(masterKeyId);
|
||||||
signatureResultBuilder.keyId(publicKeyRing.getPublicKey().getKeyID());
|
|
||||||
|
|
||||||
JcaPGPContentVerifierBuilderProvider contentVerifierBuilderProvider =
|
JcaPGPContentVerifierBuilderProvider contentVerifierBuilderProvider =
|
||||||
new JcaPGPContentVerifierBuilderProvider()
|
new JcaPGPContentVerifierBuilderProvider()
|
||||||
@ -650,11 +668,16 @@ public class PgpDecryptVerify {
|
|||||||
signature.init(contentVerifierBuilderProvider, signatureKey);
|
signature.init(contentVerifierBuilderProvider, signatureKey);
|
||||||
|
|
||||||
// get certification status of this key
|
// get certification status of this key
|
||||||
|
boolean isSignatureKeyCertified;
|
||||||
|
try {
|
||||||
Object data = mProviderHelper.getGenericData(
|
Object data = mProviderHelper.getGenericData(
|
||||||
KeychainContract.KeyRings.buildUnifiedKeyRingUri(Long.toString(masterKeyId)),
|
KeychainContract.KeyRings.buildUnifiedKeyRingUri(Long.toString(masterKeyId)),
|
||||||
KeyRings.VERIFIED,
|
KeyRings.VERIFIED,
|
||||||
ProviderHelper.FIELD_TYPE_INTEGER);
|
ProviderHelper.FIELD_TYPE_INTEGER);
|
||||||
boolean isSignatureKeyCertified = ((Long) data > 0);
|
isSignatureKeyCertified = ((Long) data > 0);
|
||||||
|
} catch (ProviderHelper.NotFoundException e) {
|
||||||
|
isSignatureKeyCertified = false;
|
||||||
|
}
|
||||||
signatureResultBuilder.signatureKeyCertified(isSignatureKeyCertified);
|
signatureResultBuilder.signatureKeyCertified(isSignatureKeyCertified);
|
||||||
} else {
|
} else {
|
||||||
// no key in our database -> return "unknown pub key" status including the first key id
|
// no key in our database -> return "unknown pub key" status including the first key id
|
||||||
|
@ -225,38 +225,6 @@ public class PgpKeyHelper {
|
|||||||
return signingKeys.get(0);
|
return signingKeys.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public static String getMainUserId(PGPPublicKey key) {
|
|
||||||
for (String userId : new IterableIterator<String>(key.getUserIDs())) {
|
|
||||||
return userId;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public static String getMainUserId(PGPSecretKey key) {
|
|
||||||
for (String userId : new IterableIterator<String>(key.getUserIDs())) {
|
|
||||||
return userId;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getMainUserIdSafe(Context context, PGPPublicKey key) {
|
|
||||||
String userId = getMainUserId(key);
|
|
||||||
if (userId == null || userId.equals("")) {
|
|
||||||
userId = context.getString(R.string.user_id_no_name);
|
|
||||||
}
|
|
||||||
return userId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getMainUserIdSafe(Context context, PGPSecretKey key) {
|
|
||||||
String userId = getMainUserId(key);
|
|
||||||
if (userId == null || userId.equals("")) {
|
|
||||||
userId = context.getString(R.string.user_id_no_name);
|
|
||||||
}
|
|
||||||
return userId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getKeyUsage(PGPSecretKey key) {
|
public static int getKeyUsage(PGPSecretKey key) {
|
||||||
return getKeyUsage(key.getPublicKey());
|
return getKeyUsage(key.getPublicKey());
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@ import org.spongycastle.openpgp.operator.jcajce.JcePGPDataEncryptorBuilder;
|
|||||||
import org.spongycastle.openpgp.operator.jcajce.JcePublicKeyKeyEncryptionMethodGenerator;
|
import org.spongycastle.openpgp.operator.jcajce.JcePublicKeyKeyEncryptionMethodGenerator;
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
|
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||||
import org.sufficientlysecure.keychain.util.InputData;
|
import org.sufficientlysecure.keychain.util.InputData;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
@ -281,9 +282,12 @@ public class PgpSignEncrypt {
|
|||||||
PGPSecretKey signingKey = null;
|
PGPSecretKey signingKey = null;
|
||||||
PGPSecretKeyRing signingKeyRing = null;
|
PGPSecretKeyRing signingKeyRing = null;
|
||||||
PGPPrivateKey signaturePrivateKey = null;
|
PGPPrivateKey signaturePrivateKey = null;
|
||||||
|
String signingUserId = null;
|
||||||
if (enableSignature) {
|
if (enableSignature) {
|
||||||
try {
|
try {
|
||||||
signingKeyRing = mProviderHelper.getPGPSecretKeyRing(mSignatureMasterKeyId);
|
signingKeyRing = mProviderHelper.getPGPSecretKeyRing(mSignatureMasterKeyId);
|
||||||
|
signingUserId = (String) mProviderHelper.getUnifiedData(mSignatureMasterKeyId,
|
||||||
|
KeychainContract.KeyRings.USER_ID, ProviderHelper.FIELD_TYPE_STRING);
|
||||||
} catch (ProviderHelper.NotFoundException e) {
|
} catch (ProviderHelper.NotFoundException e) {
|
||||||
throw new NoSigningKeyException();
|
throw new NoSigningKeyException();
|
||||||
}
|
}
|
||||||
@ -369,9 +373,8 @@ public class PgpSignEncrypt {
|
|||||||
signatureGenerator = new PGPSignatureGenerator(contentSignerBuilder);
|
signatureGenerator = new PGPSignatureGenerator(contentSignerBuilder);
|
||||||
signatureGenerator.init(signatureType, signaturePrivateKey);
|
signatureGenerator.init(signatureType, signaturePrivateKey);
|
||||||
|
|
||||||
String userId = PgpKeyHelper.getMainUserId(signingKeyRing.getSecretKey());
|
|
||||||
PGPSignatureSubpacketGenerator spGen = new PGPSignatureSubpacketGenerator();
|
PGPSignatureSubpacketGenerator spGen = new PGPSignatureSubpacketGenerator();
|
||||||
spGen.setSignerUserID(false, userId);
|
spGen.setSignerUserID(false, signingUserId);
|
||||||
signatureGenerator.setHashedSubpackets(spGen.generate());
|
signatureGenerator.setHashedSubpackets(spGen.generate());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,11 +91,12 @@ public class ProviderHelper {
|
|||||||
public static final int FIELD_TYPE_STRING = 4;
|
public static final int FIELD_TYPE_STRING = 4;
|
||||||
public static final int FIELD_TYPE_BLOB = 5;
|
public static final int FIELD_TYPE_BLOB = 5;
|
||||||
|
|
||||||
public Object getGenericData(Uri uri, String column, int type) {
|
public Object getGenericData(Uri uri, String column, int type) throws NotFoundException {
|
||||||
return getGenericData(uri, new String[]{column}, new int[]{type}).get(column);
|
return getGenericData(uri, new String[]{column}, new int[]{type}).get(column);
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<String, Object> getGenericData(Uri uri, String[] proj, int[] types) {
|
public HashMap<String, Object> getGenericData(Uri uri, String[] proj, int[] types)
|
||||||
|
throws NotFoundException {
|
||||||
Cursor cursor = mContentResolver.query(uri, proj, null, null, null);
|
Cursor cursor = mContentResolver.query(uri, proj, null, null, null);
|
||||||
|
|
||||||
HashMap<String, Object> result = new HashMap<String, Object>(proj.length);
|
HashMap<String, Object> result = new HashMap<String, Object>(proj.length);
|
||||||
@ -130,11 +131,13 @@ public class ProviderHelper {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getUnifiedData(long masterKeyId, String column, int type) {
|
public Object getUnifiedData(long masterKeyId, String column, int type)
|
||||||
|
throws NotFoundException {
|
||||||
return getUnifiedData(masterKeyId, new String[]{column}, new int[]{type}).get(column);
|
return getUnifiedData(masterKeyId, new String[]{column}, new int[]{type}).get(column);
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<String, Object> getUnifiedData(long masterKeyId, String[] proj, int[] types) {
|
public HashMap<String, Object> getUnifiedData(long masterKeyId, String[] proj, int[] types)
|
||||||
|
throws NotFoundException {
|
||||||
return getGenericData(KeyRings.buildUnifiedKeyRingUri(Long.toString(masterKeyId)), proj, types);
|
return getGenericData(KeyRings.buildUnifiedKeyRingUri(Long.toString(masterKeyId)), proj, types);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,15 +201,20 @@ public class EncryptAsymmetricFragment extends Fragment {
|
|||||||
mMainUserIdRest.setText("");
|
mMainUserIdRest.setText("");
|
||||||
} else {
|
} else {
|
||||||
// See if we can get a user_id from a unified query
|
// See if we can get a user_id from a unified query
|
||||||
|
String[] userId;
|
||||||
|
try {
|
||||||
String userIdResult = (String) mProviderHelper.getUnifiedData(
|
String userIdResult = (String) mProviderHelper.getUnifiedData(
|
||||||
mSecretKeyId, KeyRings.USER_ID, ProviderHelper.FIELD_TYPE_STRING);
|
mSecretKeyId, KeyRings.USER_ID, ProviderHelper.FIELD_TYPE_STRING);
|
||||||
String[] userId = PgpKeyHelper.splitUserId(userIdResult);
|
userId = PgpKeyHelper.splitUserId(userIdResult);
|
||||||
if (userId[0] != null) {
|
} catch (ProviderHelper.NotFoundException e) {
|
||||||
|
userId = null;
|
||||||
|
}
|
||||||
|
if (userId != null && userId[0] != null) {
|
||||||
mMainUserId.setText(userId[0]);
|
mMainUserId.setText(userId[0]);
|
||||||
} else {
|
} else {
|
||||||
mMainUserId.setText(getResources().getString(R.string.user_id_no_name));
|
mMainUserId.setText(getResources().getString(R.string.user_id_no_name));
|
||||||
}
|
}
|
||||||
if (userId[1] != null) {
|
if (userId != null && userId[1] != null) {
|
||||||
mMainUserIdRest.setText(userId[1]);
|
mMainUserIdRest.setText(userId[1]);
|
||||||
} else {
|
} else {
|
||||||
mMainUserIdRest.setText("");
|
mMainUserIdRest.setText("");
|
||||||
|
@ -127,6 +127,7 @@ public class ViewKeyActivity extends ActionBarActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
try {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case android.R.id.home:
|
case android.R.id.home:
|
||||||
Intent homeIntent = new Intent(this, KeyListActivity.class);
|
Intent homeIntent = new Intent(this, KeyListActivity.class);
|
||||||
@ -165,10 +166,15 @@ public class ViewKeyActivity extends ActionBarActivity {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (ProviderHelper.NotFoundException e) {
|
||||||
|
AppMsg.makeText(this, R.string.error_key_not_found, AppMsg.STYLE_ALERT).show();
|
||||||
|
Log.e(Constants.TAG, "Key not found", e);
|
||||||
|
}
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void exportToFile(Uri dataUri, ExportHelper exportHelper, ProviderHelper providerHelper) {
|
private void exportToFile(Uri dataUri, ExportHelper exportHelper, ProviderHelper providerHelper)
|
||||||
|
throws ProviderHelper.NotFoundException {
|
||||||
Uri baseUri = KeychainContract.KeyRings.buildUnifiedKeyRingUri(dataUri);
|
Uri baseUri = KeychainContract.KeyRings.buildUnifiedKeyRingUri(dataUri);
|
||||||
|
|
||||||
HashMap<String, Object> data = providerHelper.getGenericData(
|
HashMap<String, Object> data = providerHelper.getGenericData(
|
||||||
@ -183,13 +189,14 @@ public class ViewKeyActivity extends ActionBarActivity {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void uploadToKeyserver(Uri dataUri) {
|
private void uploadToKeyserver(Uri dataUri) throws ProviderHelper.NotFoundException {
|
||||||
Intent uploadIntent = new Intent(this, UploadKeyActivity.class);
|
Intent uploadIntent = new Intent(this, UploadKeyActivity.class);
|
||||||
uploadIntent.setData(dataUri);
|
uploadIntent.setData(dataUri);
|
||||||
startActivityForResult(uploadIntent, 0);
|
startActivityForResult(uploadIntent, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateFromKeyserver(Uri dataUri, ProviderHelper providerHelper) {
|
private void updateFromKeyserver(Uri dataUri, ProviderHelper providerHelper)
|
||||||
|
throws ProviderHelper.NotFoundException {
|
||||||
byte[] blob = (byte[]) providerHelper.getGenericData(
|
byte[] blob = (byte[]) providerHelper.getGenericData(
|
||||||
KeychainContract.KeyRings.buildUnifiedKeyRingUri(dataUri),
|
KeychainContract.KeyRings.buildUnifiedKeyRingUri(dataUri),
|
||||||
KeychainContract.Keys.FINGERPRINT, ProviderHelper.FIELD_TYPE_BLOB);
|
KeychainContract.Keys.FINGERPRINT, ProviderHelper.FIELD_TYPE_BLOB);
|
||||||
@ -202,7 +209,8 @@ public class ViewKeyActivity extends ActionBarActivity {
|
|||||||
startActivityForResult(queryIntent, REQUEST_CODE_LOOKUP_KEY);
|
startActivityForResult(queryIntent, REQUEST_CODE_LOOKUP_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void shareKey(Uri dataUri, boolean fingerprintOnly, ProviderHelper providerHelper) {
|
private void shareKey(Uri dataUri, boolean fingerprintOnly, ProviderHelper providerHelper)
|
||||||
|
throws ProviderHelper.NotFoundException {
|
||||||
String content = null;
|
String content = null;
|
||||||
if (fingerprintOnly) {
|
if (fingerprintOnly) {
|
||||||
byte[] data = (byte[]) providerHelper.getGenericData(
|
byte[] data = (byte[]) providerHelper.getGenericData(
|
||||||
|
@ -89,10 +89,16 @@ public class DeleteKeyDialogFragment extends DialogFragment {
|
|||||||
if (masterKeyIds.length == 1) {
|
if (masterKeyIds.length == 1) {
|
||||||
long masterKeyId = masterKeyIds[0];
|
long masterKeyId = masterKeyIds[0];
|
||||||
|
|
||||||
HashMap<String, Object> data = new ProviderHelper(activity).getUnifiedData(masterKeyId, new String[]{
|
try {
|
||||||
|
HashMap<String, Object> data = new ProviderHelper(activity).getUnifiedData(
|
||||||
|
masterKeyId, new String[]{
|
||||||
KeyRings.USER_ID,
|
KeyRings.USER_ID,
|
||||||
KeyRings.HAS_ANY_SECRET
|
KeyRings.HAS_ANY_SECRET
|
||||||
}, new int[]{ProviderHelper.FIELD_TYPE_STRING, ProviderHelper.FIELD_TYPE_INTEGER});
|
}, new int[]{
|
||||||
|
ProviderHelper.FIELD_TYPE_STRING,
|
||||||
|
ProviderHelper.FIELD_TYPE_INTEGER
|
||||||
|
}
|
||||||
|
);
|
||||||
String userId = (String) data.get(KeyRings.USER_ID);
|
String userId = (String) data.get(KeyRings.USER_ID);
|
||||||
boolean hasSecret = ((Long) data.get(KeyRings.HAS_ANY_SECRET)) == 1;
|
boolean hasSecret = ((Long) data.get(KeyRings.HAS_ANY_SECRET)) == 1;
|
||||||
|
|
||||||
@ -100,7 +106,13 @@ public class DeleteKeyDialogFragment extends DialogFragment {
|
|||||||
mMainMessage.setText(getString(
|
mMainMessage.setText(getString(
|
||||||
hasSecret ? R.string.secret_key_deletion_confirmation
|
hasSecret ? R.string.secret_key_deletion_confirmation
|
||||||
: R.string.public_key_deletetion_confirmation,
|
: R.string.public_key_deletetion_confirmation,
|
||||||
userId));
|
userId
|
||||||
|
));
|
||||||
|
} catch (ProviderHelper.NotFoundException e) {
|
||||||
|
sendMessageToHandler(MESSAGE_ERROR, null);
|
||||||
|
dismiss();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
mMainMessage.setText(R.string.key_deletion_confirmation_multi);
|
mMainMessage.setText(R.string.key_deletion_confirmation_multi);
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,7 @@ import org.sufficientlysecure.keychain.Constants;
|
|||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
||||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||||
|
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||||
import org.sufficientlysecure.keychain.service.PassphraseCacheService;
|
import org.sufficientlysecure.keychain.service.PassphraseCacheService;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
@ -134,13 +135,17 @@ public class PassphraseDialogFragment extends DialogFragment implements OnEditor
|
|||||||
alert.setTitle(R.string.title_authentication);
|
alert.setTitle(R.string.title_authentication);
|
||||||
|
|
||||||
final PGPSecretKey secretKey;
|
final PGPSecretKey secretKey;
|
||||||
|
final String userId;
|
||||||
|
|
||||||
if (secretKeyId == Constants.key.symmetric || secretKeyId == Constants.key.none) {
|
if (secretKeyId == Constants.key.symmetric || secretKeyId == Constants.key.none) {
|
||||||
secretKey = null;
|
secretKey = null;
|
||||||
alert.setMessage(R.string.passphrase_for_symmetric_encryption);
|
alert.setMessage(R.string.passphrase_for_symmetric_encryption);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
secretKey = new ProviderHelper(activity).getPGPSecretKeyRing(secretKeyId).getSecretKey();
|
ProviderHelper helper = new ProviderHelper(activity);
|
||||||
|
secretKey = helper.getPGPSecretKeyRing(secretKeyId).getSecretKey();
|
||||||
|
userId = (String) helper.getUnifiedData(secretKeyId,
|
||||||
|
KeychainContract.KeyRings.USER_ID, ProviderHelper.FIELD_TYPE_STRING);
|
||||||
} catch (ProviderHelper.NotFoundException e) {
|
} catch (ProviderHelper.NotFoundException e) {
|
||||||
alert.setTitle(R.string.title_key_not_found);
|
alert.setTitle(R.string.title_key_not_found);
|
||||||
alert.setMessage(getString(R.string.key_not_found, secretKeyId));
|
alert.setMessage(getString(R.string.key_not_found, secretKeyId));
|
||||||
@ -154,8 +159,6 @@ public class PassphraseDialogFragment extends DialogFragment implements OnEditor
|
|||||||
return alert.create();
|
return alert.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
String userId = PgpKeyHelper.getMainUserIdSafe(activity, secretKey);
|
|
||||||
|
|
||||||
Log.d(Constants.TAG, "User id: '" + userId + "'");
|
Log.d(Constants.TAG, "User id: '" + userId + "'");
|
||||||
alert.setMessage(getString(R.string.passphrase_for, userId));
|
alert.setMessage(getString(R.string.passphrase_for, userId));
|
||||||
}
|
}
|
||||||
|
@ -93,6 +93,7 @@ public class ShareQrCodeDialogFragment extends DialogFragment {
|
|||||||
|
|
||||||
ProviderHelper providerHelper = new ProviderHelper(getActivity());
|
ProviderHelper providerHelper = new ProviderHelper(getActivity());
|
||||||
String content = null;
|
String content = null;
|
||||||
|
try {
|
||||||
if (mFingerprintOnly) {
|
if (mFingerprintOnly) {
|
||||||
alert.setPositiveButton(R.string.btn_okay, null);
|
alert.setPositiveButton(R.string.btn_okay, null);
|
||||||
|
|
||||||
@ -119,10 +120,6 @@ public class ShareQrCodeDialogFragment extends DialogFragment {
|
|||||||
Log.e(Constants.TAG, "error processing key!", e);
|
Log.e(Constants.TAG, "error processing key!", e);
|
||||||
AppMsg.makeText(getActivity(), R.string.error_invalid_data, AppMsg.STYLE_ALERT).show();
|
AppMsg.makeText(getActivity(), R.string.error_invalid_data, AppMsg.STYLE_ALERT).show();
|
||||||
return null;
|
return null;
|
||||||
} catch (ProviderHelper.NotFoundException e) {
|
|
||||||
Log.e(Constants.TAG, "key not found!", e);
|
|
||||||
AppMsg.makeText(getActivity(), R.string.error_key_not_found, AppMsg.STYLE_ALERT).show();
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnClickListener are set in onResume to prevent automatic dismissing of Dialogs
|
// OnClickListener are set in onResume to prevent automatic dismissing of Dialogs
|
||||||
@ -136,6 +133,11 @@ public class ShareQrCodeDialogFragment extends DialogFragment {
|
|||||||
mCounter = 0;
|
mCounter = 0;
|
||||||
updatePartsQrCode();
|
updatePartsQrCode();
|
||||||
}
|
}
|
||||||
|
} catch (ProviderHelper.NotFoundException e) {
|
||||||
|
Log.e(Constants.TAG, "key not found!", e);
|
||||||
|
AppMsg.makeText(getActivity(), R.string.error_key_not_found, AppMsg.STYLE_ALERT).show();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return alert.create();
|
return alert.create();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user