@@ -60,21 +60,22 @@ internal fun <T> sandbox(file: URI, block: () -> T): T {
60
60
PropertyPermission (" org.mockito.internal.*" , " read,write" ),
61
61
ReflectPermission (" *" ),
62
62
)
63
+ val allCodeSource = CodeSource (null , emptyArray<Certificate >())
63
64
if (Files .exists(path)) {
64
65
val policyFile = PolicyFile (file.toURL())
65
- val collection = policyFile.getPermissions(CodeSource ( null , emptyArray< Certificate >()) )
66
+ val collection = policyFile.getPermissions(allCodeSource )
66
67
perms + = collection.elements().toList()
67
68
}
68
- return sandbox(perms) { block() }
69
+ return sandbox(perms, allCodeSource ) { block() }
69
70
}
70
71
71
- internal fun <T > sandbox (permission : List <Permission >, block : () -> T ): T {
72
+ internal fun <T > sandbox (permission : List <Permission >, cs : CodeSource , block : () -> T ): T {
72
73
val perms = permission.fold(Permissions ()) { acc, p -> acc.add(p); acc }
73
- return sandbox(perms) { block() }
74
+ return sandbox(perms, cs ) { block() }
74
75
}
75
76
76
- internal fun <T > sandbox (perms : PermissionCollection , block : () -> T ): T {
77
- val acc = AccessControlContext (arrayOf(ProtectionDomain (null , perms)))
77
+ internal fun <T > sandbox (perms : PermissionCollection , cs : CodeSource , block : () -> T ): T {
78
+ val acc = AccessControlContext (arrayOf(ProtectionDomain (cs , perms)))
78
79
return AccessController .doPrivileged(
79
80
PrivilegedAction {
80
81
block()
0 commit comments