java.security
Class SecureClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by java.security.SecureClassLoader
Direct Known Subclasses:
URLClassLoader

public class SecureClassLoader
extends ClassLoader

A Secure Class Loader for loading classes with additional support for specifying code source and permissions when they are retrieved by the system policy handler.

Since:
1.2

Constructor Summary
protected SecureClassLoader()
           
protected SecureClassLoader(ClassLoader parent)
           
 
Method Summary
protected  Class<?> defineClass(String name, byte[] b, int off, int len, CodeSource cs)
          Creates a class using an array of bytes and a CodeSource.
protected  Class<?> defineClass(String name, ByteBuffer b, CodeSource cs)
          Creates a class using an ByteBuffer and a CodeSource.
protected  PermissionCollection getPermissions(CodeSource cs)
          Returns a PermissionCollection for the specified CodeSource.
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SecureClassLoader

protected SecureClassLoader(ClassLoader parent)

SecureClassLoader

protected SecureClassLoader()
Method Detail

defineClass

protected final Class<?> defineClass(String name,
                                     byte[] b,
                                     int off,
                                     int len,
                                     CodeSource cs)
Creates a class using an array of bytes and a CodeSource.

Parameters:
name - the name to give the class. null if unknown.
b - the data representing the classfile, in classfile format.
off - the offset into the data where the classfile starts.
len - the length of the classfile data in the array.
cs - the CodeSource for the class or null when unknown.
Returns:
the class that was defined and optional CodeSource.
Throws:
ClassFormatError - if the byte array is not in proper classfile format.

defineClass

protected final Class<?> defineClass(String name,
                                     ByteBuffer b,
                                     CodeSource cs)
Creates a class using an ByteBuffer and a CodeSource.

Parameters:
name - the name to give the class. null if unknown.
b - the data representing the classfile, in classfile format.
cs - the CodeSource for the class or null when unknown.
Returns:
the class that was defined and optional CodeSource.
Throws:
ClassFormatError - if the byte array is not in proper classfile format.
Since:
1.5

getPermissions

protected PermissionCollection getPermissions(CodeSource cs)
Returns a PermissionCollection for the specified CodeSource. The default implementation invokes java.security.Policy.getPermissions. This method is called by defineClass that takes a CodeSource argument to build a proper ProtectionDomain for the class being defined.