简体   繁体   English

使用用户访问控制设计java GUI程序

[英]Designing a java GUI program with user access control

I want to make an application in java that has a GUI and a database. 我想在java中创建一个具有GUI和数据库的应用程序。 I will be using MYSQL as the database and my recent experience with JavaFX has been quite pleasant so that's what I'll be using to code. 我将使用MYSQL作为数据库,我最近使用JavaFX的经历非常令人愉快,因此我将使用它来编写代码。

My issue is I want user access control and want to show GUI components based on who or what type of user logs in. 我的问题是我想要用户访问控制,并希望根据用户登录的用户和用户类型显示GUI组件。

So let us say it's a school management system and if a teacher logs in the teacher can access his or her course and homework assignments ( via GUI of course) but not any other teacher's. 因此,让我们说这是一个学校管理系统,如果教师登录,教师可以访问他或她的课程和家庭作业(当然通过GUI),但不能访问任何其他教师。 If an admin user logs in he/she can make changes to student profile, etc. but nothing else. 如果管理员用户登录,他/她可以更改学生档案等,但没有别的。

Could someone point me in the right direction with regards to concepts, tutorials, books, sample code, etc. so I can accomplish something like this 有人可以指出我在概念,教程,书籍,示例代码等方面的正确方向,所以我可以完成这样的事情

if(user==teacher){
    stage.setscene(teacherOnlyScene);
    stage.show();
}

Thank you so much! 非常感谢! Apologies if its too subjective. 道歉,如果它太主观。 This is the one site that I use like 90% of the time for answers to all my programming related questions. 这是我使用的一个网站,90%的时间用于回答我所有与编程相关的问题。

The scope of your question is probably too large to be successfully answered here as you are asking about a fairly sizeable and potentially complex portion of the architecture of your final system. 您的问题范围可能太大而无法在此成功解答,因为您询问的是最终系统架构中相当大且可能很复杂的部分。 User access systems are generally quite complex especially if they are highly configurable eg you can grant users privileges outside their basic group privileges etc. 用户访问系统通常非常复杂,特别是如果它们是高度可配置的,例如,您可以授予用户超出其基本组权限的权限等。

Before starting to write any code have a think about what you want to achieve. 在开始编写任何代码之前都要考虑一下你想要实现的目标。 You've already come up with the idea of using user groups which I think is very sensible but there are some questions you need to ask. 您已经想出了使用用户组的想法,我认为这是非常明智的,但您需要提出一些问题。 Can users belong to multiple groups? 用户可以属于多个组吗? Can permissions be assigned to users or can they only be assigned to groups? 是否可以将权限分配给用户,还是只能将其分配给组? Is the administrator a special case or can it be handled as just another group? 管理员是特殊情况还是只能作为另一个组处理?

Have a look at the way Linux handles users and groups to assign permissions. 看看Linux处理用户和组以分配权限的方式。 It's a very well thought out system should offer some inspiration. 这是一个经过深思熟虑的系统应该提供一些灵感。 Additionally the JavaEE 6 documentation orangegoat linked to provides a good overview of security in Java EE (but be warned it's fairly complex). 此外,链接到的JavaEE 6文档orangegoat提供了Java EE安全性的良好概述(但要警告它相当复杂)。

Having said that I feel I must encourage you to consider making this a web based application rather than using JavaFX. 话虽如此,我觉得我必须鼓励您考虑将其设置为基于Web的应用程序,而不是使用JavaFX。 It doesn't sound like you have any particularly complex graphical requirements and it also sounds like you want multiple concurrent access to the system / database (eg more than one teacher can be checking their assignments at a time). 这听起来并不像你有任何特别复杂的图形要求,并且听起来你想要多次并发访问系统/数据库(例如,多个教师可以一次检查他们的任务)。

Perhaps I'm a little biased but I think a JavaEE based web application is a better match for these requirements. 也许我有点偏颇,但我认为基于JavaEE的Web应用程序更符合这些要求。 The business logic and most of the complexity of the multi-user side of things would be handled well by a bunch of EJB 's with all the persistence handled by JPA . 业务逻辑和多用户方面的大多数复杂性将由一堆EJB处理得很好,所有持久性都由JPA处理。 The GUI would be written in JSF and PrimeFaces and the whole lot hosted on GlassFish . GUI将用JSFPrimeFaces编写,整个批量托管在GlassFish上 The real benefit of this set up is that you have a zero installation footprint which will save you a ton of time when rolling out new versions. 这种设置的真正好处是您的安装空间为零,这将为您推出新版本节省大量时间。 Going the JavaEE route will probably make it more difficult for you but I feel it's the correct solution given the requirements. 走JavaEE路线可能会让你更难,但我认为这是满足要求的正确解决方案。

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

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