简体   繁体   English

如何在Java Application中实现管理员权限?

[英]How to implement Administrator rights in Java Application?

I am developing a Data Modeling Software that is implemented in Java. 我正在开发一个用Java实现的数据建模软件 This application converts the textual data (stored in a database) to graphical form so that users can interpret the data in a more efficient form. 此应用程序将文本数据(存储在数据库中)转换为图形形式,以便用户可以更有效的方式解释数据。 Now, this application will be accessed by 3 kinds of persons: 现在,这个应用程序将由3种人访问:

1. Managers (who can fill the database with data and they can also view the visual form of the data after entering the data into the database) 1.经理 (可以用数据填充数据库,他们还可以在将数据输入数据库后查看数据的可视形式)

2. Viewers (who can only view the visual form of data that has been filled by managers) 2.观众 (只能查看经理填写的视觉形式的数据)

3. Administrators (who can create and manage other administrators, managers and viewers) 3.管理员 (可以创建和管理其他管理员,经理和查看者)

Now, how to implement 3 diff. 现在,如何实现3 diff。 views of the same application. 同一应用程序的视图。

Note: Managers, Viewers and Administrators can be located in any part of the world and should access the application through internet. 注意:经理,查看者和管理员可以位于世界的任何地方,并应通过互联网访问该应用程序。

One idea that came in my mind is as follows: 我想到的一个想法如下:

Step1: Code all the business logic in EJBs so that it can be used in distributed environment (means which can be accessed by several users through internet) 步骤1:对EJB中的所有业务逻辑进行编码,以便可以在分布式环境中使用(多个用户可以通过Internet访问的方式)

Step2: Code 3 Swing GUI Clients: One for administrators, one for managers and one for viewers. 第2步:代码3 Swing GUI客户端:一个用于管理员,一个用于管理员,一个用于查看者。 These 3 GUI clients can access business logic written in EJBs. 这3个GUI客户端可以访问用EJB编写的业务逻辑。

Step3: Distribute the clients corresponding to their users. 步骤3:分发与其用户对应的客户端。 For instance, manager client to managers. 例如,经理客户经理。

================================= QUESTIONS ======================================= ================================= 问题 ================ =======================

Q1. Q1。 Is the above approach is correct? 以上方法是否正确?

Q2. Q2。 This is very common functionality that various softwares have. 这是各种软件具有的非常常见的功能。 So, Do they implement this kind of functionality through this way or any other way? 那么,他们是通过这种方式还是以其他方式实现这种功能?

Q3. Q3。 If any other approach would be more better, then what is that approach? 如果任何其他方法会更好,那么这种方法是什么?

  1. no 没有
  2. no 没有
  3. yes

Making different clients for different security roles is a : 为不同的安全角色创建不同的客户端是:

  • security hole - what if a viewer obtains the administrator version? 安全漏洞 - 如果观众获得管理员版本怎么办?
  • hard to maintain 难以维持

The way to do this is: 这样做的方法是:

  • make the data transferred to the client dependent on a security check 根据安全检查将数据传输到客户端
  • also make various parts of the UI visible/enabled depending on that security check 还可以根据安全检查使UI的各个部分可见/启用
  • the security check is made on the server 安全检查在服务器上进行
  • the security check depends on the currently logged user 安全检查取决于当前登录的用户
  • the user logs in on startup, using his credentials (username/password or digital certificate) 用户使用其凭据(用户名/密码或数字证书)在启动时登录
  • the security roles (administrator, moderator, viewer) are stored on the server side. 安全角色(管理员,主持人,查看者)存储在服务器端。

Then, if needed, you can extend the security model by adding: 然后,如果需要,您可以通过添加以下内容来扩展安全模型:

  • differentiation between per-user and per-role rights 区分每个用户和每个角色的权利
  • rights on specific resources 对特定资源的权利
  • transitive rights 传递权利
  • permissions for specific actions 特定操作的权限

But such a complex user rights and security model is perhaps not needed in your application. 但是在您的应用程序中可能不需要这种复杂的用户权限和安全模型。

I agree with @Bozho except for the following: 除了以下内容,我同意@Bozho:

make various parts of the UI visible/enabled depending on a security check 根据安全检查,使UI的各个部分可见/启用

You actually need to make sure that unwanted access to the data, etc is blocked on the server side , irrespective of whether the client-side UI is visible / enabled. 实际上,您需要确保在服务器端阻止对数据等的不必要访问,而不管客户端UI是否可见/启用。 The reason for this is that any client-side UI disabling code can be subverted. 这样做的原因是任何客户端UI禁用代码都可以被破坏。 Indeed, a bad guy could even entirely bypass your UIs and reverse engineer the application-specific protocols between your client and server code. 实际上,坏人甚至可以完全绕过您的UI并对客户端和服务器代码之间的应用程序特定协议进行反向工程。

This is not to say that you shouldn't also disable / hide parts of the UI that the user is not allowed to use. 这并不是说您不应该禁用/隐藏不允许用户使用的UI部分。 It is just not a good basis for decent security / access control. 它不是良好的安全/访问控制的良好基础。

(UPDATE : @Bozho has ammended his answer now to add server-side blocking to his list. So I now agree with it entirely. ) (更新:@Bozho现在已经修改了他的答案,将服务器端阻塞添加到他的列表中。所以我现在完全赞同它。)

I agree with Bozho. 我同意Bozho的观点。 Another points with the three client approach is: what if the user somehow figures out how to send the operations which isn't available in his client? 三种客户端方法的另一个要点是:如果用户以某种方式弄清楚如何发送其客户端中不可用的操作,该怎么办? What if the same user has two roles (hence is required to have two clients). 如果同一个用户有两个角色(因此需要有两个客户端),该怎么办? And of course you will have plenty to do maintaining one client... 当然,你将有很多工作来维护一个客户......

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

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