Class DocumentJarClassLoader

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class DocumentJarClassLoader
    extends java.net.URLClassLoader
    This ClassLoader implementation only grants permission to connect back to the server from where the document referencing the jar file was loaded. A URLClassLoader extension is needed in case the user allows linked jar files to come from a different origin than the document referencing them.
    Version:
    $Id: DocumentJarClassLoader.java 1805419 2017-08-18 13:04:30Z ssteiner $
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.security.CodeSource documentCodeSource
      CodeSource for the Document which referenced the Jar file
    • Constructor Summary

      Constructors 
      Constructor Description
      DocumentJarClassLoader​(java.net.URL jarURL, java.net.URL documentURL)
      Constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.security.PermissionCollection getPermissions​(java.security.CodeSource codesource)
      Returns the permissions for the given codesource object.
      • Methods inherited from class java.net.URLClassLoader

        addURL, close, definePackage, findClass, findResource, findResources, getResourceAsStream, getURLs, newInstance, newInstance
      • Methods inherited from class java.security.SecureClassLoader

        defineClass, defineClass
      • Methods inherited from class java.lang.ClassLoader

        clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getResource, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DocumentJarClassLoader

        public DocumentJarClassLoader​(java.net.URL jarURL,
                                      java.net.URL documentURL)
        Constructor
    • Method Detail

      • getPermissions

        protected java.security.PermissionCollection getPermissions​(java.security.CodeSource codesource)
        Returns the permissions for the given codesource object. The implementation of this method first gets the permissions granted by the policy, and then adds additional permissions based on the URL of the codesource.

        Then, if the documentURL passed at construction time is not null, the permissions granted to that URL are added. As a result, the jar file code will only be able to connect to the server which served the document.

        Overrides:
        getPermissions in class java.net.URLClassLoader
        Parameters:
        codesource - the codesource
        Returns:
        the permissions granted to the codesource