Class RestrictionUtils
java.lang.Object
com.sap.cds.services.impl.authorization.RestrictionUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanhasPrivilege(Privilege privilege, UserInfo user, String event) Returnstrueif and only if the given user matches the given privilege for the given event, i.e.static booleanpassesRestriction(Restriction restriction, UserInfo user, String event) Returnstrueif and only if the given user passes the givenRestrictionfor the given event, i.e.passingPrivilegesOfRestriction(Restriction restriction, UserInfo user, String event) Returns allPrivileges of the passedRestrictionwhich are passed by the currentUserInfowith given event.
-
Method Details
-
passesRestriction
Returnstrueif and only if the given user passes the givenRestrictionfor the given event, i.e. at least one of the privileges of the restriction is matched.- Parameters:
restriction- TheRestrictionto be testeduser- The user to be testedevent- The event to be tested- Returns:
trueif 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 allPrivileges of the passedRestrictionwhich are passed by the currentUserInfowith given event.- Parameters:
restriction- TheRestrictionto be analyzeduser- The user to be testedevent- The event to be tested- Returns:
- The passed privileges of empty Stream if not existing
-
hasPrivilege
Returnstrueif 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 testeduser- The user to be testedevent- The event to be tested- Returns:
trueif and only if the given user matches the given privilege
-