First of all, beginner here.
Goal:
I would like to access a page of my wiki(xWiki) with basic authentication and Openjdk 8.
Problem:
It doesn't recognize on the first attempt that im already logged in visually. So it doesn't load for example Buttons that are only available logged in
If i refresh the page, it works.
If i switch to another page, it works.
It just doesn't work the first time you open the page.
What i've tryed:
I changed openjdk and openjfx version to 11 and it worked.
Access the Site with firefox browser works.
Adding Webengine state listener but without success(The idea was to wait until it was fully loaded).
Work around:
Call the method twice or reload webengine but that doesn't feel right.
Note:
Using Apache 2.4 and Tomcat 8.5
Using Wireshark shows that bootstrap is not loaded?(not really sure)
Plaintext credentials and http just for test purposes.
Code:
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) {
stage.setTitle("Web View");
Scene scene = new Scene(new Browser(), 1500, 1000, Color.web("#666970"));
stage.setScene(scene);
stage.show();
}
}
class Browser extends Region {
final WebView browser = new WebView();
final WebEngine webEngine = browser.getEngine();
public Browser() {
String login = "foo";
String password = "foo";
String loginPassword = login + ":" + password;
String encoded = Base64.getEncoder().encodeToString(loginPassword.getBytes());
webEngine.setUserAgent(webEngine.getUserAgent().concat("\nAuthorization: Basic " + encoded));
webEngine.load("http://localhost/foo");
getChildren().add(browser);
}
@Override
protected void layoutChildren() {
double w = getWidth();
double h = getHeight();
layoutInArea(browser, 0, 0, w, h, 0, HPos.CENTER, VPos.CENTER);
}
}
Have a look at https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/Authentication/#HBasicAuthentication
Try adding the
basicauth=1query string parameter that signals XWiki to accept your submitted basic authentication header and log you in.