Package org.opencastproject.security.api
Class AccessControlUtil
java.lang.Object
org.opencastproject.security.api.AccessControlUtil
Provides common functions helpful in dealing with
AccessControlLists.-
Method Summary
Modifier and TypeMethodDescriptionstatic AccessControlListacl(Either<AccessControlEntry, List<AccessControlEntry>>... entries) Constructor function for ACLs.static ChecksumCalculate an MD5 checksum for anAccessControlList.static Either<AccessControlEntry, List<AccessControlEntry>> Create a list of access control entries for a given role.static Either<AccessControlEntry, List<AccessControlEntry>> Create a single access control entry.static booleanDefine equality on AccessControlLists.static AccessControlListextendAcl(AccessControlList acl, String role, String action, boolean allow) Extends an access control list with an access control entrystatic booleanisAuthorized(AccessControlList acl, User user, Organization org, Object action) Determines whether theAccessControlListpermits a user to perform an action.static booleanisAuthorized(AccessControlList acl, User user, Organization org, Object action, String mediaPackageId) Determines whether theAccessControlListpermits a user to perform an action.static booleanisAuthorizedAll(AccessControlList acl, User user, Organization org, Object... actions) Returns true only if all actions are authorized.static booleanisAuthorizedOne(AccessControlList acl, User user, Organization org, Object... actions) Returns true if at least one action is authorized.static booleanisProhibitedAll(AccessControlList acl, User user, Organization org, Object... actions) Returns true if all actions are prohibited.static booleanisProhibitedOne(AccessControlList acl, User user, Organization org, Object... actions) Returns true if at least one action is prohibited.static AccessControlListreduceAcl(AccessControlList acl, String role, String action) Reduces an access control list by an access control entry
-
Method Details
-
isAuthorized
public static boolean isAuthorized(AccessControlList acl, User user, Organization org, Object action) Determines whether theAccessControlListpermits a user to perform an action. There are three ways a user can be allowed to perform an action:- They have the superuser role
- They have their local organization's admin role
- They have a role listed in the series ACL, with write permission
- Parameters:
acl- theAccessControlListuser- the userorg- the organizationaction- The action to perform.actionmay be an arbitrary object. The authorization check is done on the string representation of the object (#toString()). This allows to group actions as enums and use them without converting them to a string manually. SeePermissions.Action.- Returns:
- whether this action should be allowed
- Throws:
IllegalArgumentException- if any of the arguments are null
-
isAuthorized
public static boolean isAuthorized(AccessControlList acl, User user, Organization org, Object action, String mediaPackageId) Determines whether theAccessControlListpermits a user to perform an action. There are three ways a user can be allowed to perform an action:- They have the superuser role
- They have their local organization's admin role
- They have a role listed in the series ACL, with write permission
- Parameters:
acl- theAccessControlListuser- the userorg- the organizationaction- The action to perform.actionmay be an arbitrary object. The authorization check is done on the string representation of the object (#toString()). This allows to group actions as enums and use them without converting them to a string manually. SeePermissions.Action.mediaPackageId- Only required if episodeRoleId is true.- Returns:
- whether this action should be allowed
- Throws:
IllegalArgumentException- if any of the arguments are null
-
isAuthorizedAll
public static boolean isAuthorizedAll(AccessControlList acl, User user, Organization org, Object... actions) Returns true only if all actions are authorized.- See Also:
-
isAuthorizedOne
public static boolean isAuthorizedOne(AccessControlList acl, User user, Organization org, Object... actions) Returns true if at least one action is authorized.- See Also:
-
isProhibitedAll
public static boolean isProhibitedAll(AccessControlList acl, User user, Organization org, Object... actions) Returns true if all actions are prohibited.- See Also:
-
isProhibitedOne
public static boolean isProhibitedOne(AccessControlList acl, User user, Organization org, Object... actions) Returns true if at least one action is prohibited.- See Also:
-
extendAcl
public static AccessControlList extendAcl(AccessControlList acl, String role, String action, boolean allow) Extends an access control list with an access control entry- Parameters:
acl- the access control list to extendrole- the access control entry roleaction- the access control entry actionallow- whether this access control entry role is allowed to take this action- Returns:
- the extended access control list or the same if already contained
-
reduceAcl
Reduces an access control list by an access control entry- Parameters:
acl- the access control list to reducerole- the role of the access control entry to removeaction- the action of the access control entry to remove- Returns:
- the reduced access control list or the same if already contained
-
acl
Constructor function for ACLs.- See Also:
-
entry
public static Either<AccessControlEntry,List<AccessControlEntry>> entry(String role, String action, boolean allow) Create a single access control entry. -
entries
public static Either<AccessControlEntry,List<AccessControlEntry>> entries(String role, Tuple<String, Boolean>... actions) Create a list of access control entries for a given role. -
equals
Define equality on AccessControlLists. Two AccessControlLists are considered equal if they contain the exact same entries no matter in which order.This has not been implemented in terms of #equals and #hashCode because the list of entries is not immutable and therefore not suitable to be put in a set.
-
calculateChecksum
Calculate an MD5 checksum for anAccessControlList.
-