use of com.microsoft.identity.common.internal.providers.oauth2.AuthorizationResult in project microsoft-authentication-library-common-for-android by AzureAD.
the class EmbeddedWebViewAuthorizationStrategy method completeAuthorization.
@Override
public void completeAuthorization(int requestCode, int resultCode, Intent data) {
if (requestCode == AuthenticationConstants.UIRequest.BROWSER_FLOW) {
if (mOAuth2Strategy != null && mAuthorizationResultFuture != null) {
// Suppressing unchecked warnings due to method createAuthorizationResult being a member of the raw type AuthorizationResultFactory
@SuppressWarnings(WarningType.unchecked_warning) final AuthorizationResult result = mOAuth2Strategy.getAuthorizationResultFactory().createAuthorizationResult(resultCode, data, mAuthorizationRequest);
mAuthorizationResultFuture.setResult(result);
} else {
Logger.warn(TAG, "SDK Cancel triggering before request is sent out. " + "Potentially due to an stale activity state, " + "oAuth2Strategy null ? [" + (mOAuth2Strategy == null) + "]" + "mAuthorizationResultFuture ? [" + (mAuthorizationResultFuture == null) + "]");
}
} else {
Logger.warnPII(TAG, "Unknown request code " + requestCode);
}
}
use of com.microsoft.identity.common.internal.providers.oauth2.AuthorizationResult in project microsoft-authentication-library-common-for-android by AzureAD.
the class MicrosoftStsAuthorizationResultFactoryTest method testNoMatchingResultCode.
@Test
public void testNoMatchingResultCode() {
Intent intent = new Intent();
AuthorizationResult result = mAuthorizationResultFactory.createAuthorizationResult(0, intent, getMstsAuthorizationRequest());
assertNotNull(result);
assertNull(result.getAuthorizationResponse());
assertEquals(AuthorizationStatus.FAIL, result.getAuthorizationStatus());
AuthorizationErrorResponse errorResponse = result.getAuthorizationErrorResponse();
assertNotNull(errorResponse);
assertEquals(MicrosoftAuthorizationErrorResponse.UNKNOWN_ERROR, errorResponse.getError());
assertEquals(MicrosoftAuthorizationErrorResponse.UNKNOWN_RESULT_CODE, errorResponse.getErrorDescription());
}
use of com.microsoft.identity.common.internal.providers.oauth2.AuthorizationResult in project microsoft-authentication-library-common-for-android by AzureAD.
the class MicrosoftStsAuthorizationResultFactoryTest method testBrowserCodeError.
@Test
public void testBrowserCodeError() {
Intent intent = new Intent();
AuthorizationResult result = mAuthorizationResultFactory.createAuthorizationResult(AuthenticationConstants.UIResponse.BROWSER_CODE_ERROR, intent, getMstsAuthorizationRequest());
assertNotNull(result);
assertNull(result.getAuthorizationResponse());
assertEquals(AuthorizationStatus.FAIL, result.getAuthorizationStatus());
assertNotNull(result.getAuthorizationErrorResponse());
}
use of com.microsoft.identity.common.internal.providers.oauth2.AuthorizationResult in project microsoft-authentication-library-common-for-android by AzureAD.
the class MicrosoftStsAuthorizationResultFactoryTest method testUrlWithEmptyParams.
@Test
public void testUrlWithEmptyParams() {
Intent intent = new Intent();
intent.putExtra(AUTHORIZATION_FINAL_URL, REDIRECT_URI);
AuthorizationResult result = mAuthorizationResultFactory.createAuthorizationResult(AuthenticationConstants.UIResponse.BROWSER_CODE_COMPLETE, intent, getMstsAuthorizationRequest());
assertNotNull(result);
assertNull(result.getAuthorizationResponse());
assertEquals(AuthorizationStatus.FAIL, result.getAuthorizationStatus());
AuthorizationErrorResponse errorResponse = result.getAuthorizationErrorResponse();
assertNotNull(errorResponse);
assertEquals(MicrosoftAuthorizationErrorResponse.AUTHORIZATION_FAILED, errorResponse.getError());
assertEquals(MicrosoftAuthorizationErrorResponse.AUTHORIZATION_SERVER_INVALID_RESPONSE, errorResponse.getErrorDescription());
}
use of com.microsoft.identity.common.internal.providers.oauth2.AuthorizationResult in project microsoft-authentication-library-common-for-android by AzureAD.
the class MicrosoftStsAuthorizationResultFactoryTest method testUrlWithInvalidAuthCodeAndFragmentParas.
@Test
public void testUrlWithInvalidAuthCodeAndFragmentParas() {
Intent intent = new Intent();
intent.putExtra(AUTHORIZATION_FINAL_URL, REDIRECT_URI + "?" + FRAGMENT_STRING);
AuthorizationResult result = mAuthorizationResultFactory.createAuthorizationResult(AuthenticationConstants.UIResponse.BROWSER_CODE_COMPLETE, intent, getMstsAuthorizationRequest());
assertNotNull(result);
assertNotNull(result.getAuthorizationErrorResponse());
assertEquals(AuthorizationStatus.FAIL, result.getAuthorizationStatus());
AuthorizationErrorResponse errorResponse = result.getAuthorizationErrorResponse();
assertEquals(errorResponse.getError(), MicrosoftAuthorizationErrorResponse.AUTHORIZATION_FAILED);
assertEquals(errorResponse.getErrorDescription(), MicrosoftAuthorizationErrorResponse.AUTHORIZATION_SERVER_INVALID_RESPONSE);
}
Aggregations