|
36 | 36 | import java.lang.module.ModuleReference; |
37 | 37 | import java.nio.file.Path; |
38 | 38 | import java.util.ArrayList; |
| 39 | +import java.util.Arrays; |
39 | 40 | import java.util.HashSet; |
40 | 41 | import java.util.List; |
41 | 42 | import java.util.Map; |
@@ -324,28 +325,30 @@ private static boolean isPathOnDefaultFilesystem(Path path) { |
324 | 325 | return true; |
325 | 326 | } |
326 | 327 |
|
327 | | - public void checkFileRead(Class<?> callerClass, Path path) { |
328 | | - if (isPathOnDefaultFilesystem(path) == false) { |
329 | | - return; |
330 | | - } |
331 | | - var requestingClass = requestingClass(callerClass); |
332 | | - if (isTriviallyAllowed(requestingClass)) { |
333 | | - return; |
334 | | - } |
| 328 | + public void checkFileRead(Class<?> callerClass, Path... paths) { |
| 329 | + for (var path : paths) { |
| 330 | + if (isPathOnDefaultFilesystem(path) == false) { |
| 331 | + return; |
| 332 | + } |
| 333 | + var requestingClass = requestingClass(callerClass); |
| 334 | + if (isTriviallyAllowed(requestingClass)) { |
| 335 | + return; |
| 336 | + } |
335 | 337 |
|
336 | | - ModuleEntitlements entitlements = getEntitlements(requestingClass); |
337 | | - if (entitlements.fileAccess().canRead(path) == false) { |
338 | | - logger.info(entitlements.fileAccess().toDebugString()); |
339 | | - notEntitled( |
340 | | - Strings.format( |
341 | | - "Not entitled: component [%s], module [%s], class [%s], entitlement [file], operation [read], path [%s]", |
342 | | - entitlements.componentName(), |
343 | | - requestingClass.getModule().getName(), |
344 | | - requestingClass, |
345 | | - FileAccessTree.normalizePath(path) |
346 | | - ), |
347 | | - callerClass |
348 | | - ); |
| 338 | + ModuleEntitlements entitlements = getEntitlements(requestingClass); |
| 339 | + if (entitlements.fileAccess().canRead(path) == false) { |
| 340 | + logger.info(entitlements.fileAccess().toDebugString()); |
| 341 | + notEntitled( |
| 342 | + Strings.format( |
| 343 | + "Not entitled: component [%s], module [%s], class [%s], entitlement [file], operation [read], path [%s]", |
| 344 | + entitlements.componentName(), |
| 345 | + requestingClass.getModule().getName(), |
| 346 | + requestingClass, |
| 347 | + Arrays.stream(paths).map(FileAccessTree::normalizePath).collect(Collectors.joining(", ")) |
| 348 | + ), |
| 349 | + callerClass |
| 350 | + ); |
| 351 | + } |
349 | 352 | } |
350 | 353 | } |
351 | 354 |
|
|
0 commit comments