Class PermissionsParser
java.lang.Object
org.apache.commons.jexl3.internal.introspection.PermissionsParser
A crude parser to configure permissions akin to NoJexl annotations.
The syntax recognizes 2 types of permissions:
- restricting access to packages, classes (and inner classes), methods and fields
- allowing access to a wildcard restricted set of packages
Example:
my.allowed.packages.*
another.allowed.package.*
# nojexl like restrictions
my.package {
class0 {...
class1 {...}
class2 {
...
class3 {}
}
# and eol comment
class0(); # constructors
method(); # method
field; # field
} # end class0
} # end package my.package
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
clear()
Clears this parser internals.Parses permissions from a source.(package private) Permissions
Parses permissions from a source.private int
readClass
(Permissions.NoJexlPackage njpackage, String outer, String inner, int offset) Reads a class permission.private int
readEol
(int offset) Reads a comment till end-of-line.private int
readIdentifier
(StringBuilder id, int offset) Reads an identifier (optionally dot-separated).private int
readIdentifier
(StringBuilder id, int offset, boolean dot, boolean star) Reads an identifier (optionally dot-separated).private void
Reads a package permission.private int
readSpaces
(int offset) Reads spaces.private String
unexpected
(char c, int i) Compose a parsing error message.
-
Field Details
-
src
The source. -
size
private int sizeThe source size. -
packages
The @NoJexl execution-time map. -
wildcards
The set of wildcard imports.
-
-
Constructor Details
-
PermissionsParser
public PermissionsParser()Basic ctor.
-
-
Method Details
-
clear
private void clear()Clears this parser internals. -
parse
Parses permissions from a source.- Parameters:
srcs
- the sources- Returns:
- the permissions map
-
parse
Permissions parse(Set<String> wildcards, Map<String, Permissions.NoJexlPackage> packages, String... srcs) Parses permissions from a source.- Parameters:
wildcards
- the set of allowed packagespackages
- the map of restricted elementssrcs
- the sources- Returns:
- the permissions map
-
unexpected
Compose a parsing error message.- Parameters:
c
- the offending characteri
- the offset position- Returns:
- the error message
-
readEol
private int readEol(int offset) Reads a comment till end-of-line.- Parameters:
offset
- initial position- Returns:
- position after comment
-
readSpaces
private int readSpaces(int offset) Reads spaces.- Parameters:
offset
- initial position- Returns:
- position after spaces
-
readIdentifier
Reads an identifier (optionally dot-separated).- Parameters:
id
- the builder to fill the identifier character withoffset
- the initial reading position- Returns:
- the position after the identifier
-
readIdentifier
Reads an identifier (optionally dot-separated).- Parameters:
id
- the builder to fill the identifier character withoffset
- the initial reading positiondot
- whether dots (.) are allowedstar
- whether stars (*) are allowed- Returns:
- the position after the identifier
-
readPackages
private void readPackages()Reads a package permission. -
readClass
Reads a class permission.- Parameters:
njpackage
- the owning packageouter
- the outer class (if any)inner
- the inner class name (if any)offset
- the initial parsing position in the source- Returns:
- the new parsing position
-