Loading src/main/java/com/nextcloud/android/sso/AccountImporter.java +7 −3 Original line number Diff line number Diff line Loading @@ -64,7 +64,7 @@ public class AccountImporter { } public static void pickNewAccount(android.support.v4.app.Fragment fragment) throws NextcloudFilesAppNotInstalledException { public static void pickNewAccount(Fragment fragment) throws NextcloudFilesAppNotInstalledException { if(appInstalledOrNot(fragment.getContext(), "com.nextcloud.client")) { // Clear all tokens first to prevent some caching issues.. Loading Loading @@ -195,6 +195,8 @@ public class AccountImporter { SingleSignOnAccount singleSignOnAccount = extractSingleSignOnAccountFromResponse(data, context); callback.accountAccessGranted(singleSignOnAccount); break; default: break; } } else if (resultCode == RESULT_CANCELED) { switch (requestCode) { Loading @@ -212,14 +214,16 @@ public class AccountImporter { Log.e(TAG, e.getMessage()); } break; default: break; } } } public static void handleFailedAuthRequest(Intent data) throws Exception { public static void handleFailedAuthRequest(Intent data) throws SSOException { String exception = data.getStringExtra(NEXTCLOUD_SSO_EXCEPTION); SSOException.ParseAndThrowNextcloudCustomException(new Exception(exception)); throw SSOException.parseNextcloudCustomException(new Exception(exception)); } public static void requestAuthToken(Fragment fragment, Intent intent) throws NextcloudFilesAppNotSupportedException { Loading src/main/java/com/nextcloud/android/sso/api/NextcloudAPI.java +2 −2 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ import java.lang.reflect.Type; import io.reactivex.Observable; import io.reactivex.annotations.NonNull; import static com.nextcloud.android.sso.exceptions.SSOException.ParseAndThrowNextcloudCustomException; import static com.nextcloud.android.sso.exceptions.SSOException.parseNextcloudCustomException; /** * Nextcloud SingleSignOn Loading Loading @@ -231,7 +231,7 @@ public class NextcloudAPI { // Handle Remote Exceptions if(exception != null) { if(exception.getMessage() != null) { ParseAndThrowNextcloudCustomException(exception); parseNextcloudCustomException(exception); } throw exception; } Loading src/main/java/com/nextcloud/android/sso/exceptions/SSOException.java +8 −8 Original line number Diff line number Diff line Loading @@ -85,23 +85,23 @@ public class SSOException extends Exception { } public static void ParseAndThrowNextcloudCustomException(Exception exception) throws Exception { public static SSOException parseNextcloudCustomException(Exception exception) { switch (exception.getMessage()) { case Constants.EXCEPTION_INVALID_TOKEN: throw new TokenMismatchException(); return new TokenMismatchException(); case Constants.EXCEPTION_ACCOUNT_NOT_FOUND: throw new NextcloudFilesAppAccountNotFoundException(); return new NextcloudFilesAppAccountNotFoundException(); case Constants.EXCEPTION_UNSUPPORTED_METHOD: throw new NextcloudUnsupportedMethodException(); return new NextcloudUnsupportedMethodException(); case Constants.EXCEPTION_INVALID_REQUEST_URL: throw new NextcloudInvalidRequestUrlException(exception.getCause().getMessage()); return new NextcloudInvalidRequestUrlException(exception.getCause().getMessage()); case Constants.EXCEPTION_HTTP_REQUEST_FAILED: int statusCode = Integer.parseInt(exception.getCause().getMessage()); throw new NextcloudHttpRequestFailedException(statusCode); return new NextcloudHttpRequestFailedException(statusCode); case Constants.EXCEPTION_ACCOUNT_ACCESS_DECLINED: throw new NextcloudFilesAppAccountPermissionNotGrantedException(); return new NextcloudFilesAppAccountPermissionNotGrantedException(); default: throw exception; return new UnknownErrorException(exception.getMessage()); } } } src/main/java/com/nextcloud/android/sso/exceptions/UnknownErrorException.java 0 → 100644 +22 −0 Original line number Diff line number Diff line package com.nextcloud.android.sso.exceptions; import android.content.Context; import com.nextcloud.android.sso.model.ExceptionMessage; public class UnknownErrorException extends SSOException { public UnknownErrorException() { super(); } public UnknownErrorException(String message) { super(); this.em = new ExceptionMessage("", message); } @Override public void loadExceptionMessage(Context context) { } } Loading
src/main/java/com/nextcloud/android/sso/AccountImporter.java +7 −3 Original line number Diff line number Diff line Loading @@ -64,7 +64,7 @@ public class AccountImporter { } public static void pickNewAccount(android.support.v4.app.Fragment fragment) throws NextcloudFilesAppNotInstalledException { public static void pickNewAccount(Fragment fragment) throws NextcloudFilesAppNotInstalledException { if(appInstalledOrNot(fragment.getContext(), "com.nextcloud.client")) { // Clear all tokens first to prevent some caching issues.. Loading Loading @@ -195,6 +195,8 @@ public class AccountImporter { SingleSignOnAccount singleSignOnAccount = extractSingleSignOnAccountFromResponse(data, context); callback.accountAccessGranted(singleSignOnAccount); break; default: break; } } else if (resultCode == RESULT_CANCELED) { switch (requestCode) { Loading @@ -212,14 +214,16 @@ public class AccountImporter { Log.e(TAG, e.getMessage()); } break; default: break; } } } public static void handleFailedAuthRequest(Intent data) throws Exception { public static void handleFailedAuthRequest(Intent data) throws SSOException { String exception = data.getStringExtra(NEXTCLOUD_SSO_EXCEPTION); SSOException.ParseAndThrowNextcloudCustomException(new Exception(exception)); throw SSOException.parseNextcloudCustomException(new Exception(exception)); } public static void requestAuthToken(Fragment fragment, Intent intent) throws NextcloudFilesAppNotSupportedException { Loading
src/main/java/com/nextcloud/android/sso/api/NextcloudAPI.java +2 −2 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ import java.lang.reflect.Type; import io.reactivex.Observable; import io.reactivex.annotations.NonNull; import static com.nextcloud.android.sso.exceptions.SSOException.ParseAndThrowNextcloudCustomException; import static com.nextcloud.android.sso.exceptions.SSOException.parseNextcloudCustomException; /** * Nextcloud SingleSignOn Loading Loading @@ -231,7 +231,7 @@ public class NextcloudAPI { // Handle Remote Exceptions if(exception != null) { if(exception.getMessage() != null) { ParseAndThrowNextcloudCustomException(exception); parseNextcloudCustomException(exception); } throw exception; } Loading
src/main/java/com/nextcloud/android/sso/exceptions/SSOException.java +8 −8 Original line number Diff line number Diff line Loading @@ -85,23 +85,23 @@ public class SSOException extends Exception { } public static void ParseAndThrowNextcloudCustomException(Exception exception) throws Exception { public static SSOException parseNextcloudCustomException(Exception exception) { switch (exception.getMessage()) { case Constants.EXCEPTION_INVALID_TOKEN: throw new TokenMismatchException(); return new TokenMismatchException(); case Constants.EXCEPTION_ACCOUNT_NOT_FOUND: throw new NextcloudFilesAppAccountNotFoundException(); return new NextcloudFilesAppAccountNotFoundException(); case Constants.EXCEPTION_UNSUPPORTED_METHOD: throw new NextcloudUnsupportedMethodException(); return new NextcloudUnsupportedMethodException(); case Constants.EXCEPTION_INVALID_REQUEST_URL: throw new NextcloudInvalidRequestUrlException(exception.getCause().getMessage()); return new NextcloudInvalidRequestUrlException(exception.getCause().getMessage()); case Constants.EXCEPTION_HTTP_REQUEST_FAILED: int statusCode = Integer.parseInt(exception.getCause().getMessage()); throw new NextcloudHttpRequestFailedException(statusCode); return new NextcloudHttpRequestFailedException(statusCode); case Constants.EXCEPTION_ACCOUNT_ACCESS_DECLINED: throw new NextcloudFilesAppAccountPermissionNotGrantedException(); return new NextcloudFilesAppAccountPermissionNotGrantedException(); default: throw exception; return new UnknownErrorException(exception.getMessage()); } } }
src/main/java/com/nextcloud/android/sso/exceptions/UnknownErrorException.java 0 → 100644 +22 −0 Original line number Diff line number Diff line package com.nextcloud.android.sso.exceptions; import android.content.Context; import com.nextcloud.android.sso.model.ExceptionMessage; public class UnknownErrorException extends SSOException { public UnknownErrorException() { super(); } public UnknownErrorException(String message) { super(); this.em = new ExceptionMessage("", message); } @Override public void loadExceptionMessage(Context context) { } }