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());
}
}
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);
}
}
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();
}
Aggregations