Source:
private AuthenticationResult getResultFromBrokerResponse(Bundle bundleResult) { if (bundleResult == null) { throw new IllegalArgumentException("bundleResult"); } int errCode = bundleResult.getInt(AccountManager.KEY_ERROR_CODE); String msg = bundleResult.getString(AccountManager.KEY_ERROR_MESSAGE); if (!StringExtensions.IsNullOrBlank(msg)) { ADALError adalErrorCode = ADALError.BROKER_AUTHENTICATOR_ERROR_GETAUTHTOKEN; switch (errCode) { case AccountManager.ERROR_CODE_BAD_ARGUMENTS: adalErrorCode = ADALError.BROKER_AUTHENTICATOR_BAD_ARGUMENTS; break; case ACCOUNT_MANAGER_ERROR_CODE_BAD_AUTHENTICATION: adalErrorCode = ADALError.BROKER_AUTHENTICATOR_BAD_AUTHENTICATION; break; case AccountManager.ERROR_CODE_UNSUPPORTED_OPERATION: adalErrorCode = ADALError.BROKER_AUTHENTICATOR_UNSUPPORTED_OPERATION; break; } throw new AuthenticationException(adalErrorCode, msg); } else { boolean initialRequest = bundleResult .getBoolean(AuthenticationConstants.Broker.ACCOUNT_INITIAL_REQUEST); if (initialRequest) { return AuthenticationResult.createResultForInitialRequest(); } UserInfo userinfo = UserInfo.getUserInfoFromBrokerResult(bundleResult); final String tenantId = bundleResult.getString(AuthenticationConstants.Broker.ACCOUNT_USERINFO_TENANTID, ""); final Date expires = new Date(bundleResult.getLong(AuthenticationConstants.Broker.ACCOUNT_EXPIREDATE)); AuthenticationResult result = new AuthenticationResult( bundleResult.getString(AccountManager.KEY_AUTHTOKEN), "", expires, false, userinfo, tenantId, ""); return result; } }

Target:
private AuthenticationResult getResultFromBrokerResponse(Bundle bundleResult) { if (bundleResult == null) { throw new IllegalArgumentException("bundleResult"); } int errCode = bundleResult.getInt(AccountManager.KEY_ERROR_CODE); String msg = bundleResult.getString(AccountManager.KEY_ERROR_MESSAGE); if (!StringExtensions.IsNullOrBlank(msg)) { ADALError adalErrorCode = ADALError.BROKER_AUTHENTICATOR_ERROR_GETAUTHTOKEN; switch (errCode) { case AccountManager.ERROR_CODE_BAD_ARGUMENTS: adalErrorCode = ADALError.BROKER_AUTHENTICATOR_BAD_ARGUMENTS; break; case ACCOUNT_MANAGER_ERROR_CODE_BAD_AUTHENTICATION: adalErrorCode = ADALError.BROKER_AUTHENTICATOR_BAD_AUTHENTICATION; break; case AccountManager.ERROR_CODE_UNSUPPORTED_OPERATION: adalErrorCode = ADALError.BROKER_AUTHENTICATOR_UNSUPPORTED_OPERATION; break; } throw new AuthenticationException(adalErrorCode, msg); } else { boolean initialRequest = bundleResult .getBoolean(AuthenticationConstants.Broker.ACCOUNT_INITIAL_REQUEST); if (initialRequest) { return AuthenticationResult.createResultForInitialRequest(); } UserInfo userinfo = UserInfo.getUserInfoFromBrokerResult(bundleResult); final String tenantId = bundleResult.getString(AuthenticationConstants.Broker.ACCOUNT_USERINFO_TENANTID, ""); final Date expires; if (bundleResult.getLong(AuthenticationConstants.Broker.ACCOUNT_EXPIREDATE) == 0) { Logger.v(TAG, "Broker doesn't return expire date, set it current date plus one hour"); final Calendar currentTime = new GregorianCalendar(); currentTime.add(Calendar.SECOND, AuthenticationConstants.DEFAULT_EXPIRATION_TIME_SEC);; expires = currentTime.getTime(); } else { expires = new Date(bundleResult.getLong(AuthenticationConstants.Broker.ACCOUNT_EXPIREDATE)); } AuthenticationResult result = new AuthenticationResult( bundleResult.getString(AccountManager.KEY_AUTHTOKEN), "", expires, false, userinfo, tenantId, ""); return result; } }