Pab*_*gas 5 javafx javafx-2 javafx-webengine
我正在开发一个JavaFX应用程序,我正在尝试使用WebView访问Web应用程序.此Web应用程序具有基本身份验证,我想以编程方式提交凭据(不想提示用户提供凭据,它们存储在JavaFX应用程序中,我知道此方法的安全隐患).
我在谷歌找到的唯一链接是:
https://community.oracle.com/message/12518017
还没有答案.
我们实际上正在尝试使用该方法Authenticator并且它有效。
URI baseUri = URI.create("https://my.company.com/");
String username = "";
String password = "";
Authenticator.setDefault(new Authenticator() {
@Override
public PasswordAuthentication getPasswordAuthentication() {
// only return our credentials for our URI
if (baseUri.getHost().equals(getRequestingHost())) {
return new PasswordAuthentication(username, password.toCharArray());
}
return null;
}
});
Run Code Online (Sandbox Code Playgroud)