• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Security with swing

 
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to develop an application that must authenticate users in swing.
When i start the application , i have the login and password frame .
After that i'm authenticated , i want to restrict acces to the user so that it cannot for example remove an item from the Jlist.
Then the button remove will not be displayed to this user perhaps it is not an administrator.
When the administrator connects , he will able to see the remove button.
He will have all access to manage the items displayed.
How can i do it ?
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This doesn't really have anything to do with Swing per se...

You just need to create a 'User' object when the user has sucessfully logged in. Then store it somewhere where every listener can get to it through a static method.

How you use this 'User' object is up to you... you can make subclasses of 'User' like 'Guest', 'Operator', 'Admin', etc. and test based on that inside the action. This is a really simple model... for more complex security requirements (like 'a user can do this action if they are a manager, but only if they are a manager at the location they are trying to affect') you might want to either extend this model or go with a more 'function-based' security model rather than a 'class-based' security model. If security is a big part of your app you might want to make a class that implements ActionListener and that has a lot of built in calls to do security based things.
 
Engin Okucu
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much. I'm going to try it.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic