public abstract class PermissionRule extends Object implements Cloneable
A list of PermissionRules is used to define a PermissionLevel
for a given user. All possible sub-classes of PermissionRule are listed here as
the inner classes.
PermissionRule.SetLevel,
PermissionRule.ApplyStructure,
Structure Permissions (Structure Documentation)| Modifier and Type | Class and Description |
|---|---|
static class |
PermissionRule.ApplyStructure
This rules applies a list of rules taken from a Structure, identified by the structure ID.
|
static class |
PermissionRule.SetLevel
This rule sets the permission level to a specific value in case the user matches
PermissionSubject. |
| Constructor and Description |
|---|
PermissionRule() |
| Modifier and Type | Method and Description |
|---|---|
abstract PermissionLevel |
apply(ApplicationUser user,
PermissionLevel pass,
List<Object> callStack,
La<Long,List<PermissionRule>> resolver)
Apply permission rule and return the result.
|
PermissionRule |
clone() |
static List<PermissionRule> |
decodePermissions(String s)
Utility method to decode a list of
PermissionRules. |
static String |
encodePermissions(List<PermissionRule> permissions)
Utility method to encode a list of
PermissionRules. |
static PermissionRule |
fromEncodedString(String s)
Restores permission rule from its encoded String form.
|
static PermissionRule |
fromEncodedString(String s,
boolean usersAsUserNames)
Restores permission rule from its encoded String form.
|
abstract String |
toEncodedString() |
String |
toString() |
public abstract String toEncodedString()
fromEncodedString(java.lang.String)@NotNull public abstract PermissionLevel apply(@Nullable ApplicationUser user, @NotNull PermissionLevel pass, @Nullable List<Object> callStack, @Nullable La<Long,List<PermissionRule>> resolver)
Apply permission rule and return the result.
Normally you should not call this method directly - call
Structure.getEffectivePermission() instead.
user - the user, null means anonymouspass - the default value, which is returned in case this rule does not applycallStack - auxiliary container for objects used to check for recursive rulesresolver - auxiliary function that converts structure ID into associated list of permission rules - used by PermissionRule.ApplyStructure. If null, PermissionRule.ApplyStructure will not be able to apply and return pass value.@Nullable public static PermissionRule fromEncodedString(@Nullable String s) throws ParseException
s - encoded stringParseException - if the string is not empty, but cannot be translated back to a rulefromEncodedString(String, boolean)@Nullable public static PermissionRule fromEncodedString(@Nullable String s, boolean usersAsUserNames) throws ParseException
s - encoded stringusersAsUserNames - true if user names were used to encode user permissions (Structure version was less than 2.3),
false if user keys were used instead.ParseException - if the string is not empty, but cannot be translated back to a rule@NotNull public static String encodePermissions(@Nullable List<PermissionRule> permissions)
PermissionRules.permissions - a list of permissionstoEncodedString()@NotNull public static List<PermissionRule> decodePermissions(@Nullable String s) throws ParseException
PermissionRules.s - encoded list of permissions, delimited by commaParseException - in case any of the parts used to encode a permission rule failed to decodefromEncodedString(String)public PermissionRule clone()
Copyright © 2023 ALM Works. All Rights Reserved.