mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-30 12:32:17 -05:00
certs: fix ViewCertActivity
This commit is contained in:
parent
6e2b21b6b7
commit
f01a96f56e
@ -273,6 +273,9 @@ public class KeychainContract {
|
|||||||
public static Uri buildCertsUri(String masterKeyId) {
|
public static Uri buildCertsUri(String masterKeyId) {
|
||||||
return CONTENT_URI.buildUpon().appendPath(masterKeyId).appendPath(PATH_CERTS).build();
|
return CONTENT_URI.buildUpon().appendPath(masterKeyId).appendPath(PATH_CERTS).build();
|
||||||
}
|
}
|
||||||
|
public static Uri buildCertsSpecificUri(String masterKeyId, String rank, String certifier) {
|
||||||
|
return CONTENT_URI.buildUpon().appendPath(masterKeyId).appendPath(PATH_CERTS).appendPath(rank).appendPath(certifier).build();
|
||||||
|
}
|
||||||
public static Uri buildCertsUri(Uri uri) {
|
public static Uri buildCertsUri(Uri uri) {
|
||||||
return CONTENT_URI.buildUpon().appendPath(uri.getPathSegments().get(1)).appendPath(PATH_CERTS).build();
|
return CONTENT_URI.buildUpon().appendPath(uri.getPathSegments().get(1)).appendPath(PATH_CERTS).build();
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,7 @@ public class KeychainProvider extends ContentProvider {
|
|||||||
private static final int KEY_RING_PUBLIC = 203;
|
private static final int KEY_RING_PUBLIC = 203;
|
||||||
private static final int KEY_RING_SECRET = 204;
|
private static final int KEY_RING_SECRET = 204;
|
||||||
private static final int KEY_RING_CERTS = 205;
|
private static final int KEY_RING_CERTS = 205;
|
||||||
|
private static final int KEY_RING_CERTS_SPECIFIC = 206;
|
||||||
|
|
||||||
private static final int API_APPS = 301;
|
private static final int API_APPS = 301;
|
||||||
private static final int API_APPS_BY_PACKAGE_NAME = 303;
|
private static final int API_APPS_BY_PACKAGE_NAME = 303;
|
||||||
@ -63,8 +64,6 @@ public class KeychainProvider extends ContentProvider {
|
|||||||
private static final int KEY_RINGS_FIND_BY_EMAIL = 400;
|
private static final int KEY_RINGS_FIND_BY_EMAIL = 400;
|
||||||
private static final int KEY_RINGS_FIND_BY_SUBKEY = 401;
|
private static final int KEY_RINGS_FIND_BY_SUBKEY = 401;
|
||||||
|
|
||||||
private static final int CERTS_FIND_BY_CERTIFIER_ID = 501;
|
|
||||||
|
|
||||||
// private static final int DATA_STREAM = 501;
|
// private static final int DATA_STREAM = 501;
|
||||||
|
|
||||||
protected UriMatcher mUriMatcher;
|
protected UriMatcher mUriMatcher;
|
||||||
@ -119,6 +118,8 @@ public class KeychainProvider extends ContentProvider {
|
|||||||
* key_rings/_/user_ids
|
* key_rings/_/user_ids
|
||||||
* key_rings/_/public
|
* key_rings/_/public
|
||||||
* key_rings/_/secret
|
* key_rings/_/secret
|
||||||
|
* key_rings/_/certs
|
||||||
|
* key_rings/_/certs/_/_
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/*/"
|
matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/*/"
|
||||||
@ -139,6 +140,9 @@ public class KeychainProvider extends ContentProvider {
|
|||||||
matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/*/"
|
matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/*/"
|
||||||
+ KeychainContract.PATH_CERTS,
|
+ KeychainContract.PATH_CERTS,
|
||||||
KEY_RING_CERTS);
|
KEY_RING_CERTS);
|
||||||
|
matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/*/"
|
||||||
|
+ KeychainContract.PATH_CERTS + "/*/*",
|
||||||
|
KEY_RING_CERTS_SPECIFIC);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API apps
|
* API apps
|
||||||
@ -436,6 +440,7 @@ public class KeychainProvider extends ContentProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case KEY_RING_CERTS:
|
case KEY_RING_CERTS:
|
||||||
|
case KEY_RING_CERTS_SPECIFIC: {
|
||||||
HashMap<String, String> projectionMap = new HashMap<String, String>();
|
HashMap<String, String> projectionMap = new HashMap<String, String>();
|
||||||
projectionMap.put(Certs._ID, Tables.CERTS + ".oid AS " + Certs._ID);
|
projectionMap.put(Certs._ID, Tables.CERTS + ".oid AS " + Certs._ID);
|
||||||
projectionMap.put(Certs.MASTER_KEY_ID, Tables.CERTS + "." + Certs.MASTER_KEY_ID);
|
projectionMap.put(Certs.MASTER_KEY_ID, Tables.CERTS + "." + Certs.MASTER_KEY_ID);
|
||||||
@ -443,6 +448,7 @@ public class KeychainProvider extends ContentProvider {
|
|||||||
projectionMap.put(Certs.VERIFIED, Tables.CERTS + "." + Certs.VERIFIED);
|
projectionMap.put(Certs.VERIFIED, Tables.CERTS + "." + Certs.VERIFIED);
|
||||||
projectionMap.put(Certs.TYPE, Tables.CERTS + "." + Certs.TYPE);
|
projectionMap.put(Certs.TYPE, Tables.CERTS + "." + Certs.TYPE);
|
||||||
projectionMap.put(Certs.CREATION, Tables.CERTS + "." + Certs.CREATION);
|
projectionMap.put(Certs.CREATION, Tables.CERTS + "." + Certs.CREATION);
|
||||||
|
projectionMap.put(Certs.EXPIRY, Tables.CERTS + "." + Certs.EXPIRY);
|
||||||
projectionMap.put(Certs.KEY_ID_CERTIFIER, Tables.CERTS + "." + Certs.KEY_ID_CERTIFIER);
|
projectionMap.put(Certs.KEY_ID_CERTIFIER, Tables.CERTS + "." + Certs.KEY_ID_CERTIFIER);
|
||||||
projectionMap.put(Certs.USER_ID, Tables.USER_IDS + "." + UserIds.USER_ID);
|
projectionMap.put(Certs.USER_ID, Tables.USER_IDS + "." + UserIds.USER_ID);
|
||||||
projectionMap.put(Certs.SIGNER_UID, "signer." + UserIds.USER_ID + " AS " + Certs.SIGNER_UID);
|
projectionMap.put(Certs.SIGNER_UID, "signer." + UserIds.USER_ID + " AS " + Certs.SIGNER_UID);
|
||||||
@ -450,7 +456,7 @@ public class KeychainProvider extends ContentProvider {
|
|||||||
|
|
||||||
qb.setTables(Tables.CERTS
|
qb.setTables(Tables.CERTS
|
||||||
+ " JOIN " + Tables.USER_IDS + " ON ("
|
+ " JOIN " + Tables.USER_IDS + " ON ("
|
||||||
+ Tables.CERTS + "." + Certs.MASTER_KEY_ID + " = "
|
+ Tables.CERTS + "." + Certs.MASTER_KEY_ID + " = "
|
||||||
+ Tables.USER_IDS + "." + UserIds.MASTER_KEY_ID
|
+ Tables.USER_IDS + "." + UserIds.MASTER_KEY_ID
|
||||||
+ " AND "
|
+ " AND "
|
||||||
+ Tables.CERTS + "." + Certs.RANK + " = "
|
+ Tables.CERTS + "." + Certs.RANK + " = "
|
||||||
@ -465,10 +471,17 @@ public class KeychainProvider extends ContentProvider {
|
|||||||
groupBy = Tables.CERTS + "." + Certs.RANK + ", "
|
groupBy = Tables.CERTS + "." + Certs.RANK + ", "
|
||||||
+ Tables.CERTS + "." + Certs.KEY_ID_CERTIFIER;
|
+ Tables.CERTS + "." + Certs.KEY_ID_CERTIFIER;
|
||||||
|
|
||||||
qb.appendWhere(Tables.CERTS + "." + KeyRings.MASTER_KEY_ID + " = ");
|
qb.appendWhere(Tables.CERTS + "." + Certs.MASTER_KEY_ID + " = ");
|
||||||
qb.appendWhereEscapeString(uri.getPathSegments().get(1));
|
qb.appendWhereEscapeString(uri.getPathSegments().get(1));
|
||||||
|
if(match == KEY_RING_CERTS_SPECIFIC) {
|
||||||
|
qb.appendWhere(" AND " + Tables.CERTS + "." + Certs.RANK + " = ");
|
||||||
|
qb.appendWhereEscapeString(uri.getPathSegments().get(3));
|
||||||
|
qb.appendWhere(" AND " + Tables.CERTS + "." + Certs.KEY_ID_CERTIFIER+ " = ");
|
||||||
|
qb.appendWhereEscapeString(uri.getPathSegments().get(4));
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case API_APPS:
|
case API_APPS:
|
||||||
qb.setTables(Tables.API_APPS);
|
qb.setTables(Tables.API_APPS);
|
||||||
|
@ -59,16 +59,14 @@ public class ViewCertActivity extends ActionBarActivity
|
|||||||
Certs.EXPIRY,
|
Certs.EXPIRY,
|
||||||
Certs.KEY_ID_CERTIFIER,
|
Certs.KEY_ID_CERTIFIER,
|
||||||
Certs.SIGNER_UID,
|
Certs.SIGNER_UID,
|
||||||
Certs.TYPE
|
|
||||||
};
|
};
|
||||||
private static final int INDEX_MASTER_KEY_ID = 1;
|
private static final int INDEX_MASTER_KEY_ID = 0;
|
||||||
private static final int INDEX_USER_ID = 2;
|
private static final int INDEX_USER_ID = 1;
|
||||||
private static final int INDEX_TYPE = 3;
|
private static final int INDEX_TYPE = 2;
|
||||||
private static final int INDEX_CREATION = 4;
|
private static final int INDEX_CREATION = 3;
|
||||||
private static final int INDEX_EXPIRY = 5;
|
private static final int INDEX_EXPIRY = 4;
|
||||||
private static final int INDEX_KEY_ID_CERTIFIER = 6;
|
private static final int INDEX_KEY_ID_CERTIFIER = 5;
|
||||||
private static final int INDEX_UID_CERTIFIER = 7;
|
private static final int INDEX_SIGNER_UID = 6;
|
||||||
private static final int INDEX_KEY_TYPE = 8;
|
|
||||||
|
|
||||||
private Uri mDataUri;
|
private Uri mDataUri;
|
||||||
|
|
||||||
@ -130,7 +128,7 @@ public class ViewCertActivity extends ActionBarActivity
|
|||||||
String signerKey = "0x" + PgpKeyHelper.convertKeyIdToHex(mSignerKeyId);
|
String signerKey = "0x" + PgpKeyHelper.convertKeyIdToHex(mSignerKeyId);
|
||||||
mSignerKey.setText(signerKey);
|
mSignerKey.setText(signerKey);
|
||||||
|
|
||||||
String signerUid = data.getString(INDEX_UID_CERTIFIER);
|
String signerUid = data.getString(INDEX_SIGNER_UID);
|
||||||
if(signerUid != null)
|
if(signerUid != null)
|
||||||
mSignerUid.setText(signerUid);
|
mSignerUid.setText(signerUid);
|
||||||
else
|
else
|
||||||
@ -141,19 +139,21 @@ public class ViewCertActivity extends ActionBarActivity
|
|||||||
|
|
||||||
switch(data.getInt(INDEX_TYPE)) {
|
switch(data.getInt(INDEX_TYPE)) {
|
||||||
case PGPSignature.DEFAULT_CERTIFICATION:
|
case PGPSignature.DEFAULT_CERTIFICATION:
|
||||||
mType.setText(R.string.sig_type_default); break;
|
mType.setText(R.string.cert_default); break;
|
||||||
case PGPSignature.NO_CERTIFICATION:
|
case PGPSignature.NO_CERTIFICATION:
|
||||||
mType.setText(R.string.sig_type_none); break;
|
mType.setText(R.string.cert_none); break;
|
||||||
case PGPSignature.CASUAL_CERTIFICATION:
|
case PGPSignature.CASUAL_CERTIFICATION:
|
||||||
mType.setText(R.string.sig_type_casual); break;
|
mType.setText(R.string.cert_casual); break;
|
||||||
case PGPSignature.POSITIVE_CERTIFICATION:
|
case PGPSignature.POSITIVE_CERTIFICATION:
|
||||||
mType.setText(R.string.sig_type_positive); break;
|
mType.setText(R.string.cert_positive); break;
|
||||||
|
case PGPSignature.CERTIFICATION_REVOCATION:
|
||||||
|
mType.setText(R.string.cert_revoke); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
long expiry = data.getLong(INDEX_EXPIRY);
|
long expiry = data.getLong(INDEX_EXPIRY);
|
||||||
if(expiry == 0)
|
if(expiry == 0) {
|
||||||
mExpiry.setText("never");
|
mExpiry.setText(R.string.never);
|
||||||
else {
|
} else {
|
||||||
Date expiryDate = new Date(creationDate.getTime() + expiry * 1000);
|
Date expiryDate = new Date(creationDate.getTime() + expiry * 1000);
|
||||||
mExpiry.setText(DateFormat.getDateFormat(getApplicationContext()).format(expiryDate));
|
mExpiry.setText(DateFormat.getDateFormat(getApplicationContext()).format(expiryDate));
|
||||||
}
|
}
|
||||||
|
@ -142,10 +142,16 @@ public class ViewKeyCertsFragment extends Fragment
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
|
||||||
Intent viewIntent = null;
|
if(view.getTag(R.id.tag_mki) != null) {
|
||||||
viewIntent = new Intent(getActivity(), ViewCertActivity.class);
|
long masterKeyId = (Long) view.getTag(R.id.tag_mki);
|
||||||
viewIntent.setData(Certs.buildCertsUri(Long.toString(id)));
|
long rank = (Long) view.getTag(R.id.tag_rank);
|
||||||
startActivity(viewIntent);
|
long certifierId = (Long) view.getTag(R.id.tag_certifierId);
|
||||||
|
|
||||||
|
Intent viewIntent = new Intent(getActivity(), ViewCertActivity.class);
|
||||||
|
viewIntent.setData(Certs.buildCertsSpecificUri(
|
||||||
|
Long.toString(masterKeyId), Long.toString(rank), Long.toString(certifierId)));
|
||||||
|
startActivity(viewIntent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -161,8 +167,7 @@ public class ViewKeyCertsFragment extends Fragment
|
|||||||
*/
|
*/
|
||||||
private class CertListAdapter extends CursorAdapter implements StickyListHeadersAdapter {
|
private class CertListAdapter extends CursorAdapter implements StickyListHeadersAdapter {
|
||||||
private LayoutInflater mInflater;
|
private LayoutInflater mInflater;
|
||||||
private int mIndexCertId;
|
private int mIndexMasterKeyId, mIndexUserId, mIndexRank;
|
||||||
private int mIndexUserId, mIndexRank;
|
|
||||||
private int mIndexSignerKeyId, mIndexSignerUserId;
|
private int mIndexSignerKeyId, mIndexSignerUserId;
|
||||||
private int mIndexVerified, mIndexType;
|
private int mIndexVerified, mIndexType;
|
||||||
|
|
||||||
@ -189,7 +194,7 @@ public class ViewKeyCertsFragment extends Fragment
|
|||||||
private void initIndex(Cursor cursor) {
|
private void initIndex(Cursor cursor) {
|
||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
|
|
||||||
mIndexCertId = cursor.getColumnIndexOrThrow(Certs.MASTER_KEY_ID);
|
mIndexMasterKeyId = cursor.getColumnIndexOrThrow(Certs.MASTER_KEY_ID);
|
||||||
mIndexUserId = cursor.getColumnIndexOrThrow(Certs.USER_ID);
|
mIndexUserId = cursor.getColumnIndexOrThrow(Certs.USER_ID);
|
||||||
mIndexRank = cursor.getColumnIndexOrThrow(Certs.RANK);
|
mIndexRank = cursor.getColumnIndexOrThrow(Certs.RANK);
|
||||||
mIndexType = cursor.getColumnIndexOrThrow(Certs.TYPE);
|
mIndexType = cursor.getColumnIndexOrThrow(Certs.TYPE);
|
||||||
@ -231,6 +236,10 @@ public class ViewKeyCertsFragment extends Fragment
|
|||||||
wSignerUserId.setText(signerUserId);
|
wSignerUserId.setText(signerUserId);
|
||||||
wSignerKeyId.setText(signerKeyId);
|
wSignerKeyId.setText(signerKeyId);
|
||||||
|
|
||||||
|
view.setTag(R.id.tag_mki, cursor.getLong(mIndexMasterKeyId));
|
||||||
|
view.setTag(R.id.tag_rank, cursor.getLong(mIndexRank));
|
||||||
|
view.setTag(R.id.tag_certifierId, cursor.getLong(mIndexSignerKeyId));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -486,14 +486,14 @@
|
|||||||
<string name="secret_key_yes">available</string>
|
<string name="secret_key_yes">available</string>
|
||||||
<string name="secret_key_no">unavailable</string>
|
<string name="secret_key_no">unavailable</string>
|
||||||
|
|
||||||
|
<!-- hints -->
|
||||||
|
<string name="encrypt_content_edit_text_hint">Write message here to encrypt and/or sign…</string>
|
||||||
|
<string name="decrypt_content_edit_text_hint">Enter ciphertext here to decrypt and/or verify…</string>
|
||||||
|
|
||||||
<!-- unsorted -->
|
<!-- unsorted -->
|
||||||
<string name="show_unknown_signatures">Show unknown signatures</string>
|
<string name="show_unknown_signatures">Show unknown signatures</string>
|
||||||
<string name="section_signer_id">Signer</string>
|
<string name="section_signer_id">Signer</string>
|
||||||
<string name="section_cert">Certificate Details</string>
|
<string name="section_cert">Certificate Details</string>
|
||||||
<string name="sig_type_default">default</string>
|
|
||||||
<string name="sig_type_none">none</string>
|
|
||||||
<string name="sig_type_casual">casual</string>
|
|
||||||
<string name="sig_type_positive">positive</string>
|
|
||||||
<string name="label_user_id">User ID</string>
|
<string name="label_user_id">User ID</string>
|
||||||
<string name="label_subkey_rank">Subkey Rank</string>
|
<string name="label_subkey_rank">Subkey Rank</string>
|
||||||
<string name="unknown_uid"><![CDATA[<unknown>]]></string>
|
<string name="unknown_uid"><![CDATA[<unknown>]]></string>
|
||||||
@ -503,14 +503,11 @@
|
|||||||
<string name="certs_list_known_secret">Show by known secret keys</string>
|
<string name="certs_list_known_secret">Show by known secret keys</string>
|
||||||
<string name="certs_list_known">Show by known public keys</string>
|
<string name="certs_list_known">Show by known public keys</string>
|
||||||
<string name="certs_list_all">Show all certificates</string>
|
<string name="certs_list_all">Show all certificates</string>
|
||||||
|
|
||||||
<!-- hints -->
|
|
||||||
<string name="encrypt_content_edit_text_hint">Write message here to encrypt and/or sign…</string>
|
|
||||||
<string name="decrypt_content_edit_text_hint">Enter ciphertext here to decrypt and/or verify…</string>
|
|
||||||
<string name="cert_default">default</string>
|
<string name="cert_default">default</string>
|
||||||
<string name="cert_none">none</string>
|
<string name="cert_none">none</string>
|
||||||
<string name="cert_casual">casual</string>
|
<string name="cert_casual">casual</string>
|
||||||
<string name="cert_positive">positive</string>
|
<string name="cert_positive">positive</string>
|
||||||
<string name="cert_revoke">revoke</string>
|
<string name="cert_revoke">revoke</string>
|
||||||
|
<string name="never">never</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user