linked-ids: code cleanup, handle all lint errors
This commit is contained in:
@@ -1,6 +1,4 @@
|
|||||||
package org.sufficientlysecure.keychain.pgp.linked;
|
package org.sufficientlysecure.keychain.linked;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import org.apache.http.HttpEntity;
|
import org.apache.http.HttpEntity;
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
@@ -9,6 +7,10 @@ import org.apache.http.impl.client.DefaultHttpClient;
|
|||||||
import org.apache.http.params.BasicHttpParams;
|
import org.apache.http.params.BasicHttpParams;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
|
import org.sufficientlysecure.keychain.linked.resources.DnsResource;
|
||||||
|
import org.sufficientlysecure.keychain.linked.resources.GenericHttpsResource;
|
||||||
|
import org.sufficientlysecure.keychain.linked.resources.GithubResource;
|
||||||
|
import org.sufficientlysecure.keychain.linked.resources.TwitterResource;
|
||||||
import org.sufficientlysecure.keychain.operations.results.LinkedVerifyResult;
|
import org.sufficientlysecure.keychain.operations.results.LinkedVerifyResult;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
||||||
@@ -22,14 +24,110 @@ import java.io.InputStreamReader;
|
|||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
|
||||||
public abstract class LinkedCookieResource extends LinkedResource {
|
public abstract class LinkedCookieResource extends LinkedResource {
|
||||||
|
|
||||||
|
protected final URI mSubUri;
|
||||||
|
protected final Set<String> mFlags;
|
||||||
|
protected final HashMap<String,String> mParams;
|
||||||
|
|
||||||
|
public static Pattern magicPattern =
|
||||||
|
Pattern.compile("\\[Verifying my (?:Open)?PGP key: openpgp4fpr:([a-zA-Z0-9]+)]");
|
||||||
|
|
||||||
protected LinkedCookieResource(Set<String> flags, HashMap<String, String> params, URI uri) {
|
protected LinkedCookieResource(Set<String> flags, HashMap<String, String> params, URI uri) {
|
||||||
super(flags, params, uri);
|
mFlags = flags;
|
||||||
|
mParams = params;
|
||||||
|
mSubUri = uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public URI getSubUri () {
|
||||||
|
return mSubUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<String> getFlags () {
|
||||||
|
return new HashSet<>(mFlags);
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashMap<String,String> getParams () {
|
||||||
|
return new HashMap<>(mParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String generate (byte[] fingerprint) {
|
||||||
|
return String.format("[Verifying my OpenPGP key: openpgp4fpr:%s]",
|
||||||
|
KeyFormattingUtils.convertFingerprintToHex(fingerprint));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static LinkedCookieResource fromUri (URI uri) {
|
||||||
|
|
||||||
|
if (!"openpgpid+cookie".equals(uri.getScheme())) {
|
||||||
|
Log.e(Constants.TAG, "unknown uri scheme in (suspected) linked id packet");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!uri.isOpaque()) {
|
||||||
|
Log.e(Constants.TAG, "non-opaque uri in (suspected) linked id packet");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
String specific = uri.getSchemeSpecificPart();
|
||||||
|
if (!specific.contains("@")) {
|
||||||
|
Log.e(Constants.TAG, "unknown uri scheme in linked id packet");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] pieces = specific.split("@", 2);
|
||||||
|
URI subUri = URI.create(pieces[1]);
|
||||||
|
|
||||||
|
Set<String> flags = new HashSet<>();
|
||||||
|
HashMap<String,String> params = new HashMap<>();
|
||||||
|
if (!pieces[0].isEmpty()) {
|
||||||
|
String[] rawParams = pieces[0].split(";");
|
||||||
|
for (String param : rawParams) {
|
||||||
|
String[] p = param.split("=", 2);
|
||||||
|
if (p.length == 1) {
|
||||||
|
flags.add(param);
|
||||||
|
} else {
|
||||||
|
params.put(p[0], p[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return findResourceType(flags, params, subUri);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static LinkedCookieResource findResourceType (Set<String> flags,
|
||||||
|
HashMap<String,String> params,
|
||||||
|
URI subUri) {
|
||||||
|
|
||||||
|
LinkedCookieResource res;
|
||||||
|
|
||||||
|
res = GenericHttpsResource.create(flags, params, subUri);
|
||||||
|
if (res != null) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
res = DnsResource.create(flags, params, subUri);
|
||||||
|
if (res != null) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
res = TwitterResource.create(flags, params, subUri);
|
||||||
|
if (res != null) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
res = GithubResource.create(flags, params, subUri);
|
||||||
|
if (res != null) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public URI toUri () {
|
public URI toUri () {
|
||||||
@@ -68,19 +166,6 @@ public abstract class LinkedCookieResource extends LinkedResource {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public URI getSubUri () {
|
|
||||||
return mSubUri;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String generate (Context context, byte[] fingerprint) {
|
|
||||||
return String.format("[Verifying my OpenPGP key: openpgp4fpr:%s]",
|
|
||||||
KeyFormattingUtils.convertFingerprintToHex(fingerprint));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String generatePreview () {
|
|
||||||
return "[Verifying my OpenPGP key: openpgp4fpr:0x…]";
|
|
||||||
}
|
|
||||||
|
|
||||||
public LinkedVerifyResult verify(byte[] fingerprint) {
|
public LinkedVerifyResult verify(byte[] fingerprint) {
|
||||||
|
|
||||||
OperationLog log = new OperationLog();
|
OperationLog log = new OperationLog();
|
||||||
@@ -145,6 +230,7 @@ public abstract class LinkedCookieResource extends LinkedResource {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation") // HttpRequestBase is deprecated
|
||||||
public static String getResponseBody(HttpRequestBase request) throws IOException, HttpStatusException {
|
public static String getResponseBody(HttpRequestBase request) throws IOException, HttpStatusException {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package org.sufficientlysecure.keychain.linked;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.support.annotation.DrawableRes;
|
||||||
|
|
||||||
|
public class LinkedIdentity extends RawLinkedIdentity {
|
||||||
|
|
||||||
|
public final LinkedResource mResource;
|
||||||
|
|
||||||
|
protected LinkedIdentity(URI uri, LinkedResource resource) {
|
||||||
|
super(uri);
|
||||||
|
if (resource == null) {
|
||||||
|
throw new AssertionError("resource must not be null in a LinkedIdentity!");
|
||||||
|
}
|
||||||
|
mResource = resource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @DrawableRes int getDisplayIcon() {
|
||||||
|
return mResource.getDisplayIcon();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDisplayTitle(Context context) {
|
||||||
|
return mResource.getDisplayTitle(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDisplayComment(Context context) {
|
||||||
|
return mResource.getDisplayComment(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package org.sufficientlysecure.keychain.linked;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.support.annotation.DrawableRes;
|
||||||
|
import android.support.annotation.StringRes;
|
||||||
|
|
||||||
|
public abstract class LinkedResource {
|
||||||
|
|
||||||
|
public abstract URI toUri();
|
||||||
|
|
||||||
|
public abstract @DrawableRes int getDisplayIcon();
|
||||||
|
public abstract @StringRes int getVerifiedText(boolean isSecret);
|
||||||
|
public abstract String getDisplayTitle(Context context);
|
||||||
|
public abstract String getDisplayComment(Context context);
|
||||||
|
public boolean isViewable() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
public Intent getViewIntent() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package org.sufficientlysecure.keychain.pgp.linked;
|
package org.sufficientlysecure.keychain.linked;
|
||||||
|
|
||||||
import org.spongycastle.bcpg.UserAttributeSubpacket;
|
|
||||||
import org.spongycastle.util.Strings;
|
import org.spongycastle.util.Strings;
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.pgp.WrappedUserAttribute;
|
import org.sufficientlysecure.keychain.pgp.WrappedUserAttribute;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
|
||||||
@@ -12,17 +12,17 @@ import java.net.URI;
|
|||||||
import android.content.Context;
|
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. */
|
||||||
|
public class RawLinkedIdentity {
|
||||||
|
|
||||||
public class LinkedIdentity extends RawLinkedIdentity {
|
public final URI mUri;
|
||||||
|
|
||||||
public final LinkedResource mResource;
|
protected RawLinkedIdentity(URI uri) {
|
||||||
|
mUri = uri;
|
||||||
|
}
|
||||||
|
|
||||||
protected LinkedIdentity(URI uri, LinkedResource resource) {
|
public byte[] getEncoded() {
|
||||||
super(uri);
|
return Strings.toUTF8ByteArray(mUri.toASCIIString());
|
||||||
if (resource == null) {
|
|
||||||
throw new AssertionError("resource must not be null in a LinkedIdentity!");
|
|
||||||
}
|
|
||||||
mResource = resource;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RawLinkedIdentity fromAttributeData(byte[] data) throws IOException {
|
public static RawLinkedIdentity fromAttributeData(byte[] data) throws IOException {
|
||||||
@@ -36,26 +36,13 @@ public class LinkedIdentity extends RawLinkedIdentity {
|
|||||||
throw new IOException("no subpacket data");
|
throw new IOException("no subpacket data");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method parses a linked id from a UserAttributeSubpacket, or returns null if the
|
|
||||||
* subpacket can not be parsed as a valid linked id.
|
|
||||||
*/
|
|
||||||
static RawLinkedIdentity fromAttributeSubpacket(UserAttributeSubpacket subpacket) {
|
|
||||||
if (subpacket.getType() != 101) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
byte[] data = subpacket.getData();
|
|
||||||
|
|
||||||
return fromSubpacketData(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
static RawLinkedIdentity fromSubpacketData(byte[] data) {
|
static RawLinkedIdentity fromSubpacketData(byte[] data) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String uriStr = Strings.fromUTF8ByteArray(data);
|
String uriStr = Strings.fromUTF8ByteArray(data);
|
||||||
URI uri = URI.create(uriStr);
|
URI uri = URI.create(uriStr);
|
||||||
|
|
||||||
LinkedResource res = LinkedResource.fromUri(uri);
|
LinkedResource res = LinkedCookieResource.fromUri(uri);
|
||||||
if (res == null) {
|
if (res == null) {
|
||||||
return new RawLinkedIdentity(uri);
|
return new RawLinkedIdentity(uri);
|
||||||
}
|
}
|
||||||
@@ -73,16 +60,20 @@ public class LinkedIdentity extends RawLinkedIdentity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public WrappedUserAttribute toUserAttribute () {
|
||||||
|
return WrappedUserAttribute.fromSubpacket(WrappedUserAttribute.UAT_LINKED_ID, getEncoded());
|
||||||
|
}
|
||||||
|
|
||||||
public @DrawableRes int getDisplayIcon() {
|
public @DrawableRes int getDisplayIcon() {
|
||||||
return mResource.getDisplayIcon();
|
return R.drawable.ic_warning_grey_24dp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDisplayTitle(Context context) {
|
public String getDisplayTitle(Context context) {
|
||||||
return mResource.getDisplayTitle(context);
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDisplayComment(Context context) {
|
public String getDisplayComment(Context context) {
|
||||||
return mResource.getDisplayComment(context);
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.sufficientlysecure.keychain.pgp.linked.resources;
|
package org.sufficientlysecure.keychain.linked.resources;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.annotation.DrawableRes;
|
import android.support.annotation.DrawableRes;
|
||||||
@@ -6,7 +6,7 @@ import android.support.annotation.StringRes;
|
|||||||
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
||||||
import org.sufficientlysecure.keychain.pgp.linked.LinkedCookieResource;
|
import org.sufficientlysecure.keychain.linked.LinkedCookieResource;
|
||||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
@@ -42,7 +42,7 @@ public class DnsResource extends LinkedCookieResource {
|
|||||||
mType = type;
|
mType = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String generateText (Context context, byte[] fingerprint) {
|
public static String generateText(byte[] fingerprint) {
|
||||||
|
|
||||||
return String.format("openpgpid+cookie=%s",
|
return String.format("openpgpid+cookie=%s",
|
||||||
KeyFormattingUtils.convertFingerprintToHex(fingerprint));
|
KeyFormattingUtils.convertFingerprintToHex(fingerprint));
|
||||||
@@ -50,8 +50,8 @@ public class DnsResource extends LinkedCookieResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static DnsResource createNew (String domain) {
|
public static DnsResource createNew (String domain) {
|
||||||
HashSet<String> flags = new HashSet<String>();
|
HashSet<String> flags = new HashSet<>();
|
||||||
HashMap<String,String> params = new HashMap<String,String>();
|
HashMap<String,String> params = new HashMap<>();
|
||||||
URI uri = URI.create("dns:" + domain);
|
URI uri = URI.create("dns:" + domain);
|
||||||
return create(flags, params, uri);
|
return create(flags, params, uri);
|
||||||
}
|
}
|
||||||
@@ -74,9 +74,11 @@ public class DnsResource extends LinkedCookieResource {
|
|||||||
// In either case, part before a ? is the fqdn
|
// In either case, part before a ? is the fqdn
|
||||||
String fqdn = pieces[0];
|
String fqdn = pieces[0];
|
||||||
// There may be a query part
|
// There may be a query part
|
||||||
|
/*
|
||||||
if (pieces.length > 1) {
|
if (pieces.length > 1) {
|
||||||
// TODO parse CLASS and TYPE query paramters
|
// parse CLASS and TYPE query paramters
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
CLASS clazz = CLASS.IN;
|
CLASS clazz = CLASS.IN;
|
||||||
TYPE type = TYPE.TXT;
|
TYPE type = TYPE.TXT;
|
||||||
@@ -84,6 +86,7 @@ public class DnsResource extends LinkedCookieResource {
|
|||||||
return new DnsResource(flags, params, uri, fqdn, clazz, type);
|
return new DnsResource(flags, params, uri, fqdn, clazz, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public String getFqdn() {
|
public String getFqdn() {
|
||||||
return mFqdn;
|
return mFqdn;
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.sufficientlysecure.keychain.pgp.linked.resources;
|
package org.sufficientlysecure.keychain.linked.resources;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -10,7 +10,7 @@ import org.apache.http.client.methods.HttpGet;
|
|||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
||||||
import org.sufficientlysecure.keychain.pgp.linked.LinkedCookieResource;
|
import org.sufficientlysecure.keychain.linked.LinkedCookieResource;
|
||||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -19,7 +19,6 @@ import java.util.HashMap;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
|
||||||
public class GenericHttpsResource extends LinkedCookieResource {
|
public class GenericHttpsResource extends LinkedCookieResource {
|
||||||
|
|
||||||
GenericHttpsResource(Set<String> flags, HashMap<String,String> params, URI uri) {
|
GenericHttpsResource(Set<String> flags, HashMap<String,String> params, URI uri) {
|
||||||
@@ -27,23 +26,20 @@ public class GenericHttpsResource extends LinkedCookieResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String generateText (Context context, byte[] fingerprint) {
|
public static String generateText (Context context, byte[] fingerprint) {
|
||||||
String cookie = LinkedCookieResource.generate(context, fingerprint);
|
String cookie = LinkedCookieResource.generate(fingerprint);
|
||||||
|
|
||||||
return String.format(context.getResources().getString(R.string.linked_id_generic_text),
|
return String.format(context.getResources().getString(R.string.linked_id_generic_text),
|
||||||
cookie, "0x" + KeyFormattingUtils.convertFingerprintToHex(fingerprint).substring(24));
|
cookie, "0x" + KeyFormattingUtils.convertFingerprintToHex(fingerprint).substring(24));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation") // HttpGet is deprecated
|
||||||
@Override
|
@Override
|
||||||
protected String fetchResource (OperationLog log, int indent) throws HttpStatusException, IOException {
|
protected String fetchResource (OperationLog log, int indent) throws HttpStatusException, IOException {
|
||||||
|
|
||||||
log.add(LogType.MSG_LV_FETCH, indent, mSubUri.toString());
|
log.add(LogType.MSG_LV_FETCH, indent, mSubUri.toString());
|
||||||
indent += 1;
|
|
||||||
|
|
||||||
HttpGet httpGet = new HttpGet(mSubUri);
|
HttpGet httpGet = new HttpGet(mSubUri);
|
||||||
return getResponseBody(httpGet);
|
return getResponseBody(httpGet);
|
||||||
|
|
||||||
// log.add(LogType.MSG_LV_FETCH_REDIR, indent, url.toString());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GenericHttpsResource createNew (URI uri) {
|
public static GenericHttpsResource createNew (URI uri) {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.sufficientlysecure.keychain.pgp.linked.resources;
|
package org.sufficientlysecure.keychain.linked.resources;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -14,7 +14,7 @@ import org.sufficientlysecure.keychain.Constants;
|
|||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
||||||
import org.sufficientlysecure.keychain.pgp.linked.LinkedCookieResource;
|
import org.sufficientlysecure.keychain.linked.LinkedCookieResource;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -42,11 +42,12 @@ public class GithubResource extends LinkedCookieResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String generate(Context context, byte[] fingerprint) {
|
public static String generate(Context context, byte[] fingerprint) {
|
||||||
String cookie = LinkedCookieResource.generate(context, fingerprint);
|
String cookie = LinkedCookieResource.generate(fingerprint);
|
||||||
|
|
||||||
return String.format(context.getResources().getString(R.string.linked_id_github_text), cookie);
|
return String.format(context.getResources().getString(R.string.linked_id_github_text), cookie);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation") // HttpGet is deprecated
|
||||||
@Override
|
@Override
|
||||||
protected String fetchResource (OperationLog log, int indent)
|
protected String fetchResource (OperationLog log, int indent)
|
||||||
throws HttpStatusException, IOException, JSONException {
|
throws HttpStatusException, IOException, JSONException {
|
||||||
@@ -78,6 +79,7 @@ public class GithubResource extends LinkedCookieResource {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public static GithubResource searchInGithubStream(String screenName, String needle,
|
public static GithubResource searchInGithubStream(String screenName, String needle,
|
||||||
OperationLog log) {
|
OperationLog log) {
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.sufficientlysecure.keychain.pgp.linked.resources;
|
package org.sufficientlysecure.keychain.linked.resources;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -19,7 +19,7 @@ import org.sufficientlysecure.keychain.Constants;
|
|||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
||||||
import org.sufficientlysecure.keychain.pgp.linked.LinkedCookieResource;
|
import org.sufficientlysecure.keychain.linked.LinkedCookieResource;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
@@ -66,6 +66,7 @@ public class TwitterResource extends LinkedCookieResource {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
protected String fetchResource(OperationLog log, int indent) throws IOException, HttpStatusException,
|
protected String fetchResource(OperationLog log, int indent) throws IOException, HttpStatusException,
|
||||||
JSONException {
|
JSONException {
|
||||||
@@ -139,6 +140,7 @@ public class TwitterResource extends LinkedCookieResource {
|
|||||||
return intent;
|
return intent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public static TwitterResource searchInTwitterStream(
|
public static TwitterResource searchInTwitterStream(
|
||||||
String screenName, String needle, OperationLog log) {
|
String screenName, String needle, OperationLog log) {
|
||||||
|
|
||||||
@@ -200,6 +202,7 @@ public class TwitterResource extends LinkedCookieResource {
|
|||||||
|
|
||||||
private static String cachedAuthToken;
|
private static String cachedAuthToken;
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
private static String getAuthToken() throws IOException, HttpStatusException, JSONException {
|
private static String getAuthToken() throws IOException, HttpStatusException, JSONException {
|
||||||
if (cachedAuthToken != null) {
|
if (cachedAuthToken != null) {
|
||||||
return cachedAuthToken;
|
return cachedAuthToken;
|
||||||
@@ -1,122 +0,0 @@
|
|||||||
package org.sufficientlysecure.keychain.pgp.linked;
|
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
|
||||||
import org.sufficientlysecure.keychain.pgp.linked.resources.DnsResource;
|
|
||||||
import org.sufficientlysecure.keychain.pgp.linked.resources.GenericHttpsResource;
|
|
||||||
import org.sufficientlysecure.keychain.pgp.linked.resources.GithubResource;
|
|
||||||
import org.sufficientlysecure.keychain.pgp.linked.resources.TwitterResource;
|
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.support.annotation.DrawableRes;
|
|
||||||
import android.support.annotation.StringRes;
|
|
||||||
|
|
||||||
|
|
||||||
public abstract class LinkedResource {
|
|
||||||
|
|
||||||
protected final URI mSubUri;
|
|
||||||
protected final Set<String> mFlags;
|
|
||||||
protected final HashMap<String,String> mParams;
|
|
||||||
|
|
||||||
public static Pattern magicPattern =
|
|
||||||
Pattern.compile("\\[Verifying my (?:Open)?PGP key: openpgp4fpr:([a-zA-Z0-9]+)]");
|
|
||||||
|
|
||||||
protected LinkedResource(Set<String> flags, HashMap<String, String> params, URI uri) {
|
|
||||||
mFlags = flags;
|
|
||||||
mParams = params;
|
|
||||||
mSubUri = uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<String> getFlags () {
|
|
||||||
return new HashSet<>(mFlags);
|
|
||||||
}
|
|
||||||
|
|
||||||
public HashMap<String,String> getParams () {
|
|
||||||
return new HashMap<>(mParams);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static LinkedCookieResource fromUri (URI uri) {
|
|
||||||
|
|
||||||
if (!"openpgpid+cookie".equals(uri.getScheme())) {
|
|
||||||
Log.e(Constants.TAG, "unknown uri scheme in (suspected) linked id packet");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!uri.isOpaque()) {
|
|
||||||
Log.e(Constants.TAG, "non-opaque uri in (suspected) linked id packet");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
String specific = uri.getSchemeSpecificPart();
|
|
||||||
if (!specific.contains("@")) {
|
|
||||||
Log.e(Constants.TAG, "unknown uri scheme in linked id packet");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
String[] pieces = specific.split("@", 2);
|
|
||||||
URI subUri = URI.create(pieces[1]);
|
|
||||||
|
|
||||||
Set<String> flags = new HashSet<>();
|
|
||||||
HashMap<String,String> params = new HashMap<>();
|
|
||||||
if (!pieces[0].isEmpty()) {
|
|
||||||
String[] rawParams = pieces[0].split(";");
|
|
||||||
for (String param : rawParams) {
|
|
||||||
String[] p = param.split("=", 2);
|
|
||||||
if (p.length == 1) {
|
|
||||||
flags.add(param);
|
|
||||||
} else {
|
|
||||||
params.put(p[0], p[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return findResourceType(flags, params, subUri);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static LinkedCookieResource findResourceType (Set<String> flags,
|
|
||||||
HashMap<String,String> params,
|
|
||||||
URI subUri) {
|
|
||||||
|
|
||||||
LinkedCookieResource res;
|
|
||||||
|
|
||||||
res = GenericHttpsResource.create(flags, params, subUri);
|
|
||||||
if (res != null) {
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
res = DnsResource.create(flags, params, subUri);
|
|
||||||
if (res != null) {
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
res = TwitterResource.create(flags, params, subUri);
|
|
||||||
if (res != null) {
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
res = GithubResource.create(flags, params, subUri);
|
|
||||||
if (res != null) {
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract @DrawableRes int getDisplayIcon();
|
|
||||||
public abstract @StringRes int getVerifiedText(boolean isSecret);
|
|
||||||
public abstract String getDisplayTitle(Context context);
|
|
||||||
public abstract String getDisplayComment(Context context);
|
|
||||||
public boolean isViewable() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
public Intent getViewIntent() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
package org.sufficientlysecure.keychain.pgp.linked;
|
|
||||||
|
|
||||||
import org.spongycastle.util.Strings;
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
|
||||||
import org.sufficientlysecure.keychain.pgp.WrappedUserAttribute;
|
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.support.annotation.DrawableRes;
|
|
||||||
|
|
||||||
/** The RawLinkedIdentity contains raw parsed data from a Linked Identity subpacket. */
|
|
||||||
public class RawLinkedIdentity {
|
|
||||||
|
|
||||||
public final URI mUri;
|
|
||||||
|
|
||||||
protected RawLinkedIdentity(URI uri) {
|
|
||||||
mUri = uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] getEncoded() {
|
|
||||||
return Strings.toUTF8ByteArray(mUri.toASCIIString());
|
|
||||||
}
|
|
||||||
|
|
||||||
public WrappedUserAttribute toUserAttribute () {
|
|
||||||
return WrappedUserAttribute.fromSubpacket(WrappedUserAttribute.UAT_LINKED_ID, getEncoded());
|
|
||||||
}
|
|
||||||
|
|
||||||
public @DrawableRes int getDisplayIcon() {
|
|
||||||
return R.drawable.ic_warning_grey_24dp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDisplayTitle(Context context) {
|
|
||||||
return "unknown";
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDisplayComment(Context context) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -33,8 +33,8 @@ 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.pgp.linked.LinkedIdentity;
|
import org.sufficientlysecure.keychain.linked.LinkedIdentity;
|
||||||
import org.sufficientlysecure.keychain.pgp.linked.RawLinkedIdentity;
|
import org.sufficientlysecure.keychain.linked.RawLinkedIdentity;
|
||||||
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;
|
||||||
|
|||||||
@@ -29,8 +29,7 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.pgp.linked.RawLinkedIdentity;
|
import org.sufficientlysecure.keychain.linked.resources.DnsResource;
|
||||||
import org.sufficientlysecure.keychain.pgp.linked.resources.DnsResource;
|
|
||||||
|
|
||||||
public class LinkedIdCreateDnsStep1Fragment extends Fragment {
|
public class LinkedIdCreateDnsStep1Fragment extends Fragment {
|
||||||
|
|
||||||
@@ -73,7 +72,7 @@ public class LinkedIdCreateDnsStep1Fragment extends Fragment {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String proofText = DnsResource.generateText(getActivity(),
|
String proofText = DnsResource.generateText(
|
||||||
mLinkedIdWizard.mFingerprint);
|
mLinkedIdWizard.mFingerprint);
|
||||||
|
|
||||||
LinkedIdCreateDnsStep2Fragment frag =
|
LinkedIdCreateDnsStep2Fragment frag =
|
||||||
@@ -120,8 +119,6 @@ public class LinkedIdCreateDnsStep1Fragment extends Fragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mEditDns.setText("test.mugenguild.com");
|
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,26 +19,21 @@ package org.sufficientlysecure.keychain.ui.linked;
|
|||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.compatibility.ClipboardReflection;
|
import org.sufficientlysecure.keychain.compatibility.ClipboardReflection;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
||||||
import org.sufficientlysecure.keychain.pgp.linked.LinkedCookieResource;
|
import org.sufficientlysecure.keychain.linked.LinkedCookieResource;
|
||||||
import org.sufficientlysecure.keychain.pgp.linked.resources.DnsResource;
|
import org.sufficientlysecure.keychain.linked.resources.DnsResource;
|
||||||
import org.sufficientlysecure.keychain.ui.util.Notify;
|
import org.sufficientlysecure.keychain.ui.util.Notify;
|
||||||
import org.sufficientlysecure.keychain.ui.util.Notify.Style;
|
import org.sufficientlysecure.keychain.ui.util.Notify.Style;
|
||||||
import org.sufficientlysecure.keychain.util.FileHelper;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
|
||||||
@@ -84,22 +79,26 @@ public class LinkedIdCreateDnsStep2Fragment extends LinkedIdCreateFinalFragment
|
|||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||||
|
|
||||||
view.findViewById(R.id.button_send).setOnClickListener(new OnClickListener() {
|
if (view != null) {
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
proofSend();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
view.findViewById(R.id.button_save).setOnClickListener(new OnClickListener() {
|
view.findViewById(R.id.button_send).setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
proofToClipboard();
|
proofSend();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mTextView = (TextView) view.findViewById(R.id.linked_create_dns_text);
|
view.findViewById(R.id.button_save).setOnClickListener(new OnClickListener() {
|
||||||
mTextView.setText(mResourceString);
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
proofToClipboard();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mTextView = (TextView) view.findViewById(R.id.linked_create_dns_text);
|
||||||
|
mTextView.setText(mResourceString);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ import org.sufficientlysecure.keychain.operations.results.LinkedVerifyResult;
|
|||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
||||||
import org.sufficientlysecure.keychain.pgp.WrappedUserAttribute;
|
import org.sufficientlysecure.keychain.pgp.WrappedUserAttribute;
|
||||||
import org.sufficientlysecure.keychain.pgp.linked.LinkedCookieResource;
|
import org.sufficientlysecure.keychain.linked.LinkedCookieResource;
|
||||||
import org.sufficientlysecure.keychain.pgp.linked.LinkedIdentity;
|
import org.sufficientlysecure.keychain.linked.LinkedIdentity;
|
||||||
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
||||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
||||||
import org.sufficientlysecure.keychain.service.ServiceProgressHandler;
|
import org.sufficientlysecure.keychain.service.ServiceProgressHandler;
|
||||||
|
|||||||
@@ -17,11 +17,6 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.ui.linked;
|
package org.sufficientlysecure.keychain.ui.linked;
|
||||||
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.URL;
|
|
||||||
|
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
@@ -109,11 +104,11 @@ public class LinkedIdCreateGithubStep1Fragment extends Fragment {
|
|||||||
});
|
});
|
||||||
|
|
||||||
mEditHandle = (EditText) view.findViewById(R.id.linked_create_github_handle);
|
mEditHandle = (EditText) view.findViewById(R.id.linked_create_github_handle);
|
||||||
mEditHandle.setText("Valodim");
|
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* not used at this point, too much hassle
|
||||||
private static Boolean checkHandle(String handle) {
|
private static Boolean checkHandle(String handle) {
|
||||||
try {
|
try {
|
||||||
HttpURLConnection nection =
|
HttpURLConnection nection =
|
||||||
@@ -125,5 +120,6 @@ public class LinkedIdCreateGithubStep1Fragment extends Fragment {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ import android.view.ViewGroup;
|
|||||||
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
||||||
import org.sufficientlysecure.keychain.pgp.linked.LinkedCookieResource;
|
import org.sufficientlysecure.keychain.linked.LinkedCookieResource;
|
||||||
import org.sufficientlysecure.keychain.pgp.linked.resources.GithubResource;
|
import org.sufficientlysecure.keychain.linked.resources.GithubResource;
|
||||||
|
|
||||||
|
|
||||||
public class LinkedIdCreateGithubStep2Fragment extends LinkedIdCreateFinalFragment {
|
public class LinkedIdCreateGithubStep2Fragment extends LinkedIdCreateFinalFragment {
|
||||||
@@ -65,19 +65,23 @@ public class LinkedIdCreateGithubStep2Fragment extends LinkedIdCreateFinalFragme
|
|||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||||
|
|
||||||
view.findViewById(R.id.button_send).setOnClickListener(new OnClickListener() {
|
if (view != null) {
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
proofSend();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
view.findViewById(R.id.button_share).setOnClickListener(new OnClickListener() {
|
view.findViewById(R.id.button_send).setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
proofShare();
|
proofSend();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
view.findViewById(R.id.button_share).setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
proofShare();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,8 +29,7 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.pgp.linked.RawLinkedIdentity;
|
import org.sufficientlysecure.keychain.linked.resources.GenericHttpsResource;
|
||||||
import org.sufficientlysecure.keychain.pgp.linked.resources.GenericHttpsResource;
|
|
||||||
|
|
||||||
public class LinkedIdCreateHttpsStep1Fragment extends Fragment {
|
public class LinkedIdCreateHttpsStep1Fragment extends Fragment {
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import android.widget.EditText;
|
|||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
||||||
import org.sufficientlysecure.keychain.pgp.linked.resources.GenericHttpsResource;
|
import org.sufficientlysecure.keychain.linked.resources.GenericHttpsResource;
|
||||||
import org.sufficientlysecure.keychain.ui.util.Notify;
|
import org.sufficientlysecure.keychain.ui.util.Notify;
|
||||||
import org.sufficientlysecure.keychain.ui.util.Notify.Style;
|
import org.sufficientlysecure.keychain.ui.util.Notify.Style;
|
||||||
import org.sufficientlysecure.keychain.util.FileHelper;
|
import org.sufficientlysecure.keychain.util.FileHelper;
|
||||||
@@ -95,22 +95,25 @@ public class LinkedIdCreateHttpsStep2Fragment extends LinkedIdCreateFinalFragmen
|
|||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||||
|
|
||||||
view.findViewById(R.id.button_send).setOnClickListener(new OnClickListener() {
|
if (view != null) {
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
proofSend();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
view.findViewById(R.id.button_save).setOnClickListener(new OnClickListener() {
|
view.findViewById(R.id.button_send).setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
proofSave();
|
proofSend();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mEditUri = (EditText) view.findViewById(R.id.linked_create_https_uri);
|
view.findViewById(R.id.button_save).setOnClickListener(new OnClickListener() {
|
||||||
mEditUri.setText(mResourceUri.toString());
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
proofSave();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mEditUri = (EditText) view.findViewById(R.id.linked_create_https_uri);
|
||||||
|
mEditUri.setText(mResourceUri.toString());
|
||||||
|
}
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,10 +29,6 @@ import android.widget.EditText;
|
|||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.ui.util.Notify;
|
import org.sufficientlysecure.keychain.ui.util.Notify;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.URL;
|
|
||||||
|
|
||||||
public class LinkedIdCreateTwitterStep1Fragment extends Fragment {
|
public class LinkedIdCreateTwitterStep1Fragment extends Fragment {
|
||||||
|
|
||||||
LinkedIdWizard mLinkedIdWizard;
|
LinkedIdWizard mLinkedIdWizard;
|
||||||
@@ -119,6 +115,7 @@ public class LinkedIdCreateTwitterStep1Fragment extends Fragment {
|
|||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* not used at this point, too many problems
|
||||||
private static Boolean checkHandle(String handle) {
|
private static Boolean checkHandle(String handle) {
|
||||||
try {
|
try {
|
||||||
HttpURLConnection nection =
|
HttpURLConnection nection =
|
||||||
@@ -130,5 +127,6 @@ public class LinkedIdCreateTwitterStep1Fragment extends Fragment {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,13 +25,12 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
|
||||||
import org.sufficientlysecure.keychain.pgp.linked.LinkedCookieResource;
|
import org.sufficientlysecure.keychain.linked.LinkedCookieResource;
|
||||||
import org.sufficientlysecure.keychain.pgp.linked.resources.TwitterResource;
|
import org.sufficientlysecure.keychain.linked.resources.TwitterResource;
|
||||||
|
|
||||||
public class LinkedIdCreateTwitterStep2Fragment extends LinkedIdCreateFinalFragment {
|
public class LinkedIdCreateTwitterStep2Fragment extends LinkedIdCreateFinalFragment {
|
||||||
|
|
||||||
@@ -57,7 +56,7 @@ public class LinkedIdCreateTwitterStep2Fragment extends LinkedIdCreateFinalFragm
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
mResourceString =
|
mResourceString =
|
||||||
TwitterResource.generate(getActivity(), mLinkedIdWizard.mFingerprint);
|
TwitterResource.generate(mLinkedIdWizard.mFingerprint);
|
||||||
|
|
||||||
mResourceHandle = getArguments().getString(ARG_HANDLE);
|
mResourceHandle = getArguments().getString(ARG_HANDLE);
|
||||||
|
|
||||||
@@ -67,23 +66,25 @@ public class LinkedIdCreateTwitterStep2Fragment extends LinkedIdCreateFinalFragm
|
|||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||||
|
|
||||||
view.findViewById(R.id.button_send).setOnClickListener(new OnClickListener() {
|
if (view != null) {
|
||||||
@Override
|
view.findViewById(R.id.button_send).setOnClickListener(new OnClickListener() {
|
||||||
public void onClick(View v) {
|
@Override
|
||||||
proofSend();
|
public void onClick(View v) {
|
||||||
}
|
proofSend();
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
|
||||||
view.findViewById(R.id.button_share).setOnClickListener(new OnClickListener() {
|
view.findViewById(R.id.button_share).setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
proofShare();
|
proofShare();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
((TextView) view.findViewById(R.id.linked_tweet_published)).setText(
|
((TextView) view.findViewById(R.id.linked_tweet_published)).setText(
|
||||||
Html.fromHtml(getString(R.string.linked_create_twitter_2_3, mResourceHandle))
|
Html.fromHtml(getString(R.string.linked_create_twitter_2_3, mResourceHandle))
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,10 +33,10 @@ import org.sufficientlysecure.keychain.Constants.key;
|
|||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.operations.results.CertifyResult;
|
import org.sufficientlysecure.keychain.operations.results.CertifyResult;
|
||||||
import org.sufficientlysecure.keychain.operations.results.LinkedVerifyResult;
|
import org.sufficientlysecure.keychain.operations.results.LinkedVerifyResult;
|
||||||
import org.sufficientlysecure.keychain.pgp.linked.LinkedCookieResource;
|
import org.sufficientlysecure.keychain.linked.LinkedCookieResource;
|
||||||
import org.sufficientlysecure.keychain.pgp.linked.LinkedIdentity;
|
import org.sufficientlysecure.keychain.linked.LinkedIdentity;
|
||||||
import org.sufficientlysecure.keychain.pgp.linked.LinkedResource;
|
import org.sufficientlysecure.keychain.linked.LinkedResource;
|
||||||
import org.sufficientlysecure.keychain.pgp.linked.RawLinkedIdentity;
|
import org.sufficientlysecure.keychain.linked.RawLinkedIdentity;
|
||||||
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;
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import android.net.Uri;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentTransaction;
|
import android.support.v4.app.FragmentTransaction;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user