Class DocumentJarClassLoader

All Implemented Interfaces:
Closeable, AutoCloseable

public class DocumentJarClassLoader extends 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.
  • Field Details

  • Constructor Details

    • DocumentJarClassLoader

      public DocumentJarClassLoader(URL jarURL, URL documentURL)
      Constructor
  • Method Details

    • getPermissions

      protected PermissionCollection getPermissions(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 URLClassLoader
      Parameters:
      codesource - the codesource
      Returns:
      the permissions granted to the codesource