Search in sources :

Example 6 with BrokerCommunicationException

use of com.microsoft.identity.common.exception.BrokerCommunicationException in project microsoft-authentication-library-common-for-android by AzureAD.

the class IpcStrategyTests method testOperationNotSupportedOnClientSide.

protected void testOperationNotSupportedOnClientSide(@NonNull final BrokerOperationBundle bundle) {
    final IIpcStrategy strategy = getStrategy();
    try {
        strategy.communicateToBroker(bundle);
        Assert.fail("Operation should fail.");
    } catch (BaseException e) {
        Assert.assertTrue(e instanceof BrokerCommunicationException);
        Assert.assertSame(((BrokerCommunicationException) e).getCategory(), OPERATION_NOT_SUPPORTED_ON_CLIENT_SIDE);
        Assert.assertSame(((BrokerCommunicationException) e).getStrategyType(), strategy.getType());
    }
}
Also used : BaseException(com.microsoft.identity.common.exception.BaseException) IIpcStrategy(com.microsoft.identity.common.internal.broker.ipc.IIpcStrategy) BrokerCommunicationException(com.microsoft.identity.common.exception.BrokerCommunicationException)

Example 7 with BrokerCommunicationException

use of com.microsoft.identity.common.exception.BrokerCommunicationException in project microsoft-authentication-library-common-for-android by AzureAD.

the class AccountManagerAddAccountStrategy method communicateToBroker.

@Override
@Nullable
public Bundle communicateToBroker(@NonNull final BrokerOperationBundle brokerOperationBundle) throws BrokerCommunicationException {
    final String methodName = brokerOperationBundle.getOperation().name();
    try {
        final AccountManagerFuture<Bundle> resultBundle = AccountManager.get(mContext).addAccount(AuthenticationConstants.Broker.BROKER_ACCOUNT_TYPE, AuthenticationConstants.Broker.AUTHTOKEN_TYPE, null, brokerOperationBundle.getAccountManagerBundle(), null, null, ProcessUtil.getPreferredHandler());
        Logger.verbose(TAG + methodName, "Received result from broker");
        return resultBundle.getResult();
    } catch (final AuthenticatorException | IOException | OperationCanceledException e) {
        Logger.error(TAG + methodName, e.getMessage(), e);
        throw new BrokerCommunicationException(CONNECTION_ERROR, getType(), "Failed to connect to AccountManager", e);
    }
}
Also used : Bundle(android.os.Bundle) OperationCanceledException(android.accounts.OperationCanceledException) AuthenticatorException(android.accounts.AuthenticatorException) IOException(java.io.IOException) BrokerCommunicationException(com.microsoft.identity.common.exception.BrokerCommunicationException) Nullable(androidx.annotation.Nullable)

Example 8 with BrokerCommunicationException

use of com.microsoft.identity.common.exception.BrokerCommunicationException in project microsoft-authentication-library-common-for-android by AzureAD.

the class BrokerOperationBundle method getContentProviderPath.

public String getContentProviderPath() throws BrokerCommunicationException {
    final String methodName = ":getContentProviderUriPath";
    final API contentApi = operation.getContentApi();
    if (contentApi == null) {
        final String errorMessage = "Operation " + operation.name() + " is not supported by ContentProvider.";
        Logger.warn(TAG + methodName, errorMessage);
        throw new BrokerCommunicationException(OPERATION_NOT_SUPPORTED_ON_CLIENT_SIDE, CONTENT_PROVIDER, errorMessage, null);
    }
    return contentApi.getPath();
}
Also used : API(com.microsoft.identity.common.adal.internal.AuthenticationConstants.BrokerContentProvider.API) BrokerCommunicationException(com.microsoft.identity.common.exception.BrokerCommunicationException)

Aggregations

BrokerCommunicationException (com.microsoft.identity.common.exception.BrokerCommunicationException)8 Bundle (android.os.Bundle)3 Nullable (androidx.annotation.Nullable)3 BaseException (com.microsoft.identity.common.exception.BaseException)3 IIpcStrategy (com.microsoft.identity.common.internal.broker.ipc.IIpcStrategy)3 AuthenticatorException (android.accounts.AuthenticatorException)1 OperationCanceledException (android.accounts.OperationCanceledException)1 Intent (android.content.Intent)1 Cursor (android.database.Cursor)1 Uri (android.net.Uri)1 IBinder (android.os.IBinder)1 NonNull (androidx.annotation.NonNull)1 API (com.microsoft.identity.common.adal.internal.AuthenticationConstants.BrokerContentProvider.API)1 ClientException (com.microsoft.identity.common.exception.ClientException)1 BrokerOperationBundle (com.microsoft.identity.common.internal.broker.ipc.BrokerOperationBundle)1 ResultFuture (com.microsoft.identity.common.internal.result.ResultFuture)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1