Class WikiUserPermissions

java.lang.Object
fr.paris.lutece.plugins.wiki.service.security.WikiUserPermissions

public final class WikiUserPermissions extends Object
Snapshot of everything that grants a user access to wiki items: the roles carried by the session, the permissions granted to the user individually or to a population they belong to, and the RBAC permissions granted to the roles the user carries. The roles come from the session, so building a snapshot costs nothing. The reads gathering the granted permissions are issued on the first item check and never again, so a single build serves any number of checks, and a role-only check costs no query at all.
  • Method Details

    • forUser

      public static WikiUserPermissions forUser(fr.paris.lutece.portal.service.security.LuteceUser user)
      Builds the snapshot of a user, reading their roles from the session.
      Parameters:
      user - the Lutece user, may be null for an anonymous visitor
      Returns:
      the permissions of that user
    • hasRole

      public boolean hasRole(String strRole)
      Tells whether the user carries the given role.
      Parameters:
      strRole - the role key
      Returns:
      true when the user carries it
    • isAllowedToView

      public boolean isAllowedToView(AbstractWikiItem item)
      Tells whether the user is allowed to view the item, either individually or through a role.
      Parameters:
      item - the wiki item
      Returns:
      true when allowed
    • isAllowedToEdit

      public boolean isAllowedToEdit(AbstractWikiItem item)
      Tells whether the user is allowed to edit the item, either individually or through a role.
      Parameters:
      item - the wiki item
      Returns:
      true when allowed