Source:
private static UserInfo parseIdToken(String idtoken) { UserInfo userinfo = null; if (StringExtensions.IsNullOrBlank(idtoken)) { Logger.v(TAG, "IdToken is not provided"); } try { int firstDot = idtoken.indexOf("."); int secondDot = idtoken.indexOf(".", firstDot + 1); int invalidDot = idtoken.indexOf(".", secondDot + 1); if (invalidDot == -1 && firstDot > 0 && secondDot > 0) { String idbody = idtoken.substring(firstDot + 1, secondDot); byte[] data = Base64.decode(idbody, Base64.URL_SAFE); String decodedBody = new String(data, "UTF-8"); HashMap<String, String> responseItems = new HashMap<String, String>(); extractJsonObjects(responseItems, decodedBody); if (responseItems != null && !responseItems.isEmpty()) { IdToken idtokenInfo = new IdToken(); idtokenInfo.mSubject = responseItems .get(AuthenticationConstants.OAuth2.ID_TOKEN_SUBJECT); idtokenInfo.mTenantId = responseItems .get(AuthenticationConstants.OAuth2.ID_TOKEN_TENANTID); idtokenInfo.mUpn = responseItems .get(AuthenticationConstants.OAuth2.ID_TOKEN_UPN); idtokenInfo.mEmail = responseItems .get(AuthenticationConstants.OAuth2.ID_TOKEN_EMAIL); idtokenInfo.mGivenName = responseItems .get(AuthenticationConstants.OAuth2.ID_TOKEN_GIVEN_NAME); idtokenInfo.mFamilyName = responseItems .get(AuthenticationConstants.OAuth2.ID_TOKEN_FAMILY_NAME); idtokenInfo.mIdentityProvider = responseItems .get(AuthenticationConstants.OAuth2.ID_TOKEN_IDENTITY_PROVIDER); userinfo = new UserInfo(idtokenInfo); Logger.v( TAG, "IdToken is extracted from token response for userid:" + userinfo.getUserId()); } } } catch (Exception ex) { Logger.e(TAG, "Error in parsing user id token", null, ADALError.IDTOKEN_PARSING_FAILURE, ex); } return userinfo; }

Target:
private static UserInfo parseIdToken(String idtoken) { UserInfo userinfo = null; try { int firstDot = idtoken.indexOf("."); int secondDot = idtoken.indexOf(".", firstDot + 1); int invalidDot = idtoken.indexOf(".", secondDot + 1); if (invalidDot == -1 && firstDot > 0 && secondDot > 0) { String idbody = idtoken.substring(firstDot + 1, secondDot); byte[] data = Base64.decode(idbody, Base64.URL_SAFE); String decodedBody = new String(data, "UTF-8"); HashMap<String, String> responseItems = new HashMap<String, String>(); extractJsonObjects(responseItems, decodedBody); if (responseItems != null && !responseItems.isEmpty()) { IdToken idtokenInfo = new IdToken(); idtokenInfo.mSubject = responseItems .get(AuthenticationConstants.OAuth2.ID_TOKEN_SUBJECT); idtokenInfo.mTenantId = responseItems .get(AuthenticationConstants.OAuth2.ID_TOKEN_TENANTID); idtokenInfo.mUpn = responseItems .get(AuthenticationConstants.OAuth2.ID_TOKEN_UPN); idtokenInfo.mEmail = responseItems .get(AuthenticationConstants.OAuth2.ID_TOKEN_EMAIL); idtokenInfo.mGivenName = responseItems .get(AuthenticationConstants.OAuth2.ID_TOKEN_GIVEN_NAME); idtokenInfo.mFamilyName = responseItems .get(AuthenticationConstants.OAuth2.ID_TOKEN_FAMILY_NAME); idtokenInfo.mIdentityProvider = responseItems .get(AuthenticationConstants.OAuth2.ID_TOKEN_IDENTITY_PROVIDER); userinfo = new UserInfo(idtokenInfo); Logger.v( TAG, "IdToken is extracted from token response for userid:" + userinfo.getUserId()); } } } catch (Exception ex) { Logger.e(TAG, "Error in parsing user id token", null, ADALError.IDTOKEN_PARSING_FAILURE, ex); } return userinfo; }