Loading mail/common/build.gradle +1 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ dependencies { implementation "com.squareup.okio:okio:${versions.okio}" implementation "commons-io:commons-io:${versions.commonsIo}" implementation "com.jakewharton.timber:timber:${versions.timber}" implementation "com.squareup.moshi:moshi:${versions.moshi}" testImplementation project(":mail:testing") testImplementation "org.robolectric:robolectric:${versions.robolectric}" Loading mail/common/src/main/java/com/fsck/k9/mail/oauth/XOAuth2ChallengeParser.java +12 −7 Original line number Diff line number Diff line package com.fsck.k9.mail.oauth; import java.io.IOException; import com.fsck.k9.mail.K9MailLib; import com.fsck.k9.mail.filter.Base64; import org.json.JSONException; import org.json.JSONObject; import com.squareup.moshi.JsonAdapter; import com.squareup.moshi.JsonDataException; import com.squareup.moshi.Moshi; import timber.log.Timber; Loading @@ -24,13 +27,15 @@ public class XOAuth2ChallengeParser { } try { JSONObject json = new JSONObject(decodedResponse); String status = json.getString("status"); if (!BAD_RESPONSE.equals(status)) { Moshi moshi = new Moshi.Builder().build(); JsonAdapter<XOAuth2Response> adapter = moshi.adapter(XOAuth2Response.class); XOAuth2Response responseObject = adapter.fromJson(decodedResponse); if (responseObject != null && responseObject.status != null && !BAD_RESPONSE.equals(responseObject.status)) { return false; } } catch (JSONException jsonException) { Timber.e("Error decoding JSON response from: %s. Response was: %s", host, decodedResponse); } catch (IOException | JsonDataException e) { Timber.e(e, "Error decoding JSON response from: %s. Response was: %s", host, decodedResponse); } return true; Loading mail/common/src/main/java/com/fsck/k9/mail/oauth/XOAuth2Response.java 0 → 100644 +6 −0 Original line number Diff line number Diff line package com.fsck.k9.mail.oauth; class XOAuth2Response { public String status; } Loading
mail/common/build.gradle +1 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ dependencies { implementation "com.squareup.okio:okio:${versions.okio}" implementation "commons-io:commons-io:${versions.commonsIo}" implementation "com.jakewharton.timber:timber:${versions.timber}" implementation "com.squareup.moshi:moshi:${versions.moshi}" testImplementation project(":mail:testing") testImplementation "org.robolectric:robolectric:${versions.robolectric}" Loading
mail/common/src/main/java/com/fsck/k9/mail/oauth/XOAuth2ChallengeParser.java +12 −7 Original line number Diff line number Diff line package com.fsck.k9.mail.oauth; import java.io.IOException; import com.fsck.k9.mail.K9MailLib; import com.fsck.k9.mail.filter.Base64; import org.json.JSONException; import org.json.JSONObject; import com.squareup.moshi.JsonAdapter; import com.squareup.moshi.JsonDataException; import com.squareup.moshi.Moshi; import timber.log.Timber; Loading @@ -24,13 +27,15 @@ public class XOAuth2ChallengeParser { } try { JSONObject json = new JSONObject(decodedResponse); String status = json.getString("status"); if (!BAD_RESPONSE.equals(status)) { Moshi moshi = new Moshi.Builder().build(); JsonAdapter<XOAuth2Response> adapter = moshi.adapter(XOAuth2Response.class); XOAuth2Response responseObject = adapter.fromJson(decodedResponse); if (responseObject != null && responseObject.status != null && !BAD_RESPONSE.equals(responseObject.status)) { return false; } } catch (JSONException jsonException) { Timber.e("Error decoding JSON response from: %s. Response was: %s", host, decodedResponse); } catch (IOException | JsonDataException e) { Timber.e(e, "Error decoding JSON response from: %s. Response was: %s", host, decodedResponse); } return true; Loading
mail/common/src/main/java/com/fsck/k9/mail/oauth/XOAuth2Response.java 0 → 100644 +6 −0 Original line number Diff line number Diff line package com.fsck.k9.mail.oauth; class XOAuth2Response { public String status; }