java.security

Class SecureClassLoader

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(ClassLoader parent)
protected SecureClassLoader()
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 PermissionCollectiongetPermissions(CodeSource cs)
Returns a PermissionCollection for the specified CodeSource.

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.