use of com.microsoft.identity.common.internal.net.HttpResponse in project microsoft-authentication-library-common-for-android by AzureAD.
the class MockServerResponse method getMockTokenFailureInvalidGrantResponse.
public static HttpResponse getMockTokenFailureInvalidGrantResponse() {
final MicrosoftTokenErrorResponse tokenErrorResponse = new MicrosoftTokenErrorResponse();
tokenErrorResponse.setError("invalid_grant");
tokenErrorResponse.setErrorDescription("AADSTS70000: Provided grant is invalid or malformed");
tokenErrorResponse.setErrorCodes(new ArrayList<Long>(Arrays.asList(70000L)));
tokenErrorResponse.setTimeStamp("2019-10-23 21:05:16Z");
tokenErrorResponse.setTraceId("8497799a-e9f9-402f-a951-7060b5014600");
tokenErrorResponse.setCorrelationId("390d7507-c607-4f05-bb8a-51a2a7a6282b");
tokenErrorResponse.setErrorUri("https://login.microsoftonline.com/error?code=70000");
tokenErrorResponse.setSubError("");
final String mockResponse = ObjectMapper.serializeObjectToJsonString(tokenErrorResponse);
final HttpResponse response = new HttpResponse(400, mockResponse, new HashMap<String, List<String>>());
return response;
}
use of com.microsoft.identity.common.internal.net.HttpResponse in project microsoft-authentication-library-common-for-android by AzureAD.
the class MockServerResponse method getMockTokenSuccessResponse.
public static HttpResponse getMockTokenSuccessResponse() {
final MicrosoftTokenResponse mockTokenResponse = new MicrosoftTokenResponse();
mockTokenResponse.setTokenType("Bearer");
mockTokenResponse.setScope("User.Read");
mockTokenResponse.setExpiresIn(defaultTokenExpiryInSec);
mockTokenResponse.setExtExpiresIn(defaultTokenExpiryInSec);
mockTokenResponse.setAccessToken("b06d0810-12ff-4a4e-850b-4bda1540d895");
mockTokenResponse.setRefreshToken("6b80f5b5-d53c-4c46-992d-66c5dcd4cfb1");
mockTokenResponse.setIdToken(MockTokenCreator.createMockIdToken());
mockTokenResponse.setClientInfo(MockTokenCreator.createMockRawClientInfo());
final String mockResponse = ObjectMapper.serializeObjectToJsonString(mockTokenResponse);
return new HttpResponse(200, mockResponse, new HashMap<>());
}
use of com.microsoft.identity.common.internal.net.HttpResponse in project microsoft-authentication-library-common-for-android by AzureAD.
the class MockDelayedResponseStrategy method makeHttpResponseFromResponseObject.
public HttpResponse makeHttpResponseFromResponseObject(final Object obj) {
final String httpResponseBody = ObjectMapper.serializeObjectToJsonString(obj);
final HashMap<String, List<String>> responseHeaders = new HashMap<>();
responseHeaders.put(AuthenticationConstants.HeaderField.X_MS_CLITELEM, new ArrayList<>(Collections.singleton("1,0,0,,")));
final HttpResponse httpResponse = new HttpResponse(200, httpResponseBody, responseHeaders);
return httpResponse;
}
use of com.microsoft.identity.common.internal.net.HttpResponse in project microsoft-authentication-library-common-for-android by AzureAD.
the class MockDelayedResponseStrategy method performTokenRequest.
@Override
protected HttpResponse performTokenRequest(final MicrosoftStsTokenRequest tokenRequest) {
final TokenResult tokenResult = getTokenResult();
final TokenResponse tokenResponse = tokenResult.getTokenResponse();
try {
Thread.sleep(RESPONSE_DELAY);
} catch (InterruptedException e) {
e.printStackTrace();
}
final HttpResponse httpResponse = makeHttpResponseFromResponseObject(tokenResponse);
return httpResponse;
}
Aggregations