if (settings.getUsername() != null && settings.getPassword() != null) {
xmlHttpRequest.open(httpMethod, url, settings.getUsername(), settings.getPassword());
} else if (settings.getUsername() != null) {
xmlHttpRequest.open(httpMethod, url, settings.getUsername());
} else {
xmlHttpRequest.open(httpMethod, url);
}
} catch (JavaScriptException e) {
RequestPermissionException requestPermissionException = new RequestPermissionException(url);
requestPermissionException.initCause(new RequestException(e.getMessage()));
onError(null, e);