use of com.microsoft.identity.common.internal.result.ResultFuture in project microsoft-authentication-library-common-for-android by AzureAD.
the class MockStrategyWithMockedHttpResponse method requestAuthorization.
/**
* Template method for executing an OAuth2 authorization request.
*
* @param request microsoft sts authorization request.
* @param authorizationStrategy authorization strategy.
* @return GenericAuthorizationResponse
*/
@Override
public Future<AuthorizationResult> requestAuthorization(final MicrosoftStsAuthorizationRequest request, final AuthorizationStrategy authorizationStrategy) {
final MockSuccessAuthorizationResultMockedTests authorizationResult = new MockSuccessAuthorizationResultMockedTests();
final ResultFuture<AuthorizationResult> future = new ResultFuture<>();
future.setResult(authorizationResult);
return future;
}
use of com.microsoft.identity.common.internal.result.ResultFuture in project microsoft-authentication-library-common-for-android by AzureAD.
the class ResourceOwnerPasswordCredentialsTestStrategy method requestAuthorization.
/**
* Template method for executing an OAuth2 authorization request.
*
* @param request microsoft sts authorization request.
* @param authorizationStrategy authorization strategy.
* @return GenericAuthorizationResponse
*/
@Override
public Future<AuthorizationResult> requestAuthorization(final MicrosoftStsAuthorizationRequest request, final AuthorizationStrategy authorizationStrategy) {
final MockSuccessAuthorizationResultNetworkTests authorizationResult = new MockSuccessAuthorizationResultNetworkTests();
final ResultFuture<AuthorizationResult> future = new ResultFuture<>();
future.setResult(authorizationResult);
return future;
}
use of com.microsoft.identity.common.internal.result.ResultFuture in project microsoft-authentication-library-common-for-android by AzureAD.
the class BoundServiceClient method connect.
/**
* Binds to the service.
*
* @param targetServicePackageName Package name of the app this client will talk to.
*/
@NonNull
protected T connect(@NonNull final String targetServicePackageName) throws BrokerCommunicationException, InterruptedException, TimeoutException, ExecutionException {
final String methodName = ":connect";
if (!isBoundServiceSupported(targetServicePackageName)) {
final String errorMessage = "Bound service is not supported.";
Logger.info(TAG + methodName, errorMessage);
throw new BrokerCommunicationException(OPERATION_NOT_SUPPORTED_ON_SERVER_SIDE, BOUND_SERVICE, errorMessage, null);
}
final ResultFuture<IBinder> future = new ResultFuture<>();
mConnection = new BoundServiceConnection(future);
mHasStartedBinding = mContext.bindService(getIntentForBoundService(targetServicePackageName), mConnection, Context.BIND_AUTO_CREATE);
if (!mHasStartedBinding) {
final String errorMessage = "failed to bind. The service is not available.";
Logger.info(TAG + methodName, errorMessage);
throw new BrokerCommunicationException(OPERATION_NOT_SUPPORTED_ON_SERVER_SIDE, BOUND_SERVICE, errorMessage, null);
}
Logger.info(TAG + "connect", "Android is establishing the bound service connection.");
final IBinder binder = future.get(mTimeOutInSeconds, TimeUnit.SECONDS);
return getInterfaceFromIBinder(binder);
}
use of com.microsoft.identity.common.internal.result.ResultFuture in project microsoft-authentication-library-common-for-android by AzureAD.
the class MockTestStrategy method requestAuthorization.
/**
* Template method for executing an OAuth2 authorization request.
*
* @param request microsoft sts authorization request.
* @param authorizationStrategy authorization strategy.
* @return GenericAuthorizationResponse
*/
@Override
public Future<AuthorizationResult> requestAuthorization(final MicrosoftStsAuthorizationRequest request, final AuthorizationStrategy authorizationStrategy) {
final MockSuccessAuthorizationResultMockedTests authorizationResult = new MockSuccessAuthorizationResultMockedTests();
final ResultFuture<AuthorizationResult> future = new ResultFuture<>();
future.setResult(authorizationResult);
return future;
}
Aggregations