基于RMI的回调注册程序

Registration program based on RMI with callbacks

我必须制作一个具有以下要求的程序:

Build a Client/Server application based on RMI with the following characteristics: The application is structured in 3 different projects: Server, Client, Shared where Shared contains interfaces and classes common to Server and Client. Server and Client are programs, each with its own main, that should also work on different machines.

  1. The Server exports a remote object for the registrations.
  2. The clients register on the server using an appropriate method of the server that takes as parameters name and IP of the client and returns an unique identifier.
  3. The server mantains an updated list of all the registered clients and offers them methods for registration and for accessing in each moment the list.

Make a distributed program for simulating the registration of a random number of clients. A client is a Java program that connects to the server, registrates and then allows the visualization of the global state of the system.

Use the RMI callbacks to notificate each registered client of the new registrations.

我的问题从第 2 点开始。在我目前看到的所有教程中,客户端创建一个导出的对象客户端并将其传递给服务器导出的远程对象的注册方法。在这里它要求我只传递名称和 IP 但为了进行回调我需要对客户端对象的引用所以我想在注册表中查找每个注册的客户端但我认为这个想法只是一种解决方法我可以直接将客户端对象作为参数传递给方法...

注册后,我认为客户端应该使用其标识符来访问已注册客户端列表,但是如果另一个未注册的客户端使用与已注册客户端的标识符相匹配的自制标识符怎么办?在这种情况下,它可以访问该帐户。有没有一种方法可以安全地识别客户并让他们保持登录状态,而无需要求他们为他们提出的每个请求表明自己的身份?

可选问题:这种程序怎么可能使用注册表?我们怎么知道每个客户端都将一个名称绑定到它的对象而不覆盖另一个名称?例如,如果注册表中有一个名为 "client1" 的对象,则可能有另一个将其对象命名为 "client1" 的客户端覆盖了第一个对象;在这种情况下,第一个对象的名称会发生​​什么情况,又如何在知道这可能发生的情况下使用注册表?...

我为我的英语道歉,但这不是我的主要语言

服务器应为客户端创建令牌。客户端应在所有后续调用中传递它。服务器应该使用它进行身份验证。

GUID 很难伪造。

您无法阻止客户这样做,但如果标识符足够复杂,则很难做到这一点。

您还可以让用户提供凭据(例如用户名和密码)。