Search in sources :

Example 1 with MicrosoftTokenErrorResponse

use of com.microsoft.identity.common.internal.providers.microsoft.MicrosoftTokenErrorResponse in project microsoft-authentication-library-common-for-android by AzureAD.

the class MockServerResponse method getMockTokenFailureInvalidScopeResponse.

public static HttpResponse getMockTokenFailureInvalidScopeResponse() {
    final MicrosoftTokenErrorResponse tokenErrorResponse = new MicrosoftTokenErrorResponse();
    tokenErrorResponse.setError("invalid_scope");
    tokenErrorResponse.setErrorDescription("AADSTS70000: Provided scope 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("bad_token");
    final String mockResponse = ObjectMapper.serializeObjectToJsonString(tokenErrorResponse);
    final HttpResponse response = new HttpResponse(400, mockResponse, new HashMap<String, List<String>>());
    return response;
}
Also used : MicrosoftTokenErrorResponse(com.microsoft.identity.common.internal.providers.microsoft.MicrosoftTokenErrorResponse) HttpResponse(com.microsoft.identity.common.internal.net.HttpResponse) List(java.util.List) ArrayList(java.util.ArrayList)

Example 2 with MicrosoftTokenErrorResponse

use of com.microsoft.identity.common.internal.providers.microsoft.MicrosoftTokenErrorResponse in project microsoft-authentication-library-common-for-android by AzureAD.

the class MockServerResponse method getMockTokenFailureProtectionPolicyRequiredResponse.

public static HttpResponse getMockTokenFailureProtectionPolicyRequiredResponse() {
    final MicrosoftTokenErrorResponse tokenErrorResponse = new MicrosoftTokenErrorResponse();
    tokenErrorResponse.setError("unauthorized_client");
    tokenErrorResponse.setErrorDescription("AADSTS53005: Application needs to enforce Intune protection policies");
    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("protection_policy_required");
    final String mockResponse = ObjectMapper.serializeObjectToJsonString(tokenErrorResponse);
    final HttpResponse response = new HttpResponse(400, mockResponse, new HashMap<String, List<String>>());
    return response;
}
Also used : MicrosoftTokenErrorResponse(com.microsoft.identity.common.internal.providers.microsoft.MicrosoftTokenErrorResponse) HttpResponse(com.microsoft.identity.common.internal.net.HttpResponse) List(java.util.List) ArrayList(java.util.ArrayList)

Example 3 with MicrosoftTokenErrorResponse

use of com.microsoft.identity.common.internal.providers.microsoft.MicrosoftTokenErrorResponse in project microsoft-authentication-library-common-for-android by AzureAD.

the class MockServerResponse method getMockTokenFailureServiceUnavailable.

public static HttpResponse getMockTokenFailureServiceUnavailable() {
    final MicrosoftTokenErrorResponse tokenErrorResponse = new MicrosoftTokenErrorResponse();
    tokenErrorResponse.setError("service_unavailable");
    tokenErrorResponse.setErrorDescription("AADSTS70000: Service is unavailable");
    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("bad_token");
    final String mockResponse = ObjectMapper.serializeObjectToJsonString(tokenErrorResponse);
    final HttpResponse response = new HttpResponse(503, mockResponse, new HashMap<String, List<String>>());
    return response;
}
Also used : MicrosoftTokenErrorResponse(com.microsoft.identity.common.internal.providers.microsoft.MicrosoftTokenErrorResponse) HttpResponse(com.microsoft.identity.common.internal.net.HttpResponse) List(java.util.List) ArrayList(java.util.ArrayList)

Example 4 with MicrosoftTokenErrorResponse

use of com.microsoft.identity.common.internal.providers.microsoft.MicrosoftTokenErrorResponse 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;
}
Also used : MicrosoftTokenErrorResponse(com.microsoft.identity.common.internal.providers.microsoft.MicrosoftTokenErrorResponse) HttpResponse(com.microsoft.identity.common.internal.net.HttpResponse) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

HttpResponse (com.microsoft.identity.common.internal.net.HttpResponse)4 MicrosoftTokenErrorResponse (com.microsoft.identity.common.internal.providers.microsoft.MicrosoftTokenErrorResponse)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4