简体   繁体   中英

java login/logout on localhost

This is for a desktop application that uses jdbc:mysql://localhost/ database.
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 ).
  3. If true → load the workspace, which implements data from MySQL .
  4. If false → keep asking for valid credentials.

As of now, i`m thinking of using CardLayout approach.
The schema is simple:

  1. If true → switch to workspace_card .
    • Set MySQL table field ( user_status ) to 1 (meaning online ).
  2. Logout → switch to login_card .
    • Set MySQL table field ( user_status ) to 0 (meaning offline ).

So, my question is:

  • May CardLayout be considered a good approach when it comes to low level security type of applications?
  • What is the most accurate schema/method to use in JavaWorld to achieve the above tasks/results ?

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.

In typical java web application we usually use some web session (which one storing the credentials) and some JDBC pool (like bonecp or c3p0 ). 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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