-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathProtectionDomainHelper.java
More file actions
32 lines (28 loc) · 1.09 KB
/
ProtectionDomainHelper.java
File metadata and controls
32 lines (28 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package cpw.mods.cl;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.VarHandle;
import java.net.URL;
import java.security.*;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
public class ProtectionDomainHelper {
private static final Map<URL, CodeSource> csCache = new HashMap<>();
public static CodeSource createCodeSource(final URL url, final CodeSigner[] signers) {
synchronized (csCache) {
return csCache.computeIfAbsent(url, u->new CodeSource(url, signers));
}
}
private static final Map<CodeSource, ProtectionDomain> pdCache = new HashMap<>();
public static ProtectionDomain createProtectionDomain(CodeSource codeSource, ClassLoader cl) {
synchronized (pdCache) {
return pdCache.computeIfAbsent(codeSource, cs->{
Permissions perms = new Permissions();
perms.add(new AllPermission());
return new ProtectionDomain(codeSource, perms, cl, null);
});
}
}
}