Source:
private AuthenticationResult processTokenResponse(HttpWebResponse webResponse) { AuthenticationResult result = new AuthenticationResult(); HashMap<String, String> responseItems = new HashMap<String, String>(); String correlationIdInHeader = null; if (webResponse.getResponseHeaders() != null && webResponse.getResponseHeaders().containsKey( AuthenticationConstants.AAD.CLIENT_REQUEST_ID)) { List<String> listOfHeaders = webResponse.getResponseHeaders().get( AuthenticationConstants.AAD.CLIENT_REQUEST_ID); if (listOfHeaders != null && listOfHeaders.size() > 0) { correlationIdInHeader = listOfHeaders.get(0); } } if (webResponse.getBody() != null && webResponse.getBody().length > 0) { try { String jsonStr = new String(webResponse.getBody()); extractJsonObjects(responseItems, jsonStr); result = processUIResponseParams(responseItems); } catch (final Exception ex) { Logger.e(TAG, ex.getMessage(), "", ADALError.SERVER_INVALID_JSON_RESPONSE, ex); result = new AuthenticationResult(JSON_PARSING_ERROR, ex.getMessage()); } } else { String errMessage = null; byte[] message = webResponse.getBody(); if (message != null) { errMessage = new String(message); } else { errMessage = "Status code:" + String.valueOf(webResponse.getStatusCode()); } Logger.v(TAG, "Server error message:" + errMessage); result = new AuthenticationResult(String.valueOf(webResponse.getStatusCode()), errMessage); } if (correlationIdInHeader != null && !correlationIdInHeader.isEmpty()) { try { UUID correlation = UUID.fromString(correlationIdInHeader); if (correlation != mRequest.getCorrelationId()) { Logger.w(TAG, "CorrelationId is not matching", "", ADALError.CORRELATION_ID_NOT_MATCHING_REQUEST_RESPONSE); } Logger.v(TAG, "Response correlationId:" + correlationIdInHeader); } catch (Exception ex) { Logger.e(TAG, "Correlation is not parsed", "", ADALError.CORRELATION_ID_FORMAT, ex); } } return result; }

Target:
private AuthenticationResult processTokenResponse(HttpWebResponse webResponse) { AuthenticationResult result = new AuthenticationResult(); HashMap<String, String> responseItems = new HashMap<String, String>(); String correlationIdInHeader = null; if (webResponse.getResponseHeaders() != null && webResponse.getResponseHeaders().containsKey( AuthenticationConstants.AAD.CLIENT_REQUEST_ID)) { List<String> listOfHeaders = webResponse.getResponseHeaders().get( AuthenticationConstants.AAD.CLIENT_REQUEST_ID); if (listOfHeaders != null && listOfHeaders.size() > 0) { correlationIdInHeader = listOfHeaders.get(0); } } if (webResponse.getBody() != null && webResponse.getBody().length > 0) { try { String jsonStr = new String(webResponse.getBody()); extractJsonObjects(responseItems, jsonStr); result = processUIResponseParams(responseItems); } catch (final Exception ex) { Logger.e(TAG, ex.getMessage(), "", ADALError.SERVER_INVALID_JSON_RESPONSE, ex); result = new AuthenticationResult(JSON_PARSING_ERROR, ex.getMessage()); } } else { String errMessage = null; byte[] message = webResponse.getBody(); if (message != null) { errMessage = new String(message); } else { errMessage = "Status code:" + String.valueOf(webResponse.getStatusCode()); } Logger.v(TAG, "Server error message:" + errMessage); result = new AuthenticationResult(String.valueOf(webResponse.getStatusCode()), errMessage); } if (correlationIdInHeader != null && !correlationIdInHeader.isEmpty()) { try { UUID correlation = UUID.fromString(correlationIdInHeader); if (correlation != mRequest.getCorrelationId()) { Logger.w(TAG, "CorrelationId is not matching", "", ADALError.CORRELATION_ID_NOT_MATCHING_REQUEST_RESPONSE); } Logger.v(TAG, "Response correlationId:" + correlationIdInHeader); } catch (Exception ex) { Logger.e(TAG, "Wrong format of the correlation ID:" + correlationIdInHeader, "", ADALError.CORRELATION_ID_FORMAT, ex); } } return result; }