简体   繁体   中英

Login architechture for a local java desktop application

Hi,
I am trying to write my first simple local desktop application with login capabilities. There should be support for different types of users with different access rights. I have managed to come up with something that works in a simple version of the program, however, it feels flawed on several levels. I simply don't know if I am on the right track with the structure of the entire application. I am also very uncertain about security.

Here is my current implementation (only the login specific classes/methods) : 登录架构上的 UML 图

Question:
Does anyone have recommendations for how to implement this kind of system? Or is there somewhere I can learn more about how to structure an application in a way that makes sense? I have been learning a lot of design patterns and OOB principals, but I have a hard time applying them in a real application.

NB: If context matters, the application is a fictional computer store that lets administrators add different types of computer components to an inventory. Customers can search and filter through these parts and create their own configuration. Customers can then order that configuration.

What's the point of the password feature? If it runs on a machine that is under the control of some user and not under yours, they will have access. There's nothing you can do about this.

Generally, for apps that run entirely locally, piggyback on the OS itself; store the data in the user's home dir and make sure the file's access rights are such that other (non-admin) users can't read it. Other admin users? Well, they are admin users. If they wanna read it, they can, that's sort of the point of such users. You can't stop them from doing this. If you store the relevant data per user in a file that only they can read, there's no need for a username/password prompt at all; their 'login' is their local username, and their 'authentication' is inherent. Simple.

The one time where a user/pass setup MIGHT make sense is if the app is started by an administrator and is started in a locked down mode, where the one operating the keyboard and mouse cannot get at the case of the system and cannot close the app at all. That's for example how an ATM works: Those are just windows machines, where the 'keyboard' is just a numpad, and the mouse and the computer system itself are locked away in a bunch of brick and metal. If you do this, make sure you apply proper password hygiene; don't store it, store its bcrypt/pbkdf/argon2/scrypt hash instead. That way if someone gets at that file, your app is hosed but at least if that user re-used their passwords on other sites (which users do, in spades), the hack won't expose that too.

I assume you don't have that, which brings us back to: What are you attempting to accomplish with the password?

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