Methods Summary |
---|
public static synchronized PermissionCache | createPermissionCache(java.lang.String pcID, java.security.CodeSource codesource, java.security.Permission[] perms, java.lang.String name)Create a PermissionCache object.
If the corresponding object exists, then it will overwrite the
previous one.
if (!supportsReuse) {
return null;
}
Integer key = getNextKey();
PermissionCache cache =
new PermissionCache(key, pcID, codesource, perms, name);
return registerPermissionCache(cache);
|
public static synchronized PermissionCache | createPermissionCache(java.lang.String pcID, java.security.CodeSource codesource, java.lang.Class clazz, java.lang.String name)Create a PermissionCache object.
If the corresponding object exists, then it will overwrite the
previous one.
if (!supportsReuse) {
return null;
}
Integer key = getNextKey();
PermissionCache cache =
new PermissionCache(key, pcID, codesource, clazz, name);
return registerPermissionCache(cache);
|
private static synchronized PermissionCache | createSecurityManagerCache()
Integer key = getNextKey();
PermissionCache cache =
new PermissionCache(key, null, null, protoPerms, null);
return registerPermissionCache(cache);
|
private static java.lang.Integer | getNextKey()Reserve the next Cache Key for subsequent registration.
try {
// make a call to policy.refresh() to see if the provider
// calls the supportsReuse callback (see resetCaches below).
// which will set supportsReuse to true (to enable caching).
Policy policy = Policy.getPolicy();
if (policy != null) {
policy.refresh();
}
} catch(Exception pe) {
}
Integer key = Integer.valueOf(factoryKey++);
while (cacheMap.get(key) != null) {
key = Integer.valueOf(factoryKey++);
}
return key;
|
private static PermissionCache | registerPermissionCache(PermissionCache cache)Register a PermissionCache object with the factory. If an object is
already registered at the key, it will be overidden.
cacheMap.put(cache.getFactoryKey(),cache);
return cache;
|
public static synchronized PermissionCache | removePermissionCache(PermissionCache cache)
PermissionCache rvalue = null;
if (cache != null) {
Object value = cacheMap.remove(cache.getFactoryKey());
if (value != null && value instanceof PermissionCache) {
rvalue = (PermissionCache) value;
rvalue.reset();
}
}
return rvalue;
|
public static synchronized void | resetCaches()This resets all caches inside the factory.
supportsReuse = true;
SecurityManager sm = System.getSecurityManager();
if (sm != null && sm instanceof J2EESecurityManager) {
if (!((J2EESecurityManager)sm).cacheEnabled()) {
((J2EESecurityManager)sm).enablePermissionCache
(securityManagerCache);
}
}
Iterator iter = cacheMap.values().iterator();
while (iter.hasNext()) {
Object cache = iter.next();
if (cache instanceof PermissionCache) {
((PermissionCache) cache).reset();
}
}
|