简体   繁体   English

本地主机上的Java登录/注销

[英]java login/logout on localhost

This is for a desktop application that uses jdbc:mysql://localhost/ database. 这适用于使用jdbc:mysql://localhost/数据库的桌面应用程序。
Long story short, this is what i`m trying to do: 长话短说,这就是我想要做的:


  1. Ask for credentials ( Username/Password ). 要求提供凭据( 用户名/密码 )。
  2. Compare with MySQL database for match ( true/false ). MySQL数据库比较是否匹配( true / false )。
  3. If true → load the workspace, which implements data from MySQL . 如果为true,请加载工作区,该工作区实现来自MySQL的数据。
  4. If false → keep asking for valid credentials. 如果为 →继续要求提供有效的凭据。

As of now, i`m thinking of using CardLayout approach. 到目前为止,我正在考虑使用CardLayout方法。
The schema is simple: 模式很简单:

  1. If true → switch to workspace_card . 如果为true →切换到workspace_card
    • Set MySQL table field ( user_status ) to 1 (meaning online ). MySQL表字段( user_status )设置为1 (表示online )。
  2. Logout → switch to login_card . 注销 →切换到login_card
    • Set MySQL table field ( user_status ) to 0 (meaning offline ). MySQL表字段( user_status )设置为0 (表示offline )。

So, my question is: 所以,我的问题是:

  • May CardLayout be considered a good approach when it comes to low level security type of applications? 如果涉及低级别的应用程序安全性 ,是否可以将CardLayout视为一种好方法?
  • What is the most accurate schema/method to use in JavaWorld to achieve the above tasks/results ? JavaWorld中用于实现上述任务/结果的最准确的架构/方法是什么?

I guess stoting user online/offline status in database and manahe it through some application in very bad approach. 我想在数据库中存储用户的联机/脱机状态,并以非常糟糕的方式通过某些应用程序来处理它。 In some cases, such of application/database process shutdown, force shutdown and others, your logout logic may not be executed, and user_status will be left as online. 在某些情况下,例如应用程序/数据库进程关闭,强制关闭等,您的注销逻辑可能不会执行,并且user_status将保持联机状态。

In typical java web application we usually use some web session (which one storing the credentials) and some JDBC pool (like bonecp or c3p0 ). 在典型的Java Web应用程序中,我们通常使用一些Web会话(其中一个存储凭据)和一些JDBC池(例如bonecpc3p0 )。 You have desktop application, so you may use some JDBC pool and you need to make some kind of session to storing user status/credentials 您拥有桌面应用程序,因此您可能会使用一些JDBC池,并且需要进行某种类型的会话来存储用户状态/凭证

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM