org.jdesktop.swingx.auth
Class UserPermissions

java.lang.Object
  extended by org.jdesktop.swingx.auth.UserPermissions

public class UserPermissions
extends Object

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.


Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
           
 void addPropertyChangeListener(String name, PropertyChangeListener listener)
           
static UserPermissions getInstance()
          Returns the singleton instance of this class.
 String[] getRoles()
          Returns the roles of the currently logged in user
 boolean 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 removePropertyChangeListener(PropertyChangeListener listener)
           
 void removePropertyChangeListener(String name, PropertyChangeListener listener)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)

addPropertyChangeListener

public void addPropertyChangeListener(String name,
                                      PropertyChangeListener listener)

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)

removePropertyChangeListener

public void removePropertyChangeListener(String name,
                                         PropertyChangeListener listener)

getInstance

public static UserPermissions 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

public String[] getRoles()
Returns the roles of the currently logged in user


isUserInRole

public boolean isUserInRole(String role)
Returns true if the user is in the given role (case sensitive).


isUserInARole

public boolean isUserInARole(String[] roles)
Returns true if the user is in one of the given roles (case sensitive).


isUserInRoles

public boolean isUserInRoles(String[] roles)
Returns true if the user is in all of the given roles (case sensitive).