/[classpath]/classpath/java/net/URLClassLoader.java
ViewVC logotype

Diff of /classpath/java/net/URLClassLoader.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.21 by tromey, Fri Apr 23 21:13:20 2004 UTC revision 1.22 by mkoch, Tue Sep 28 09:08:56 2004 UTC
# Line 35  this exception to your version of the li Line 35  this exception to your version of the li
35  obligated to do so.  If you do not wish to do so, delete this  obligated to do so.  If you do not wish to do so, delete this
36  exception statement from your version. */  exception statement from your version. */
37    
38    
39  package java.net;  package java.net;
40    
41  import java.io.ByteArrayOutputStream;  import java.io.ByteArrayOutputStream;
# Line 59  import java.util.jar.JarEntry; Line 60  import java.util.jar.JarEntry;
60  import java.util.jar.JarFile;  import java.util.jar.JarFile;
61  import java.util.jar.Manifest;  import java.util.jar.Manifest;
62    
   
63  /**  /**
64   * A secure class loader that can load classes and resources from   * A secure class loader that can load classes and resources from
65   * multiple locations.  Given an array of <code>URL</code>s this class   * multiple locations.  Given an array of <code>URL</code>s this class
# Line 656  public class URLClassLoader extends Secu Line 656  public class URLClassLoader extends Secu
656          if (loader == null)          if (loader == null)
657            {            {
658              String file = newUrl.getFile();              String file = newUrl.getFile();
659                String protocol = newUrl.getProtocol();
660    
661              // Check that it is not a directory              // Check that it is not a directory
662              if (! (file.endsWith("/") || file.endsWith(File.separator)))              if (! (file.endsWith("/") || file.endsWith(File.separator)))
663                loader = new JarURLLoader(this, newUrl);                loader = new JarURLLoader(this, newUrl);
664              else if ("file".equals(newUrl.getProtocol()))              else if ("file".equals(protocol))
665                loader = new FileURLLoader(this, newUrl);                loader = new FileURLLoader(this, newUrl);
666              else              else
667                loader = new RemoteURLLoader(this, newUrl);                loader = new RemoteURLLoader(this, newUrl);
# Line 811  public class URLClassLoader extends Secu Line 812  public class URLClassLoader extends Secu
812          // And finally construct the class!          // And finally construct the class!
813          SecurityManager sm = System.getSecurityManager();          SecurityManager sm = System.getSecurityManager();
814          if (sm != null && securityContext != null)          if (sm != null && securityContext != null)
815            return (Class) AccessController.doPrivileged(new PrivilegedAction()            {
816                {              return (Class)AccessController.doPrivileged
817                  public Object run()                (new PrivilegedAction()
818                  {                  {
819                    return defineClass(className, classData, 0,                    public Object run()
820                                       classData.length, source);                    {
821                  }                      return defineClass(className, classData,
822                }, securityContext);                                         0, classData.length,
823                                           source);
824                      }
825                    }, securityContext);
826              }
827          else          else
828            return defineClass(className, classData, 0, classData.length, source);            return defineClass(className, classData, 0, classData.length, source);
829        }        }
# Line 955  public class URLClassLoader extends Secu Line 960  public class URLClassLoader extends Secu
960    
961          // If the file end in / it must be an directory.          // If the file end in / it must be an directory.
962          if (file.endsWith("/") || file.endsWith(File.separator))          if (file.endsWith("/") || file.endsWith(File.separator))
963            // Grant permission to read everything in that directory and            {
964            // all subdirectories.              // Grant permission to read everything in that directory and
965            permissions.add(new FilePermission(file + "-", "read"));              // all subdirectories.
966                permissions.add(new FilePermission(file + "-", "read"));
967              }
968          else          else
969            // It is a 'normal' file.            {
970            // Grant permission to access that file.              // It is a 'normal' file.
971            permissions.add(new FilePermission(file, "read"));              // Grant permission to access that file.
972                permissions.add(new FilePermission(file, "read"));
973              }
974        }        }
975      else      else
976        {        {

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.22

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26