Answer the question
In order to leave comments, you need to log in
Authorization and registration for a desktop application in Java, how best to do it?
I'm doing a chat, I need to do registration and authorization, tell me how to do it, more precisely, which technologies and libraries are better to use.
Answer the question
In order to leave comments, you need to log in
If, in a simple way, and judging by the question, this is exactly the case, then something like that.
To begin with, we delve into what authorization and registration are and what it consists of. It turns out that there is a client and a server.
The client for registration must say the desired login and password. For authorization, you can make it a little more complicated and work according to 2 schemes, The first one is when the client tells the server the login and password. In the second login and token.
*The token here is obtained after authorization, it is generated by the server and reported to the client. It is used for minimal protection, because on the client you can not store the password, but store only the login and token.
The server, in turn, waits for a username and password from clients, after receiving which it checks in its storage (for example, a database) and responds to the client with a status message (ok, login is busy, error, simple password, etc.). Then he waits for authorization from this client in one of two ways, which can be by login and password, then the server will also respond with a message (it will generate a token, the error password \ login is not correct). 2nd option that login and token are expected, the answer will be (ok, the token is not correct error).
The client and the server will naturally communicate over the network, but how you decide is up to you. It can be:
1) Bare sockets, easier to understand. there will no longer be any libraries and in fact the entire protocol will be yours.
2) Use some kind of rest similar system. For example, stupidly taking a server with php and doing something similar (I hope you understand the meaning) to register.php and auth.php. Accordingly, requests from the client will already go stupidly via http
3) Take something more abruptly and an order of magnitude more difficult, for example, netty. Cooler than sockets, but a couple of hundred times more difficult, although you will have to do essentially the same as on sockets.
4) Some kind of network engine, for example kryonet. Here, of course, it’s closer to games, but why not? You will have to read the docks and follow the principles of the library without ever knowing what serialization is and why it is needed.
For practice, then you can complicate the scheme, for example, so that the server no longer just looks at the client's login and token, but also at its ip so that it matches. You can wrap all this with encryption, it will be implemented differently depending on which way you go. Implement also a temporary token of this session or stupidly another parameter from the client like what kind of device, then the client under one login will be able to log in simultaneously from several devices and no one will interfere with anyone.
In more serious projects, the scheme is approximately the same as I described above, but modified a couple of thousand times thicker for any sneeze and occasion.
Specifically for javafx, I don’t see anything in this topic at all, and in general there can be nothing. it's just a library for drawing the interface of the program with collections designed to help make it even more convenient. Similarly, there are also her predecessors awt and swing, which are more complicated but work darker and are lighter in terms of resources.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question