aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2015-09-10 02:11:43 +0200
committerVincent Breitmoser <valodim@mugenguild.com>2015-09-10 02:11:43 +0200
commit0f4af7d2ed11af8910ac30f79971775565fc6a9d (patch)
tree1d1ef22108a3ef0857d018cb1475a920f048404e
parent7fa1afe4300ff1603861389a242dce1a5b224943 (diff)
downloadopen-keychain-0f4af7d2ed11af8910ac30f79971775565fc6a9d.tar.gz
open-keychain-0f4af7d2ed11af8910ac30f79971775565fc6a9d.tar.bz2
open-keychain-0f4af7d2ed11af8910ac30f79971775565fc6a9d.zip
linked: fix screwups from last commit, sigh
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateGithubFragment.java26
1 files changed, 17 insertions, 9 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateGithubFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateGithubFragment.java
index f8f4a7020..b5dd2d758 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateGithubFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateGithubFragment.java
@@ -244,18 +244,19 @@ public class LinkedIdCreateGithubFragment extends CryptoOperationFragment<SaveKe
}
if (result != null) {
- Notify.create(activity, "Authorization failed!", Style.ERROR);
+ Notify.create(activity, "Authorization failed!", Style.ERROR).show();
return;
}
if (mException instanceof SocketTimeoutException) {
- Notify.create(activity, "Connection timeout!", Style.ERROR);
+ Notify.create(activity, "Connection timeout!", Style.ERROR).show();
} else if (mException instanceof HttpResultException) {
// we have the error code here.. should we use it?
Notify.create(activity,
- "Communication error: " + ((HttpResultException) mException).mResponse, Style.ERROR);
+ "Communication error: " + ((HttpResultException) mException).mResponse,
+ Style.ERROR).show();
} else if (mException instanceof IOException) {
- Notify.create(activity, "Network error!", Style.ERROR);
+ Notify.create(activity, "Network error!", Style.ERROR).show();
}
return;
@@ -330,13 +331,14 @@ public class LinkedIdCreateGithubFragment extends CryptoOperationFragment<SaveKe
}
if (mException instanceof SocketTimeoutException) {
- Notify.create(activity, "Connection timeout!", Style.ERROR);
+ Notify.create(activity, "Connection timeout!", Style.ERROR).show();
} else if (mException instanceof HttpResultException) {
// we have the error code here.. should we use it?
Notify.create(activity,
- "Communication error: " + ((HttpResultException) mException).mResponse, Style.ERROR);
+ "Communication error: " + ((HttpResultException) mException).mResponse,
+ Style.ERROR).show();
} else if (mException instanceof IOException) {
- Notify.create(activity, "Network error!", Style.ERROR);
+ Notify.create(activity, "Network error!", Style.ERROR).show();
}
return;
@@ -513,6 +515,7 @@ public class LinkedIdCreateGithubFragment extends CryptoOperationFragment<SaveKe
byte[] buf = new byte[16];
new Random().nextBytes(buf);
mOAuthState = new String(Hex.encode(buf));
+ mOAuthCode = null;
final Dialog auth_dialog = new Dialog(activity);
auth_dialog.setContentView(R.layout.oauth_webview);
@@ -526,6 +529,10 @@ public class LinkedIdCreateGithubFragment extends CryptoOperationFragment<SaveKe
Uri uri = Uri.parse(url);
if ("oauth-openkeychain".equals(uri.getScheme())) {
+ if (mOAuthCode != null) {
+ return true;
+ }
+
if (uri.getQueryParameter("error") != null) {
Log.i(Constants.TAG, "ACCESS_DENIED_HERE");
auth_dialog.dismiss();
@@ -539,7 +546,7 @@ public class LinkedIdCreateGithubFragment extends CryptoOperationFragment<SaveKe
return true;
}
// don't surf away from github!
- if ( ! "github.com".equals(uri.getHost())) {
+ if (!"github.com".equals(uri.getHost())) {
auth_dialog.dismiss();
return true;
}
@@ -638,7 +645,8 @@ public class LinkedIdCreateGithubFragment extends CryptoOperationFragment<SaveKe
nection.connect();
- if (nection.getResponseCode() != 200) {
+ int code = nection.getResponseCode();
+ if (code != HttpsURLConnection.HTTP_CREATED && code != HttpsURLConnection.HTTP_OK) {
throw new HttpResultException(nection.getResponseCode(), nection.getResponseMessage());
}