Package java.security
Class SecureClassLoader
- java.lang.Object
-
- java.lang.ClassLoader
-
- java.security.SecureClassLoader
-
- Direct Known Subclasses:
URLClassLoader
public class SecureClassLoader extends ClassLoader
SecureClassLoaderrepresents aClassLoaderwhich associates the classes it loads with a code source and provide mechanisms to allow the relevant permissions to be retrieved.
-
-
Field Summary
-
Fields inherited from class java.lang.ClassLoader
proxyCache
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSecureClassLoader()Constructs a new instance ofSecureClassLoader.protectedSecureClassLoader(ClassLoader parent)Constructs a new instance ofSecureClassLoaderwith the specified parentClassLoader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Class<?>defineClass(String name, byte[] b, int off, int len, CodeSource cs)Constructs a new class from an array of bytes containing a class definition in class file format with an optionalCodeSource.protected Class<?>defineClass(String name, ByteBuffer b, CodeSource cs)Constructs a new class from an array of bytes containing a class definition in class file format with an optionalCodeSource.protected PermissionCollectiongetPermissions(CodeSource codesource)Returns thePermissionCollectionfor the specifiedCodeSource.-
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
-
-
-
-
Constructor Detail
-
SecureClassLoader
protected SecureClassLoader()
Constructs a new instance ofSecureClassLoader. The default parentClassLoaderis used.
-
SecureClassLoader
protected SecureClassLoader(ClassLoader parent)
Constructs a new instance ofSecureClassLoaderwith the specified parentClassLoader.- Parameters:
parent- the parentClassLoader.
-
-
Method Detail
-
getPermissions
protected PermissionCollection getPermissions(CodeSource codesource)
Returns thePermissionCollectionfor the specifiedCodeSource.- Parameters:
codesource- the code source.- Returns:
- the
PermissionCollectionfor the specifiedCodeSource.
-
defineClass
protected final Class<?> defineClass(String name, byte[] b, int off, int len, CodeSource cs)
Constructs a new class from an array of bytes containing a class definition in class file format with an optionalCodeSource.- Parameters:
name- the name of the new class.b- a memory image of a class file.off- the start offset in b of the class data.len- the length of the class data.cs- theCodeSource, ornull.- Returns:
- a new class.
- Throws:
IndexOutOfBoundsException- ifofforlenare not valid in respect tob.ClassFormatError- if the specified data is not valid class data.SecurityException- if the package to which this class is to be added, already contains classes which were signed by different certificates, or if the class name begins with "java."
-
defineClass
protected final Class<?> defineClass(String name, ByteBuffer b, CodeSource cs)
Constructs a new class from an array of bytes containing a class definition in class file format with an optionalCodeSource.- Parameters:
name- the name of the new class.b- a memory image of a class file.cs- theCodeSource, ornull.- Returns:
- a new class.
- Throws:
ClassFormatError- if the specified data is not valid class data.SecurityException- if the package to which this class is to be added, already contains classes which were signed by different certificates, or if the class name begins with "java."
-
-