Class FilesystemPolicy
java.lang.Object
eu.mrapik.minecraftservermcp.config.FilesystemPolicy
Evaluates whether a path relative to the server root is allowed by
ToolAccessConfig file/folder lists.
Semantics (high level):
nulllist = rule not in effect (no restriction from that list).- Empty list after parsing = deny-all for that dimension (whitelist with no entries blocks everything).
- Folder whitelist/blacklist match path prefixes (directory containment).
- File whitelist/blacklist match either exact relative paths or, for patterns without
/, the final path segment (filename) anywhere under the tree.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanallowsPath(String relativePathNormalized) Evaluates folder and file rules in order: folder whitelist, folder blacklist, file whitelist, file blacklist.static FilesystemPolicyBuilds a policy from the file-related fields of a tool config.
-
Constructor Details
-
FilesystemPolicy
public FilesystemPolicy(@Nullable @Nullable List<String> fileWhitelist, @Nullable @Nullable List<String> fileBlacklist, @Nullable @Nullable List<String> folderWhitelist, @Nullable @Nullable List<String> folderBlacklist) Internal constructor after optional list normalization.- Parameters:
fileWhitelist- normalized patterns, or nullfileBlacklist- normalized patterns, or nullfolderWhitelist- normalized prefixes, or nullfolderBlacklist- normalized prefixes, or null
-
-
Method Details
-
fromToolConfig
Builds a policy from the file-related fields of a tool config.- Parameters:
cfg- tool policy containing file/folder lists- Returns:
- policy for
allowsPath(String)
-
allowsPath
Evaluates folder and file rules in order: folder whitelist, folder blacklist, file whitelist, file blacklist.- Parameters:
relativePathNormalized- path relative to server root, forward slashes, no leading slash- Returns:
- true if all configured rules pass
-