Class PermissionRule
Object
PermissionRule
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
PermissionRule.ApplyStructure
,PermissionRule.SetLevel
A list of PermissionRule
s is used to define a PermissionLevel
for a given user. All possible sub-classes of PermissionRule
are listed here as
the inner classes.
- Author:
- Igor Sereda
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
This rules applies a list of rules taken from a Structure, identified by the structure ID.static class
This rule sets the permission level to a specific value in case the user matchesPermissionSubject
. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract PermissionLevel
apply
(ApplicationUser user, PermissionLevel pass, List<Object> callStack, La<Long, List<PermissionRule>> resolver) Apply permission rule and return the result.clone()
static List<PermissionRule>
Deprecated.Please avoid using this method.static String
encodePermissions
(List<PermissionRule> permissions) Deprecated.Please avoid using this method.static PermissionRule
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
toString()
-
Constructor Details
-
PermissionRule
public PermissionRule()
-
-
Method Details
-
toEncodedString
- Returns:
- a string representation of this permission rule
- See Also:
-
apply
@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.- Parameters:
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 byPermissionRule.ApplyStructure
. If null,PermissionRule.ApplyStructure
will not be able to apply and return pass value.- Returns:
- permission level for the passed user
-
fromEncodedString
Restores permission rule from its encoded String form. In case the string is null or empty, returns null. Use this method only if user keys were used to encode user permissions.- Parameters:
s
- encoded string- Returns:
- the encoded rule, or null if the string is null or empty
- Throws:
ParseException
- if the string is not empty, but cannot be translated back to a rule- See Also:
-
fromEncodedString
@Nullable public static PermissionRule fromEncodedString(@Nullable String s, boolean usersAsUserNames) throws ParseException Restores permission rule from its encoded String form. In case the string is null or empty, returns null.- Parameters:
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.- Returns:
- the encoded rule, or null if the string is null or empty
- Throws:
ParseException
- if the string is not empty, but cannot be translated back to a rule
-
encodePermissions
@NotNull @Deprecated public static String encodePermissions(@Nullable List<PermissionRule> permissions) Deprecated.Please avoid using this method. The resultingString
can't be decoded if any providedPermissionRule
contains "," in its encoded form. Consider using other formats for encoding: JSON or XML.Utility method to encode a list ofPermissionRule
s.- Parameters:
permissions
- a list of permissions- Returns:
- a string with encoded permissions, separated by comma
- See Also:
-
decodePermissions
@NotNull @Deprecated public static List<PermissionRule> decodePermissions(@Nullable String s) throws ParseException Deprecated.Please avoid using this method. It can't decode permission rules if any rule contains "," it its encoded form. Consider using other formats for encoding: JSON or XML.Utility method to decode a list ofPermissionRule
s.- Parameters:
s
- encoded list of permissions, delimited by comma- Returns:
- a restored list of rules
- Throws:
ParseException
- in case any of the parts used to encode a permission rule failed to decode- See Also:
-
clone
-
toString
-