This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Security with swing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Security with swing" Watch "Security with swing" New topic
Author

Security with swing

Engin Okucu
Ranch Hand

Joined: Feb 09, 2002
Posts: 174
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 ?
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

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.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Engin Okucu
Ranch Hand

Joined: Feb 09, 2002
Posts: 174
Thank you very much. I'm going to try it.
 
wood burning stoves
 
subject: Security with swing
 
Similar Threads
How to perform this design?
how to disable the back button when the user logouts...
Java socket connection does not work in Vista
problem with Browser's back button
Design Issue