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

Commit d43998a0 authored by David Luhmer's avatar David Luhmer
Browse files

use constants for custom exceptions and for username/token/url

parent 8f684fc8
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -143,10 +143,9 @@ public class AccountImporter {
        accMgr.invalidateAuthToken(auth_account_type, auth_token);

        //String accountName = future.getString(AccountManager.KEY_ACCOUNT_NAME);
        String username = future.getString("username");
        String token = future.getString("token");
        String server_url = future.getString("server_url");
        boolean dhnv = future.getBoolean("disable_hostname_verification");
        String username = future.getString(Constants.SSO_USERNAME);
        String token = future.getString(Constants.SSO_TOKEN);
        String server_url = future.getString(Constants.SSO_SERVER_URL);

        return new SingleSignOnAccount(account.name, username, token, server_url, dhnv);
    }
+13 −0
Original line number Diff line number Diff line
package com.nextcloud.android.sso;

public class Constants {

    // Authenticator related constants
    public final static String SSO_USERNAME = "username";
    public final static String SSO_TOKEN = "token";
    public final static String SSO_SERVER_URL = "server_url";

    // Custom Exceptions
    public static final String EXCEPTION_INVALID_TOKEN = "CE_1";
    public static final String EXCEPTION_ACCOUNT_NOT_FOUND = "CE_2";
}
+3 −2
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ import android.os.RemoteException;
import android.util.Log;

import com.google.gson.Gson;
import com.nextcloud.android.sso.Constants;
import com.nextcloud.android.sso.aidl.IInputStreamService;
import com.nextcloud.android.sso.aidl.IThreadListener;
import com.nextcloud.android.sso.aidl.NextcloudRequest;
@@ -194,9 +195,9 @@ public class NextcloudAPI {
        if(exception != null) {
            if(exception.getMessage() != null) {
                switch (exception.getMessage()) {
                    case "CE_1":
                    case Constants.EXCEPTION_INVALID_TOKEN:
                        throw new TokenMismatchException();
                    case "CE_2":
                    case Constants.EXCEPTION_ACCOUNT_NOT_FOUND:
                        throw new NextcloudFilesAppAccountNotFoundException();
                    default:
                        throw exception;