Class RBACService


  • public final class RBACService
    extends Object
    This class provides the main methods to control the access to a resource depending on the user's roles
    • Method Detail

      • isAuthorized

        public static boolean isAuthorized​(String strResourceTypeCode,
                                           String strResourceId,
                                           String strPermission,
                                           fr.paris.lutece.api.user.User user)
        Check that a given user is allowed to access a resource for a given permission
        Parameters:
        strResourceTypeCode - the key of the resource type being considered
        strResourceId - the id of the resource being considered
        strPermission - the permission needed
        user - the user trying to access the ressource
        Returns:
        true if the user can access the given resource with the given permission, false otherwise
      • isAuthorized

        @Deprecated
        public static boolean isAuthorized​(String strResourceTypeCode,
                                           String strResourceId,
                                           String strPermission,
                                           AdminUser user)
        Deprecated.
        use isAuthorized( String, String, String, User )
        Check that a given user is allowed to access a resource for a given permission
        Parameters:
        strResourceTypeCode - the key of the resource type being considered
        strResourceId - the id of the resource being considered
        strPermission - the permission needed
        user - the user trying to access the ressource
        Returns:
        true if the user can access the given resource with the given permission, false otherwise
      • isAuthorized

        public static boolean isAuthorized​(fr.paris.lutece.portal.service.rbac.RBACResource resource,
                                           String strPermission,
                                           fr.paris.lutece.api.user.User user)
        Check that a given user is allowed to access a resource for a given permission
        Parameters:
        resource - the resource object being considered
        strPermission - the permission needed
        user - the user trying to access the ressource
        Returns:
        true if the user can access the given resource with the given permission, false otherwise
      • isAuthorized

        @Deprecated
        public static boolean isAuthorized​(fr.paris.lutece.portal.service.rbac.RBACResource resource,
                                           String strPermission,
                                           AdminUser user)
        Deprecated.
        use isAuthorized( RBACResource, String, User )
        Check that a given user is allowed to access a resource for a given permission
        Parameters:
        resource - the resource object being considered
        strPermission - the permission needed
        user - the user trying to access the ressource
        Returns:
        true if the user can access the given resource with the given permission, false otherwise
      • isUserInRole

        public static boolean isUserInRole​(fr.paris.lutece.api.user.User user,
                                           String strRole)
        Check that a given user is in the given role
        Parameters:
        user - The user
        strRole - The role
        Returns:
        true if the user has the given role, false otherwise
      • isUserInRole

        @Deprecated
        public static boolean isUserInRole​(AdminUser user,
                                           String strRole)
        Deprecated.
        use isUserInRole( User, String )
        Check that a given user is in the given role
        Parameters:
        user - The user
        strRole - The role
        Returns:
        true if the user has the given role, false otherwise
      • getAuthorizedCollection

        public static <E extends fr.paris.lutece.portal.service.rbac.RBACResource> Collection<E> getAuthorizedCollection​(Collection<E> collection,
                                                                                                                         String strPermission,
                                                                                                                         fr.paris.lutece.api.user.User user)
        Filter a collection of resources for a given user
        Type Parameters:
        E - The RBAC resource
        Parameters:
        collection - The collection to filter
        strPermission - Permission to check
        user - The user
        Returns:
        A filtered collection of resources
      • getAuthorizedCollection

        @Deprecated
        public static <E extends fr.paris.lutece.portal.service.rbac.RBACResource> Collection<E> getAuthorizedCollection​(Collection<E> collection,
                                                                                                                         String strPermission,
                                                                                                                         AdminUser user)
        Deprecated.
        use getAuthorizedCollection( Collection, String, User )
        Filter a collection of resources for a given user
        Type Parameters:
        E - The RBAC resource
        Parameters:
        collection - The collection to filter
        strPermission - Permission to check
        user - The user
        Returns:
        A filtered collection of resources
      • getAuthorizedReferenceList

        public static ReferenceList getAuthorizedReferenceList​(ReferenceList listResources,
                                                               String strResourceType,
                                                               String strPermission,
                                                               fr.paris.lutece.api.user.User user)
        Filter a Reference List for a given user
        Parameters:
        listResources - The list to filter
        strResourceType - The resource type
        strPermission - The permission to check
        user - The user
        Returns:
        The filtered collection
      • getAuthorizedReferenceList

        @Deprecated
        public static ReferenceList getAuthorizedReferenceList​(ReferenceList listResources,
                                                               String strResourceType,
                                                               String strPermission,
                                                               AdminUser user)
        Deprecated.
        use getAuthorizedReferenceList( ReferenceList, String, String, User )
        Filter a Reference List for a given user
        Parameters:
        listResources - The list to filter
        strResourceType - The resource type
        strPermission - The permission to check
        user - The user
        Returns:
        The filtered collection
      • getAuthorizedActionsCollection

        public static <E extends fr.paris.lutece.portal.service.rbac.RBACAction> Collection<E> getAuthorizedActionsCollection​(Collection<E> collection,
                                                                                                                              fr.paris.lutece.portal.service.rbac.RBACResource resource,
                                                                                                                              fr.paris.lutece.api.user.User user)
        Filter a collection of RBACAction for a given user
        Type Parameters:
        E - The RBAC resource
        Parameters:
        collection - The collection to filter
        resource - The resource
        user - The user
        Returns:
        The filtered collection
      • getAuthorizedActionsCollection

        @Deprecated
        public static <E extends fr.paris.lutece.portal.service.rbac.RBACAction> Collection<E> getAuthorizedActionsCollection​(Collection<E> collection,
                                                                                                                              fr.paris.lutece.portal.service.rbac.RBACResource resource,
                                                                                                                              AdminUser user)
        Deprecated.
        use getAuthorizedActionsCollection( Collection, RBACResource, User )
        Filter a collection of RBACAction for a given user
        Type Parameters:
        E - The RBAC resource
        Parameters:
        collection - The collection to filter
        resource - The resource
        user - The user
        Returns:
        The filtered collection