Class EssRbacSubject

java.lang.Object
xal.plugin.essrbac.EssRbacSubject
All Implemented Interfaces:
RBACSubject

public class EssRbacSubject extends Object implements RBACSubject
Implementation of RBACSubject. A wrapper to SecurityFacade for getting permissions, and log out.
Version:
0.2 28 Jul 2015
Author:
Blaž Kranjc <blaz.kranjc@cosylab.com>
  • Method Details

    • logout

      public void logout() throws RBACException
      Description copied from interface: RBACSubject
      Logs the user out. If there was an error during the logout a RBACException is thrown.
      Specified by:
      logout in interface RBACSubject
      Throws:
      RBACException - if there was an error while logout.
    • hasPermission

      public boolean hasPermission(String resource, String permission) throws AccessDeniedException, RBACException
      Description copied from interface: RBACSubject
      Checks if the logged in user is granted the permission provided as parameter. If the access is granted, method returns true, if not it returns false. If there was an error a RBACException is thrown.
      Specified by:
      hasPermission in interface RBACSubject
      Parameters:
      resource - the name of the resource
      permission - the name of the permission
      Returns:
      true if the user has the specified permission
      Throws:
      AccessDeniedException
      RBACException - if there was an error
    • hasPermissions

      public Map<String,Boolean> hasPermissions(String resource, String... permissions) throws AccessDeniedException, RBACException
      Description copied from interface: RBACSubject
      Checks if the logged in user is granted the permissions provided as parameters. Method returns a map of permission-grant pairs. For every permission, which was granted, value true is returned; for every permission, which was denied, value false is returned. RBACException is thrown in case of an error.
      Specified by:
      hasPermissions in interface RBACSubject
      Parameters:
      resource - the name of the resource
      permissions - the names of the permission
      Returns:
      map of permission name - permission grant pairs.
      Throws:
      AccessDeniedException - if the user was logged out
      RBACException - if token is missing, or if there was an error while reading or connecting to web services.
    • requestExclusiveAccess

      public ExclusiveAccess requestExclusiveAccess(String resource, String permission, int durationInMinutes) throws AccessDeniedException, RBACException
      Description copied from interface: RBACSubject
      Requests exclusive access to the specified permission for the currently logged in user, on the specified resource. If the access is granted, method returns ExclusivAccess object. If the access was not granted AccessDeniedException is thrown. If there was an error RBACException is thrown.
      Specified by:
      requestExclusiveAccess in interface RBACSubject
      Parameters:
      resource - name of the resource
      permission - name of the permission
      durationInMinutes - the duration of exclusive access in minutes, if less than 1 minute, default value will be used (defined by the service)
      Returns:
      ExclusiveAccess containing information about the requested permission and the expiration date of the exclusive access, if the request was successful.
      Throws:
      AccessDeniedException - if the access was not granted
      RBACException - if there was an error
    • setAutoLogoutTimeout

      public void setAutoLogoutTimeout(int timeoutInMinutes, AutoLogoutCallback callback)
      Description copied from interface: RBACSubject
      Sets the auto logout timeout in minutes. If there was no user activity for the specified duration the facade will notify the user and request confirmation through AutoLogoutCallback. Based on the response or if there is no response for a specific duration, the user will be logged out.
      Specified by:
      setAutoLogoutTimeout in interface RBACSubject
      Parameters:
      timeoutInMinutes - the timeout in minutes after which the user will be logged out if inactive
      callback - handler called before subject is logged out
    • updateLastAction

      public void updateLastAction()
      Description copied from interface: RBACSubject
      Update the last action time to now to prevent auto logout.
      Specified by:
      updateLastAction in interface RBACSubject
    • getUserInfo

      public RBACUserInfo getUserInfo()
      Description copied from interface: RBACSubject
      Get info of logged in RBAC user.
      Specified by:
      getUserInfo in interface RBACSubject
      Returns:
      info of logged in user or null if the user is not logged in.