Class RestrictionUtils

java.lang.Object
com.sap.cds.services.impl.authorization.RestrictionUtils

public class RestrictionUtils extends Object
  • Method Details

    • passesRestriction

      public static boolean passesRestriction(Restriction restriction, UserInfo user, String event)
      Returns true if and only if the given user passes the given Restriction for the given event, i.e. at least one of the privileges of the restriction is matched.
      Parameters:
      restriction - The Restriction to be tested
      user - The user to be tested
      event - The event to be tested
      Returns:
      true if and only if the given user passes the given restriction for the event
    • passingPrivilegesOfRestriction

      public static Stream<Privilege> passingPrivilegesOfRestriction(Restriction restriction, UserInfo user, String event)
      Returns all Privileges of the passed Restriction which are passed by the current UserInfo with given event.
      Parameters:
      restriction - The Restriction to be analyzed
      user - The user to be tested
      event - The event to be tested
      Returns:
      The passed privileges of empty Stream if not existing
    • hasPrivilege

      public static boolean hasPrivilege(Privilege privilege, UserInfo user, String event)
      Returns true if and only if the given user matches the given privilege for the given event, i.e. the privilege grants the event and the user provides an matching role.
      Parameters:
      privilege - The privilege to be tested
      user - The user to be tested
      event - The event to be tested
      Returns:
      true if and only if the given user matches the given privilege