mirror of
https://github.com/moparisthebest/open-keychain
synced 2025-02-23 23:12:06 -05:00
linked-ids: rename RawLinkedIdentity to UriAttribute
This commit is contained in:
parent
57f72996e8
commit
3600cda3bc
@ -5,7 +5,7 @@ import java.net.URI;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.annotation.DrawableRes;
|
import android.support.annotation.DrawableRes;
|
||||||
|
|
||||||
public class LinkedIdentity extends RawLinkedIdentity {
|
public class LinkedIdentity extends UriAttribute {
|
||||||
|
|
||||||
public final LinkedResource mResource;
|
public final LinkedResource mResource;
|
||||||
|
|
||||||
|
@ -13,11 +13,11 @@ import android.content.Context;
|
|||||||
import android.support.annotation.DrawableRes;
|
import android.support.annotation.DrawableRes;
|
||||||
|
|
||||||
/** The RawLinkedIdentity contains raw parsed data from a Linked Identity subpacket. */
|
/** The RawLinkedIdentity contains raw parsed data from a Linked Identity subpacket. */
|
||||||
public class RawLinkedIdentity {
|
public class UriAttribute {
|
||||||
|
|
||||||
public final URI mUri;
|
public final URI mUri;
|
||||||
|
|
||||||
protected RawLinkedIdentity(URI uri) {
|
protected UriAttribute(URI uri) {
|
||||||
mUri = uri;
|
mUri = uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ public class RawLinkedIdentity {
|
|||||||
return Strings.toUTF8ByteArray(mUri.toASCIIString());
|
return Strings.toUTF8ByteArray(mUri.toASCIIString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RawLinkedIdentity fromAttributeData(byte[] data) throws IOException {
|
public static UriAttribute fromAttributeData(byte[] data) throws IOException {
|
||||||
WrappedUserAttribute att = WrappedUserAttribute.fromData(data);
|
WrappedUserAttribute att = WrappedUserAttribute.fromData(data);
|
||||||
|
|
||||||
byte[][] subpackets = att.getSubpackets();
|
byte[][] subpackets = att.getSubpackets();
|
||||||
@ -36,7 +36,7 @@ public class RawLinkedIdentity {
|
|||||||
throw new IOException("no subpacket data");
|
throw new IOException("no subpacket data");
|
||||||
}
|
}
|
||||||
|
|
||||||
static RawLinkedIdentity fromSubpacketData(byte[] data) {
|
static UriAttribute fromSubpacketData(byte[] data) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String uriStr = Strings.fromUTF8ByteArray(data);
|
String uriStr = Strings.fromUTF8ByteArray(data);
|
||||||
@ -44,7 +44,7 @@ public class RawLinkedIdentity {
|
|||||||
|
|
||||||
LinkedResource res = LinkedTokenResource.fromUri(uri);
|
LinkedResource res = LinkedTokenResource.fromUri(uri);
|
||||||
if (res == null) {
|
if (res == null) {
|
||||||
return new RawLinkedIdentity(uri);
|
return new UriAttribute(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new LinkedIdentity(uri, res);
|
return new LinkedIdentity(uri, res);
|
||||||
@ -55,13 +55,13 @@ public class RawLinkedIdentity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RawLinkedIdentity fromResource (LinkedTokenResource res) {
|
public static UriAttribute fromResource (LinkedTokenResource res) {
|
||||||
return new RawLinkedIdentity(res.toUri());
|
return new UriAttribute(res.toUri());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public WrappedUserAttribute toUserAttribute () {
|
public WrappedUserAttribute toUserAttribute () {
|
||||||
return WrappedUserAttribute.fromSubpacket(WrappedUserAttribute.UAT_LINKED_ID, getEncoded());
|
return WrappedUserAttribute.fromSubpacket(WrappedUserAttribute.UAT_URI_ATTRIBUTE, getEncoded());
|
||||||
}
|
}
|
||||||
|
|
||||||
public @DrawableRes int getDisplayIcon() {
|
public @DrawableRes int getDisplayIcon() {
|
@ -44,7 +44,7 @@ public class DnsResource extends LinkedTokenResource {
|
|||||||
|
|
||||||
public static String generateText(byte[] fingerprint) {
|
public static String generateText(byte[] fingerprint) {
|
||||||
|
|
||||||
return String.format("openpgpid+token=%s",
|
return String.format("openpgp4fpr=%s",
|
||||||
KeyFormattingUtils.convertFingerprintToHex(fingerprint));
|
KeyFormattingUtils.convertFingerprintToHex(fingerprint));
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -52,7 +52,7 @@ public class DnsResource extends LinkedTokenResource {
|
|||||||
public static DnsResource createNew (String domain) {
|
public static DnsResource createNew (String domain) {
|
||||||
HashSet<String> flags = new HashSet<>();
|
HashSet<String> flags = new HashSet<>();
|
||||||
HashMap<String,String> params = new HashMap<>();
|
HashMap<String,String> params = new HashMap<>();
|
||||||
URI uri = URI.create("dns:" + domain);
|
URI uri = URI.create("dns:" + domain + "?TYPE=TXT");
|
||||||
return create(flags, params, uri);
|
return create(flags, params, uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ public class WrappedUserAttribute implements Serializable {
|
|||||||
|
|
||||||
public static final int UAT_NONE = 0;
|
public static final int UAT_NONE = 0;
|
||||||
public static final int UAT_IMAGE = UserAttributeSubpacketTags.IMAGE_ATTRIBUTE;
|
public static final int UAT_IMAGE = UserAttributeSubpacketTags.IMAGE_ATTRIBUTE;
|
||||||
public static final int UAT_LINKED_ID = 101;
|
public static final int UAT_URI_ATTRIBUTE = 101;
|
||||||
|
|
||||||
private PGPUserAttributeSubpacketVector mVector;
|
private PGPUserAttributeSubpacketVector mVector;
|
||||||
|
|
||||||
|
@ -518,7 +518,7 @@ public class KeychainProvider extends ContentProvider {
|
|||||||
|
|
||||||
if (match == KEY_RING_LINKED_IDS) {
|
if (match == KEY_RING_LINKED_IDS) {
|
||||||
qb.appendWhere(Tables.USER_PACKETS + "." + UserPackets.TYPE + " = "
|
qb.appendWhere(Tables.USER_PACKETS + "." + UserPackets.TYPE + " = "
|
||||||
+ WrappedUserAttribute.UAT_LINKED_ID);
|
+ WrappedUserAttribute.UAT_URI_ATTRIBUTE);
|
||||||
} else {
|
} else {
|
||||||
qb.appendWhere(Tables.USER_PACKETS + "." + UserPackets.TYPE + " IS NULL");
|
qb.appendWhere(Tables.USER_PACKETS + "." + UserPackets.TYPE + " IS NULL");
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ import android.widget.TextView;
|
|||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.linked.LinkedIdentity;
|
import org.sufficientlysecure.keychain.linked.LinkedIdentity;
|
||||||
import org.sufficientlysecure.keychain.linked.RawLinkedIdentity;
|
import org.sufficientlysecure.keychain.linked.UriAttribute;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.Certs;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.Certs;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.UserPackets;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.UserPackets;
|
||||||
import org.sufficientlysecure.keychain.ui.linked.LinkedIdViewFragment;
|
import org.sufficientlysecure.keychain.ui.linked.LinkedIdViewFragment;
|
||||||
@ -49,7 +49,7 @@ import java.util.WeakHashMap;
|
|||||||
public class LinkedIdsAdapter extends UserAttributesAdapter {
|
public class LinkedIdsAdapter extends UserAttributesAdapter {
|
||||||
private final boolean mIsSecret;
|
private final boolean mIsSecret;
|
||||||
protected LayoutInflater mInflater;
|
protected LayoutInflater mInflater;
|
||||||
WeakHashMap<Integer,RawLinkedIdentity> mLinkedIdentityCache = new WeakHashMap<>();
|
WeakHashMap<Integer,UriAttribute> mLinkedIdentityCache = new WeakHashMap<>();
|
||||||
|
|
||||||
private Cursor mUnfilteredCursor;
|
private Cursor mUnfilteredCursor;
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ public class LinkedIdsAdapter extends UserAttributesAdapter {
|
|||||||
FilterCursorWrapper filteredCursor = new FilterCursorWrapper(cursor) {
|
FilterCursorWrapper filteredCursor = new FilterCursorWrapper(cursor) {
|
||||||
@Override
|
@Override
|
||||||
public boolean isVisible(Cursor cursor) {
|
public boolean isVisible(Cursor cursor) {
|
||||||
RawLinkedIdentity id = getItemAtPosition(cursor);
|
UriAttribute id = getItemAtPosition(cursor);
|
||||||
return id instanceof LinkedIdentity;
|
return id instanceof LinkedIdentity;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -132,16 +132,16 @@ public class LinkedIdsAdapter extends UserAttributesAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RawLinkedIdentity id = getItemAtPosition(cursor);
|
UriAttribute id = getItemAtPosition(cursor);
|
||||||
holder.setData(mContext, id);
|
holder.setData(mContext, id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public RawLinkedIdentity getItemAtPosition(Cursor cursor) {
|
public UriAttribute getItemAtPosition(Cursor cursor) {
|
||||||
int rank = cursor.getInt(INDEX_RANK);
|
int rank = cursor.getInt(INDEX_RANK);
|
||||||
Log.d(Constants.TAG, "requested rank: " + rank);
|
Log.d(Constants.TAG, "requested rank: " + rank);
|
||||||
|
|
||||||
RawLinkedIdentity ret = mLinkedIdentityCache.get(rank);
|
UriAttribute ret = mLinkedIdentityCache.get(rank);
|
||||||
if (ret != null) {
|
if (ret != null) {
|
||||||
Log.d(Constants.TAG, "cached!");
|
Log.d(Constants.TAG, "cached!");
|
||||||
return ret;
|
return ret;
|
||||||
@ -160,7 +160,7 @@ public class LinkedIdsAdapter extends UserAttributesAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RawLinkedIdentity getItem(int position) {
|
public UriAttribute getItem(int position) {
|
||||||
Cursor cursor = getCursor();
|
Cursor cursor = getCursor();
|
||||||
cursor.moveToPosition(position);
|
cursor.moveToPosition(position);
|
||||||
return getItemAtPosition(cursor);
|
return getItemAtPosition(cursor);
|
||||||
@ -206,7 +206,7 @@ public class LinkedIdsAdapter extends UserAttributesAdapter {
|
|||||||
vComment = (TextView) view.findViewById(R.id.linked_id_comment);
|
vComment = (TextView) view.findViewById(R.id.linked_id_comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setData(Context context, RawLinkedIdentity id) {
|
public void setData(Context context, UriAttribute id) {
|
||||||
|
|
||||||
vTitle.setText(id.getDisplayTitle(context));
|
vTitle.setText(id.getDisplayTitle(context));
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ import org.sufficientlysecure.keychain.operations.results.LinkedVerifyResult;
|
|||||||
import org.sufficientlysecure.keychain.linked.LinkedTokenResource;
|
import org.sufficientlysecure.keychain.linked.LinkedTokenResource;
|
||||||
import org.sufficientlysecure.keychain.linked.LinkedIdentity;
|
import org.sufficientlysecure.keychain.linked.LinkedIdentity;
|
||||||
import org.sufficientlysecure.keychain.linked.LinkedResource;
|
import org.sufficientlysecure.keychain.linked.LinkedResource;
|
||||||
import org.sufficientlysecure.keychain.linked.RawLinkedIdentity;
|
import org.sufficientlysecure.keychain.linked.UriAttribute;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.Certs;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.Certs;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.UserPackets;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.UserPackets;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables;
|
import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables;
|
||||||
@ -68,7 +68,7 @@ public class LinkedIdViewFragment extends CryptoOperationFragment implements
|
|||||||
private static final String ARG_FINGERPRINT = "fingerprint";
|
private static final String ARG_FINGERPRINT = "fingerprint";
|
||||||
private static final int LOADER_ID_LINKED_ID = 1;
|
private static final int LOADER_ID_LINKED_ID = 1;
|
||||||
|
|
||||||
private RawLinkedIdentity mLinkedId;
|
private UriAttribute mLinkedId;
|
||||||
private LinkedTokenResource mLinkedResource;
|
private LinkedTokenResource mLinkedResource;
|
||||||
private boolean mIsSecret;
|
private boolean mIsSecret;
|
||||||
|
|
||||||
@ -147,7 +147,7 @@ public class LinkedIdViewFragment extends CryptoOperationFragment implements
|
|||||||
int certStatus = cursor.getInt(UserIdsAdapter.INDEX_VERIFIED);
|
int certStatus = cursor.getInt(UserIdsAdapter.INDEX_VERIFIED);
|
||||||
|
|
||||||
byte[] data = cursor.getBlob(UserIdsAdapter.INDEX_ATTRIBUTE_DATA);
|
byte[] data = cursor.getBlob(UserIdsAdapter.INDEX_ATTRIBUTE_DATA);
|
||||||
RawLinkedIdentity linkedId = LinkedIdentity.fromAttributeData(data);
|
UriAttribute linkedId = LinkedIdentity.fromAttributeData(data);
|
||||||
|
|
||||||
loadIdentity(linkedId, certStatus);
|
loadIdentity(linkedId, certStatus);
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ public class LinkedIdViewFragment extends CryptoOperationFragment implements
|
|||||||
mIdLoadedListener = listener;
|
mIdLoadedListener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadIdentity(RawLinkedIdentity linkedId, int certStatus) {
|
private void loadIdentity(UriAttribute linkedId, int certStatus) {
|
||||||
mLinkedId = linkedId;
|
mLinkedId = linkedId;
|
||||||
|
|
||||||
if (mLinkedId instanceof LinkedIdentity) {
|
if (mLinkedId instanceof LinkedIdentity) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user