Class RBACService


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

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static <E extends fr.paris.lutece.portal.service.rbac.RBACAction>
      java.util.Collection<E>
      getAuthorizedActionsCollection​(java.util.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
      static <E extends fr.paris.lutece.portal.service.rbac.RBACAction>
      java.util.Collection<E>
      getAuthorizedActionsCollection​(java.util.Collection<E> collection, fr.paris.lutece.portal.service.rbac.RBACResource resource, AdminUser user)
      Deprecated.
      use getAuthorizedActionsCollection( Collection, RBACResource, User )
      static <E extends fr.paris.lutece.portal.service.rbac.RBACResource>
      java.util.Collection<E>
      getAuthorizedCollection​(java.util.Collection<E> collection, java.lang.String strPermission, fr.paris.lutece.api.user.User user)
      Filter a collection of resources for a given user
      static <E extends fr.paris.lutece.portal.service.rbac.RBACResource>
      java.util.Collection<E>
      getAuthorizedCollection​(java.util.Collection<E> collection, java.lang.String strPermission, AdminUser user)
      Deprecated.
      use getAuthorizedCollection( Collection, String, User )
      static ReferenceList getAuthorizedReferenceList​(ReferenceList listResources, java.lang.String strResourceType, java.lang.String strPermission, fr.paris.lutece.api.user.User user)
      Filter a Reference List for a given user
      static ReferenceList getAuthorizedReferenceList​(ReferenceList listResources, java.lang.String strResourceType, java.lang.String strPermission, AdminUser user)
      Deprecated.
      use getAuthorizedReferenceList( ReferenceList, String, String, User )
      static boolean isAuthorized​(fr.paris.lutece.portal.service.rbac.RBACResource resource, java.lang.String strPermission, fr.paris.lutece.api.user.User user)
      Check that a given user is allowed to access a resource for a given permission
      static boolean isAuthorized​(fr.paris.lutece.portal.service.rbac.RBACResource resource, java.lang.String strPermission, AdminUser user)
      Deprecated.
      use isAuthorized( RBACResource, String, User )
      static boolean isAuthorized​(java.lang.String strResourceTypeCode, java.lang.String strResourceId, java.lang.String strPermission, fr.paris.lutece.api.user.User user)
      Check that a given user is allowed to access a resource for a given permission
      static boolean isAuthorized​(java.lang.String strResourceTypeCode, java.lang.String strResourceId, java.lang.String strPermission, AdminUser user)
      Deprecated.
      use isAuthorized( String, String, String, User )
      static boolean isUserInRole​(fr.paris.lutece.api.user.User user, java.lang.String strRole)
      Check that a given user is in the given role
      static boolean isUserInRole​(AdminUser user, java.lang.String strRole)
      Deprecated.
      use isUserInRole( User, String )
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • isAuthorized

        public static boolean isAuthorized​(java.lang.String strResourceTypeCode,
                                           java.lang.String strResourceId,
                                           java.lang.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​(java.lang.String strResourceTypeCode,
                                           java.lang.String strResourceId,
                                           java.lang.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,
                                           java.lang.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,
                                           java.lang.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,
                                           java.lang.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,
                                           java.lang.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> java.util.Collection<E> getAuthorizedCollection​(java.util.Collection<E> collection,
                                                                                                                                   java.lang.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> java.util.Collection<E> getAuthorizedCollection​(java.util.Collection<E> collection,
                                                                                                                                   java.lang.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,
                                                               java.lang.String strResourceType,
                                                               java.lang.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,
                                                               java.lang.String strResourceType,
                                                               java.lang.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> java.util.Collection<E> getAuthorizedActionsCollection​(java.util.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> java.util.Collection<E> getAuthorizedActionsCollection​(java.util.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