Desktop application with role-based access [closed]

I am developing an application in java (swing) which requires authentication. The application behaviour needs to change depending on the role of the user. These changes might be "complex": consider a tree (maybe representing a file system) such that, based on the role of the authenticated user, the expansion of some node is forbidden. The authentication is based on a local DB which will be most likely used for the roles as well. How would you implement these changes in behaviour? Some ideas are: roles kept as an enum and behaviour determined by switch cases interface-based developement with the FQN of the implementing classes saved on DB: each role implements a component differently and this implementation can be retrieved by the name of the class saved on DB.

Jun 28, 2025 - 02:00
 0

I am developing an application in java (swing) which requires authentication. The application behaviour needs to change depending on the role of the user. These changes might be "complex": consider a tree (maybe representing a file system) such that, based on the role of the authenticated user, the expansion of some node is forbidden.

The authentication is based on a local DB which will be most likely used for the roles as well.

How would you implement these changes in behaviour?

Some ideas are:

  • roles kept as an enum and behaviour determined by switch cases
  • interface-based developement with the FQN of the implementing classes saved on DB: each role implements a component differently and this implementation can be retrieved by the name of the class saved on DB.