Package xal.rbac
Interface RBACSubject
- All Known Implementing Classes:
DummyRbacSubject
,EssRbacSubject
public interface RBACSubject
RBACSubject
is the main entry point authorization of all
actions. It represent a logged in user and is returned by RBACLogin
after the user is logged in.
It also provides a mechanism for autologout of the user.- Author:
- Ivo List, BlazKranjc
-
Method Summary
Modifier and TypeMethodDescriptionGet info of logged in RBAC user.boolean
hasPermission
(String resource, String permission) Checks if the logged in user is granted the permission provided as parameter.hasPermissions
(String resource, String... permissions) Checks if the logged in user is granted the permissions provided as parameters.void
logout()
Logs the user out.requestExclusiveAccess
(String resource, String permission, int durationInMinutes) Requests exclusive access to the specified permission for the currently logged in user, on the specified resource.void
setAutoLogoutTimeout
(int timeoutInMinutes, AutoLogoutCallback callback) Sets the auto logout timeout in minutes.void
Update the last action time to now to prevent auto logout.
-
Method Details
-
logout
Logs the user out. If there was an error during the logout aRBACException
is thrown.- Throws:
RBACException
- if there was an error while logout.
-
hasPermission
boolean hasPermission(String resource, String permission) throws RBACException, AccessDeniedException Checks if the logged in user is granted the permission provided as parameter. If the access is granted, method returnstrue
, if not it returnsfalse
. If there was an error aRBACException
is thrown.- Parameters:
resource
- the name of the resourcepermission
- the name of the permission- Returns:
true
if the user has the specified permission- Throws:
RBACException
- if there was an errorAccessDeniedException
-
hasPermissions
Map<String,Boolean> hasPermissions(String resource, String... permissions) throws AccessDeniedException, RBACException 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.- Parameters:
resource
- the name of the resourcepermissions
- the names of the permission- Returns:
- map of permission name - permission grant pairs.
- Throws:
AccessDeniedException
- if the user was logged outRBACException
- if token is missing, or if there was an error while reading or connecting to web services.
-
requestExclusiveAccess
ExclusiveAccess requestExclusiveAccess(String resource, String permission, int durationInMinutes) throws AccessDeniedException, RBACException 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 grantedAccessDeniedException
is thrown. If there was an errorRBACException
is thrown.- Parameters:
resource
- name of the resourcepermission
- name of the permissiondurationInMinutes
- 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 grantedRBACException
- if there was an error
-
setAutoLogoutTimeout
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 throughAutoLogoutCallback
. Based on the response or if there is no response for a specific duration, the user will be logged out.- Parameters:
timeoutInMinutes
- the timeout in minutes after which the user will be logged out if inactivecallback
- handler called before subject is logged out
-
updateLastAction
void updateLastAction()Update the last action time to now to prevent auto logout. -
getUserInfo
RBACUserInfo getUserInfo()Get info of logged in RBAC user.- Returns:
- info of logged in user or null if the user is not logged in.
-