net.drijf.javaone
Class DelegatingCL

java.lang.Object
  |
  +--java.lang.ClassLoader
        |
        +--java.security.SecureClassLoader
              |
              +--java.net.URLClassLoader
                    |
                    +--net.drijf.javaone.DelegatingCL

public class DelegatingCL
extends java.net.URLClassLoader

Implements a class loader that uses the delegating policy to assign permissions. Furthermore, a class is checked for ClassLoadPermission during loading.

Author:
Otto Moerbeek
See Also:
ClassLoadPermission

Constructor Summary
DelegatingCL(java.net.URL[] urls, java.lang.ClassLoader parent, java.security.Policy policy)
          Construct a new delegating URL classloader, given a policy.
 
Method Summary
protected  java.lang.Class findClass(java.lang.String name)
          Find a class, with an additional check on ClassLoadPermission.
protected  java.security.PermissionCollection getPermissions(java.security.CodeSource cs)
          Return the permission associated with a codesource according to the policy associated with this classloader.
 
Methods inherited from class java.net.URLClassLoader
addURL, definePackage, findResource, findResources, getURLs, newInstance, newInstance
 
Methods inherited from class java.security.SecureClassLoader
defineClass
 
Methods inherited from class java.lang.ClassLoader
defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, resolveClass, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DelegatingCL

public DelegatingCL(java.net.URL[] urls,
                    java.lang.ClassLoader parent,
                    java.security.Policy policy)
Construct a new delegating URL classloader, given a policy.
Parameters:
urls - the urls to look for classes.
parent - the parent class loader.
policy - the policy to use when determining permissions.
Method Detail

findClass

protected java.lang.Class findClass(java.lang.String name)
                             throws java.lang.ClassNotFoundException
Find a class, with an additional check on ClassLoadPermission.
Overrides:
findClass in class java.net.URLClassLoader
Parameters:
name - the name of the class to load.
Returns:
a loaded Classobject.
Throws:
java.lang.ClassNotFoundException - if either the class could not be found, or the class is denied ClassLoadPermission.
See Also:
ClassLoadPermission

getPermissions

protected java.security.PermissionCollection getPermissions(java.security.CodeSource cs)
Return the permission associated with a codesource according to the policy associated with this classloader.
Overrides:
getPermissions in class java.net.URLClassLoader
Parameters:
cs - the code source to return the permissions for.
Returns:
the permission collection associated with the code source according to the policy.