48 |
*/ |
*/ |
49 |
public class SecureClassLoader extends ClassLoader |
public class SecureClassLoader extends ClassLoader |
50 |
{ |
{ |
51 |
|
java.util.WeakHashMap protectionDomainCache = new java.util.WeakHashMap(); |
52 |
|
|
53 |
protected SecureClassLoader(ClassLoader parent) |
protected SecureClassLoader(ClassLoader parent) |
54 |
{ |
{ |
55 |
super(parent); |
super(parent); |
82 |
protected final Class defineClass(String name, byte[] b, int off, int len, |
protected final Class defineClass(String name, byte[] b, int off, int len, |
83 |
CodeSource cs) |
CodeSource cs) |
84 |
{ |
{ |
|
// FIXME: Need to cache ProtectionDomains according to 1.3 docs. |
|
85 |
if (cs != null) |
if (cs != null) |
86 |
{ |
{ |
87 |
ProtectionDomain protectionDomain |
ProtectionDomain protectionDomain; |
88 |
= new ProtectionDomain(cs, getPermissions(cs), this, null); |
|
89 |
|
synchronized (protectionDomainCache) |
90 |
|
{ |
91 |
|
protectionDomain = (ProtectionDomain)protectionDomainCache.get(cs); |
92 |
|
} |
93 |
|
|
94 |
|
if (protectionDomain == null) |
95 |
|
{ |
96 |
|
protectionDomain |
97 |
|
= new ProtectionDomain(cs, getPermissions(cs), this, null); |
98 |
|
synchronized (protectionDomainCache) |
99 |
|
{ |
100 |
|
ProtectionDomain domain |
101 |
|
= (ProtectionDomain)protectionDomainCache.get(cs); |
102 |
|
if (domain == null) |
103 |
|
protectionDomainCache.put(cs, protectionDomain); |
104 |
|
else |
105 |
|
protectionDomain = domain; |
106 |
|
} |
107 |
|
} |
108 |
return super.defineClass(name, b, off, len, protectionDomain); |
return super.defineClass(name, b, off, len, protectionDomain); |
109 |
} |
} |
110 |
else |
else |