Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0954d184 authored by Mathew Smith's avatar Mathew Smith
Browse files

Code tidy ups to meet lint rules

parent cd647873
Loading
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -8,10 +8,10 @@ import com.fsck.k9.autodiscovery.api.DiscoveryResults
import com.fsck.k9.autodiscovery.api.DiscoveryTarget
import com.fsck.k9.helper.EmailHelper
import com.fsck.k9.mail.AuthType
import com.fsck.k9.mail.oauth.OAuth2Provider
import java.net.URI
import com.fsck.k9.mail.ConnectionSecurity
import com.fsck.k9.mail.oauth.OAuth2Provider
import com.fsck.k9.preferences.Protocols
import java.net.URI
import org.xmlpull.v1.XmlPullParser
import timber.log.Timber

+1 −0
Original line number Diff line number Diff line
package com.fsck.k9.mail.oauth;


public class AuthorizationException extends Exception {
    public AuthorizationException(String detailMessage, Throwable throwable) {
        super(detailMessage, throwable);
+19 −11
Original line number Diff line number Diff line
@@ -13,17 +13,25 @@ enum class OAuth2Provider(
    val isInDomain: (String) -> Boolean,
    val webViewClient: (String, OAuth2CodeGrantFlowManager) -> OAuth2WebViewClient
) {
    GMAIL(GmailAuthorizationServer(), {
    GMAIL(
        GmailAuthorizationServer(),
        {
            it in listOf("gmail.com", "android.com", "google.com", "googlemail.com")
    }, { email: String, codeGrantFlowManager: OAuth2CodeGrantFlowManager ->
        },
        { email: String, codeGrantFlowManager: OAuth2CodeGrantFlowManager ->
            GmailWebViewClient(email, codeGrantFlowManager)
    }),
    OUTLOOK(OutlookAuthorizationServer(), {
        }
    ),
    OUTLOOK(
        OutlookAuthorizationServer(),
        {
            val domainWoExt = it.split('.')[0]
            domainWoExt in listOf("hotmail", "live", "msn", "outlook")
    }, { email: String, codeGrantFlowManager: OAuth2CodeGrantFlowManager ->
        },
        { email: String, codeGrantFlowManager: OAuth2CodeGrantFlowManager ->
            OutlookWebViewClient(email, codeGrantFlowManager)
    });
        }
    );

    companion object {
        private fun getTypeFromDomain(domain: String): OAuth2Provider? {
+6 −3
Original line number Diff line number Diff line
package com.fsck.k9.mail.oauth;


import com.fsck.k9.mail.AuthenticationFailedException;
import com.fsck.k9.mail.oauth.authorizationserver.codegrantflow.OAuth2NeedUserPromptException;


public interface OAuth2TokenProvider {
    /**
     * A default timeout value to use when fetching tokens.
@@ -12,14 +14,15 @@ public interface OAuth2TokenProvider {
    /**
     * Fetch a token. No guarantees are provided for validity.
     */
    String getToken(String email, long timeoutMillis) throws AuthenticationFailedException, OAuth2NeedUserPromptException;
    String getToken(String email, long timeoutMillis)
            throws AuthenticationFailedException, OAuth2NeedUserPromptException;

    /**
     * Invalidate the token for this email.
     *
     * <p>
     * Note that the token should always be invalidated on credential failure. However invalidating a token every
     * single time is not recommended.
     * Note that the token should always be invalidated on credential failure. However invalidating a token every single
     * time is not recommended.
     * <p>
     * Invalidating a token and then failure with a new token should be treated as a permanent failure.
     */
+1 −2
Original line number Diff line number Diff line
@@ -9,8 +9,7 @@ import timber.log.Timber;


/**
 * Parses Google's Error/Challenge responses
 * See: https://developers.google.com/gmail/xoauth2_protocol#error_response
 * Parses Google's Error/Challenge responses See: https://developers.google.com/gmail/xoauth2_protocol#error_response
 */
public class XOAuth2ChallengeParser {
    public static final String BAD_RESPONSE = "400";
Loading