Package org.jdesktop.swingx.auth
Class UserPermissions
java.lang.Object
org.jdesktop.swingx.auth.UserPermissions
This is a singleton that marks the set of permissions for a given logged in user.
It is one of the optional results of a successful login operation.
The purpose of this class is to provide a central location and client side bridge
to the server side permissions and user roles (see J2EE role based authorization).
This class is used by gui widgets and actions to determine visibility and enabled
status and thus a UI can adapt itself to users with a lower set of privileges.
This class is not meant as a secure barrier! It is only a thin layer to supplant the
server side permissions. This class can be compromized by the user and thus its purpose
is only to help UI flow and navigation and not to prevent attack against a client side
UI. A server implementation must ALWAYS recheck permissions sent by the client regardless
of the client.
- Author:
- Shai Almog
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
addPropertyChangeListener
(String name, PropertyChangeListener listener) static UserPermissions
Returns the singleton instance of this class.String[]
getRoles()
Returns the roles of the currently logged in userboolean
isUserInARole
(String[] roles) Returns true if the user is in one of the given roles (case sensitive).boolean
isUserInRole
(String role) Returns true if the user is in the given role (case sensitive).boolean
isUserInRoles
(String[] roles) Returns true if the user is in all of the given roles (case sensitive).void
void
removePropertyChangeListener
(String name, PropertyChangeListener listener)
-
Method Details
-
addPropertyChangeListener
-
addPropertyChangeListener
-
removePropertyChangeListener
-
removePropertyChangeListener
-
getInstance
Returns the singleton instance of this class. A singleton is used to simplify access for the permissions from every point in the application. -
getRoles
Returns the roles of the currently logged in user -
isUserInRole
Returns true if the user is in the given role (case sensitive). -
isUserInARole
Returns true if the user is in one of the given roles (case sensitive). -
isUserInRoles
Returns true if the user is in all of the given roles (case sensitive).
-