gpt4 book ai didi

java - 绕过登录屏幕

转载 作者:行者123 更新时间:2023-12-01 14:17:54 26 4
gpt4 key购买 nike

在我们的rcp应用程序中,我们使用eclipse框架实现了登录功能(Splash屏幕上的登录功能)。

现在我们如何通过提供虚拟机参数来绕过此登录(包括启动屏幕)?

如果为虚拟机参数提供了正确的用户名和密码,我们不想显示登录页面(这包括启动屏幕,因为登录功能位于启动屏幕本身)

有什么想法吗?

最佳答案

不确定是否可以跳过启动屏幕(而且,没有看到这样做的任何充分理由),但如果您想将登录对话框与启动屏幕分开,则可以跳过显示登录对话框。

在应用程序启动时创建对话框,就像这样:

Application implements IApplication {

@Override
public Object start(IApplicationContext context) throws Exception {
Display display = PlatformUI.createDisplay();
try {

LoginDialog dialog = new LoginDialog(display.getActiveShell());
if (dialog.open() == Dialog.CANCEL) {
return EXIT_OK;
}

int code = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());

// Exit the application with an appropriate return code.
return code == PlatformUI.RETURN_RESTART ? EXIT_RESTART : EXIT_OK;

} finally {

if (display != null) {
display.dispose();
}
}
}

然后,您可以通过检查所需的系统属性并使用属性值对用户进行身份验证来跳过显示对话框:

    String username = System.getProperty("username");
String pwd = System.getProperty("password");
if (username != null && pwd != null) {
// do something with username and password
} else {
LoginDialog dialog = new LoginDialog(display.getActiveShell());
if (dialog.open() == Dialog.CANCEL) {
return EXIT_OK;
}
}

此外,Platform.endSplash();可能会有所帮助。

关于java - 绕过登录屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17938693/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com